Kiln » Dependencies » Dulwich Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in master-1, master-0, and 0.9.4

ObjectStore.get_graph_walker() now no longer yields the same
revision more than once. This has a significant improvement for

performance when wide revision graphs are involved.

Changeset fcbe1e1e6040

Parent fdbf28356688

by Jelmer Vernooij

Changes to 3 files · Browse files at fcbe1e1e6040 Showing diff from parent fdbf28356688 Diff from another changeset...

Change 1 of 1 Show Entire File NEWS Stacked
 
34
35
36
 
 
 
 
 
37
38
39
 
34
35
36
37
38
39
40
41
42
43
44
@@ -34,6 +34,11 @@
  * Support ~ in git:// URL paths. (Jelmer Vernooij, #813555)     * Make ShaFile.__eq__ work when other is not a ShaFile. (Dave Borowitz) + + * ObjectStore.get_graph_walker() now no longer yields the same + revision more than once. This has a significant improvement for + performance when wide revision graphs are involved. + (Jelmer Vernooij, #818168)     API CHANGES  
 
779
780
781
782
783
 
 
 
 
784
785
786
 
794
795
796
797
 
798
799
 
779
780
781
 
 
782
783
784
785
786
787
788
 
796
797
798
 
799
800
801
@@ -779,8 +779,10 @@
  # collect all ancestors   new_ancestors = set()   for a in ancestors: - if a in self.parents: - new_ancestors.update(self.parents[a]) + ps = self.parents.get(a) + if ps is not None: + new_ancestors.update(ps) + self.parents[a] = None     # no more ancestors; stop   if not new_ancestors: @@ -794,6 +796,6 @@
  ret = self.heads.pop()   ps = self.get_parents(ret)   self.parents[ret] = ps - self.heads.update(ps) + self.heads.update([p for p in ps if not p in self.parents])   return ret   return None
 
41
42
43
 
44
45
46
 
300
301
302
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
42
43
44
45
46
47
 
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
@@ -41,6 +41,7 @@
 from dulwich.object_store import (   DiskObjectStore,   MemoryObjectStore, + ObjectStoreGraphWalker,   tree_lookup_path,   )  from dulwich.pack import ( @@ -300,3 +301,58 @@
  self.assertRaises(NotTreeError, tree_lookup_path, self.get_object, self.tree_id, 'ad/b/j')    # TODO: MissingObjectFinderTests + +class ObjectStoreGraphWalkerTests(TestCase): + + def get_walker(self, heads, parent_map): + return ObjectStoreGraphWalker(heads, + parent_map.__getitem__) + + def test_empty(self): + gw = self.get_walker([], {}) + self.assertIs(None, gw.next()) + gw.ack("aa" * 20) + self.assertIs(None, gw.next()) + + def test_descends(self): + gw = self.get_walker(["a"], {"a": ["b"], "b": []}) + self.assertEquals("a", gw.next()) + self.assertEquals("b", gw.next()) + + def test_present(self): + gw = self.get_walker(["a"], {"a": ["b"], "b": []}) + gw.ack("a") + self.assertIs(None, gw.next()) + + def test_parent_present(self): + gw = self.get_walker(["a"], {"a": ["b"], "b": []}) + self.assertEquals("a", gw.next()) + gw.ack("a") + self.assertIs(None, gw.next()) + + def test_child_ack_later(self): + gw = self.get_walker(["a"], {"a": ["b"], "b": ["c"], "c": []}) + self.assertEquals("a", gw.next()) + self.assertEquals("b", gw.next()) + gw.ack("a") + self.assertIs(None, gw.next()) + + def test_only_once(self): + # a b + # | | + # c d + # \ / + # e + gw = self.get_walker(["a", "b"], { + "a": ["c"], + "b": ["d"], + "c": ["e"], + "d": ["e"], + "e": [], + }) + self.assertEquals("a", gw.next()) + self.assertEquals("c", gw.next()) + gw.ack("a") + self.assertEquals("b", gw.next()) + self.assertEquals("d", gw.next()) + self.assertIs(None, gw.next())