Kiln » Dependencies » Dulwich Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in master

dulwich.object_store: Ensure only valid data is added to the memory object store, fix a walk test.

Changeset 799f53753232

Parent 883b904fcd2e

by Jelmer Vernooij

Changes to 2 files · Browse files at 799f53753232 Showing diff from parent 883b904fcd2e Diff from another changeset...

 
610
611
612
 
 
 
 
 
 
 
 
613
614
615
 
616
617
618
 
633
634
635
636
 
637
638
639
640
 
641
642
643
644
 
645
646
647
 
610
611
612
613
614
615
616
617
618
619
620
621
622
 
623
624
625
626
 
641
642
643
 
644
645
646
647
 
648
649
650
651
 
652
653
654
655
@@ -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
124
125
126
 
127
128
129
 
123
124
125
 
126
127
128
129
@@ -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]])