* Repo.get_blob, Repo.commit, Repo.tag and Repo.tree are now deprecated.
(Jelmer Vernooij)
+ API CHANGES
+
+ * Blob.chunked was added. (Jelmer Vernooij)
+
0.5.0 2010-03-03
BUG FIXES
_type = BLOB_ID
_num_type = 3
- _needs_serialization = False
- _needs_parsing = False
+
+ def __init__(self):
+ super(Blob, self).__init__()
+ self._chunked = []
+ self._text = ""
+ self._needs_parsing = False
+ self._needs_serialization = False
def get_data(self):
+ if self._needs_serialization:
+ self.serialize()
return self._text
def set_data(self, data):
self._text = data
+ self._needs_parsing = True
+ self._needs_serialization = False
data = property(get_data, set_data,
"The text contained within the blob object.")
+ def get_chunked(self):
+ if self._needs_parsing:
+ self._parse_text()
+ return self._chunked
+
+ def set_chunked(self, chunks):
+ self._chunked = chunks
+ self._needs_serialization = True
+
+ chunked = property(get_chunked, set_chunked,
+ "The text within the blob object, as chunks (not necessarily lines).")
+
+ def _parse_text(self):
+ self._chunked = [self._text]
+
+ def serialize(self):
+ self._text = "".join(self._chunked)
+
@classmethod
def from_file(cls, filename):
blob = ShaFile.from_file(filename)
b = Blob.from_string(string)
self.assertEqual(b.data, string)
self.assertEqual(b.sha().hexdigest(), b_sha)
+
+ def test_chunks(self):
+ string = 'test 5\n'
+ b = Blob.from_string(string)
+ self.assertEqual([string], b.chunked)
+
+ def test_set_chunks(self):
+ b = Blob()
+ b.chunked = ['te', 'st', ' 5\n']
+ self.assertEqual('test 5\n', b.data)
+ b.chunked = ['te', 'st', ' 6\n']
+ self.assertEqual('test 6\n', b.as_raw_string())
def test_parse_legacy_blob(self):
string = 'test 3\n'