Changeset f640dd6c2dba…
Parent 711969d1c9cb…
by
Changes to 2 files · Browse files at f640dd6c2dba Showing diff from parent 711969d1c9cb Diff from another changeset...
@@ -610,9 +610,17 @@ super(MemoryObjectStore, self).__init__()
self._data = {}
+ def _to_hexsha(self, sha):
+ if len(sha) == 40:
+ return sha
+ elif len(sha) == 20:
+ return sha_to_hex(sha)
+ else:
+ raise ValueError("Invalid sha %r" % sha)
+
def contains_loose(self, sha):
"""Check if a particular object is present by SHA1 and is loose."""
- return sha in self._data
+ return self._to_hexsha(sha) in self._data
def contains_packed(self, sha):
"""Check if a particular object is present by SHA1 and is packed."""
@@ -633,15 +641,15 @@ :param name: sha for the object.
:return: tuple with numeric type and object contents.
"""
- obj = self[name]
+ obj = self[self._to_hexsha(name)]
return obj.type_num, obj.as_raw_string()
def __getitem__(self, name):
- return self._data[name]
+ return self._data[self._to_hexsha(name)]
def __delitem__(self, name):
"""Delete an object from this store, for testing only."""
- del self._data[name]
+ del self._data[self._to_hexsha(name)]
def add_object(self, obj):
"""Add a single object to this object store.
|
@@ -123,7 +123,7 @@ del self.store[cs[-1].id]
for i in xrange(1, 11):
self.assertWalkYields(cs[:i], [cs[0].id], max_entries=i)
- self.assertRaises(MissingCommitError, Walker, self.store, cs[0].id)
+ self.assertRaises(MissingCommitError, Walker, self.store, [cs[-1].id])
def test_branch(self):
c1, x2, x3, y4 = self.make_commits([[1], [2, 1], [3, 2], [4, 1]])
|
Loading...