Skip to content

Commit 18be097

Browse files
committed
Removed blob.data property as there is no real reason for an exception to the rule of trying not to cache possibly heavy data. The data_stream method should be used instead
1 parent 77cd665 commit 18be097

File tree

4 files changed

+24
-36
lines changed

4 files changed

+24
-36
lines changed

CHANGES

+23-15
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,34 @@
11
=======
22
CHANGES
33
=======
4+
45
0.3
56
===
6-
* ConcurrentWriteOperation was removed, and replaced by LockedFD
7-
* IndexFile.get_entries_key was renamed to entry_key
8-
* IndexEntry instances contained in IndexFile.entries now use binary sha's. Use
9-
the .hexsha property to obtain the hexadecimal version. The .sha property
10-
was removed to make the use of the respective sha more explicit.
11-
* IndexFile.write_tree: removed missing_ok keyword, its always True now
12-
Instead of raising GitCommandError it raises UnmergedEntriesError
13-
* diff.Diff.null_hex_sha renamed to NULL_HEX_SHA, to be conforming with
14-
the naming in the Object base class
15-
* Object instances, and everything derived from it, now use binary sha's internally. The 'sha' member was removed, in favor of the 'binsha' member.
16-
An 'hexsha' property is available for convenient conversions.
17-
They may only be initialized using their binary shas, reference names or revision specs are not allowed anymore.
18-
* The .data attribute was removed from the Object type, it is only available
19-
on the Blob type.
20-
* For consistency with naming conventions used in sub-modules like gitdb, the following modules have been renamed
7+
Renamed Modules
8+
---------------
9+
* For consistency with naming conventions used in sub-modules like gitdb, the following modules have been renamed
2110
* git.utils -> git.util
2211
* git.errors -> git.exc
2312
* git.objects.utils -> git.objects.util
13+
14+
General
15+
-------
16+
* Object instances, and everything derived from it, now use binary sha's internally. The 'sha' member was removed, in favor of the 'binsha' member.
17+
An 'hexsha' property is available for convenient conversions.
18+
They may only be initialized using their binary shas, reference names or revision specs are not allowed anymore.
19+
* IndexEntry instances contained in IndexFile.entries now use binary sha's. Use the .hexsha property to obtain the hexadecimal version. The .sha property was removed to make the use of the respective sha more explicit.
20+
* If objects are instantiated explicitly, a binary sha is required to identify the object, where previously any rev-spec could be used. The ref-spec compatible
21+
version still exists as Object.new or Repo.commit|Repo.tree respectively.
22+
* The .data attribute was removed from the Object type, to obtain plain data, use the data_stream property instead.
23+
* ConcurrentWriteOperation was removed, and replaced by LockedFD
24+
* IndexFile.get_entries_key was renamed to entry_key
25+
* IndexFile.write_tree: removed missing_ok keyword, its always True now
26+
Instead of raising GitCommandError it raises UnmergedEntriesError.
27+
This is required as the pure-python implementation doesn't support the missing_ok keyword yet.
28+
* diff.Diff.null_hex_sha renamed to NULL_HEX_SHA, to be conforming with
29+
the naming in the Object base class
30+
31+
2432

2533

2634
0.2 Beta 2

lib/git/objects/blob.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,7 @@ class Blob(base.IndexObject):
1414
DEFAULT_MIME_TYPE = "text/plain"
1515
type = "blob"
1616

17-
__slots__ = "data"
18-
19-
def _set_cache_(self, attr):
20-
if attr == "data":
21-
ostream = self.repo.odb.stream(self.binsha)
22-
self.size = ostream.size
23-
self.data = ostream.read()
24-
# assert ostream.type == self.type, _assertion_msg_format % (self.binsha, ostream.type, self.type)
25-
else:
26-
super(Blob, self)._set_cache_(attr)
27-
# END handle data
17+
__slots__ = tuple()
2818

2919
@property
3020
def mime_type(self):

test/git/test_base.py

-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ def test_base_object(self):
4242
assert item.hexsha == hexsha
4343
assert item.type == typename
4444
assert item.size
45-
if isinstance(item, Blob):
46-
assert item.data
4745
assert item == item
4846
assert not item != item
4947
assert str(item) == item.hexsha

test/git/test_blob.py

-8
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@
1010

1111
class TestBlob(TestBase):
1212

13-
def test_should_cache_data(self):
14-
bid = 'a802c139d4767c89dcad79d836d05f7004d39aac'
15-
blob = Blob(self.rorepo, hex_to_bin(bid))
16-
blob.data
17-
assert blob.data
18-
blob.size
19-
blob.size
20-
2113
def test_mime_type_should_return_mime_type_for_known_types(self):
2214
blob = Blob(self.rorepo, **{'binsha': Blob.NULL_BIN_SHA, 'path': 'foo.png'})
2315
assert_equal("image/png", blob.mime_type)

0 commit comments

Comments
 (0)