diff tests/test-revlog-raw.py @ 34160:c8b6ed51386b

changegroup: remove changegroup dependency from revlog.addgroup Previously revlog.addgroup would accept a changegroup and a linkmapper and use it to iterate of the deltas. As part of untangling the revlog-changegroup interdependency, let's move the changegroup delta iteration logic to it's own function and pass the simple iterator to the revlog instead. This will make it easier to introduce non-revlogs stores in the future, without reinventing any changegroup specific logic. Differential Revision: https://phab.mercurial-scm.org/D688
author Durham Goode <durham@fb.com>
date Wed, 13 Sep 2017 10:43:44 -0700
parents 6788e648efcf
children 1db9abf407c5
line wrap: on
line diff
--- a/tests/test-revlog-raw.py	Wed Sep 13 10:43:16 2017 -0700
+++ b/tests/test-revlog-raw.py	Wed Sep 13 10:43:44 2017 -0700
@@ -119,11 +119,28 @@
                     'deltabase': rlog.node(deltaparent),
                     'delta': rlog.revdiff(deltaparent, r)}
 
+        def deltaiter(self, linkmapper):
+            chain = None
+            for chunkdata in iter(lambda: self.deltachunk(chain), {}):
+                node = chunkdata['node']
+                p1 = chunkdata['p1']
+                p2 = chunkdata['p2']
+                cs = chunkdata['cs']
+                deltabase = chunkdata['deltabase']
+                delta = chunkdata['delta']
+                flags = chunkdata['flags']
+
+                link = linkmapper(cs)
+                chain = node
+
+                yield (node, p1, p2, link, deltabase, delta, flags)
+
     def linkmap(lnode):
         return rlog.rev(lnode)
 
     dlog = newrevlog(destname, recreate=True)
-    dlog.addgroup(dummychangegroup(), linkmap, tr)
+    dummydeltas = dummychangegroup().deltaiter(linkmap)
+    dlog.addgroup(dummydeltas, tr)
     return dlog
 
 def lowlevelcopy(rlog, tr, destname=b'_destrevlog.i'):