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

Delegate SHA peeling to the object store.

Once a ref is resolved to a SHA, we no longer need access to the
RefsContainer, so the ObjectStore can do all the work.

Changeset 3be37749daa8

Parent c1ea0a7ab91e

committed by Jelmer Vernooij

authored by Dave Borowitz

Changes to 4 files · Browse files at 3be37749daa8 Showing diff from parent c1ea0a7ab91e Diff from another changeset...

Change 1 of 1 Show Entire File NEWS Stacked
 
23
24
25
 
 
26
27
28
 
23
24
25
26
27
28
29
30
@@ -23,6 +23,8 @@
  * Initial work on a fastimport parser. (Jelmer Vernooij)     * New dulwich.pack.MemoryPackIndex class. (Jelmer Vernooij) + + * Delegate SHA peeling to the object store. (Dave Borowitz)     TESTS  
 
41
42
43
 
44
45
46
 
243
244
245
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
247
248
 
41
42
43
44
45
46
47
 
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
@@ -41,6 +41,7 @@
  sha_to_hex,   hex_to_filename,   S_ISGITLINK, + object_class,   )  from dulwich.pack import (   Pack, @@ -243,6 +244,21 @@
  """   return self.iter_shas(self.find_missing_objects(have, want, progress))   + def peel_sha(self, sha): + """Peel all tags from a SHA. + + :param sha: The object SHA to peel. + :return: The fully-peeled SHA1 of a tag object, after peeling all + intermediate tags; if the original ref does not point to a tag, this + will equal the original SHA1. + """ + obj = self[sha] + obj_class = object_class(obj.type_name) + while obj_class is Tag: + obj_class, sha = obj.object + obj = self[sha] + return obj +    class PackBasedObjectStore(BaseObjectStore):  
Change 1 of 1 Show Entire File dulwich/​repo.py Stacked
 
924
925
926
927
928
 
 
929
930
931
932
933
934
935
936
937
938
939
940
 
941
942
943
 
924
925
926
 
 
927
928
929
930
931
932
933
934
 
 
 
 
 
 
935
936
937
938
@@ -924,20 +924,15 @@
  def get_peeled(self, ref):   """Get the peeled value of a ref.   - :param ref: the refname to peel - :return: the fully-peeled SHA1 of a tag object, after peeling all + :param ref: The refname to peel. + :return: The fully-peeled SHA1 of a tag object, after peeling all   intermediate tags; if the original ref does not point to a tag, this   will equal the original SHA1.   """   cached = self.refs.get_peeled(ref)   if cached is not None:   return cached - obj = self[ref] - obj_class = object_class(obj.type_name) - while obj_class is Tag: - obj_class, sha = obj.object - obj = self.get_object(sha) - return obj.id + return self.object_store.peel_sha(self.refs[ref]).id     def revision_history(self, head):   """Returns a list of the commits reachable from head.
 
27
28
29
 
30
 
31
32
33
 
127
128
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
131
132
 
27
28
29
30
31
32
33
34
35
 
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
@@ -27,7 +27,9 @@
  commit_tree,   )  from dulwich.objects import ( + object_class,   Blob, + Tag,   )  from dulwich.object_store import (   DiskObjectStore, @@ -127,6 +129,22 @@
  actual = self.store.iter_tree_contents(tree_id, include_trees=True)   self.assertEquals(expected, list(actual))   + def make_tag(self, name, obj): + tag = make_object(Tag, name=name, message='', + tag_time=12345, tag_timezone=0, + tagger='Test Tagger <test@example.com>', + object=(object_class(obj.type_name), obj.id)) + self.store.add_object(tag) + return tag + + def test_peel_sha(self): + self.store.add_object(testobject) + tag1 = self.make_tag('1', testobject) + tag2 = self.make_tag('2', testobject) + tag3 = self.make_tag('3', testobject) + for obj in [testobject, tag1, tag2, tag3]: + self.assertEqual(testobject, self.store.peel_sha(obj.id)) +    class MemoryObjectStoreTests(ObjectStoreTests, TestCase):