[PATCH 5 of 5] manifestv2: implement slow readdelta() without revdiff

Martin von Zweigbergk martinvonz at google.com
Mon Mar 30 19:19:42 CDT 2015


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1427514090 25200
#      Fri Mar 27 20:41:30 2015 -0700
# Node ID 165a99e70157e581ef3328efcc3f5a195d388894
# Parent  816d01895c212b8d313d748f9b8c530b7f92c249
manifestv2: implement slow readdelta() without revdiff

For manifest v2, revlog.revdiff() usually does not provide enough
information to produce a manifest. As a simple workaround, implement
readdelta() by reading both the old and the new manifest and use
manifest.diff() to find the difference. This is several times slower
than the current readdelta() for v1 manifests, but there seems to be
no other simple option, and this is still much faster than returning
the full manifest (at least for verify).

diff -r 816d01895c21 -r 165a99e70157 mercurial/manifest.py
--- a/mercurial/manifest.py	Fri Mar 27 17:07:24 2015 -0700
+++ b/mercurial/manifest.py	Fri Mar 27 20:41:30 2015 -0700
@@ -613,7 +613,21 @@
             return treemanifest('', data)
         return manifestdict(data)
 
+    def _slowreaddelta(self, node):
+        r0 = self.deltaparent(self.rev(node))
+        m0 = self.read(self.node(r0))
+        m1 = self.read(node)
+        md = self._newmanifest()
+        for f, ((n0, fl0), (n1, fl1)) in m0.diff(m1).iteritems():
+            if n1:
+                md[f] = n1
+                if fl1:
+                    md.setflag(f, fl1)
+        return md
+
     def readdelta(self, node):
+        if self._usemanifestv2:
+            return self._slowreaddelta(node)
         r = self.rev(node)
         d = mdiff.patchtext(self.revdiff(self.deltaparent(r), r))
         return self._newmanifest(d)


More information about the Mercurial-devel mailing list