Patchwork [6,of,9,V2] revlog: use raw revisions in revdiff

login
register
mail settings
Submitter Jun Wu
Date March 31, 2017, 4:45 a.m.
Message ID <272495735d544f8ab605.1490935515@x1c>
Download mbox | patch
Permalink /patch/19858/
State Accepted
Headers show

Comments

Jun Wu - March 31, 2017, 4:45 a.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1490923407 25200
#      Thu Mar 30 18:23:27 2017 -0700
# Node ID 272495735d544f8ab6053752db4e0a648f07415d
# Parent  290c65aad38108cc59c7e8fb7f3b37a7c7a7573b
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 272495735d54
revlog: use raw revisions in revdiff

See the added comment. revdiff is meant to output the raw delta that will be
written to revlog. It should use raw.

test-revlog-raw.py now shows "addgroupcopy test passed", but there is more
to fix.

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1240,10 +1240,14 @@  class revlog(object):
 
     def revdiff(self, rev1, rev2):
-        """return or calculate a delta between two revisions"""
+        """return or calculate a delta between two revisions
+
+        The delta calculated is in binary form and is intended to be written to
+        revlog data directly. So this function needs raw revision data.
+        """
         if rev1 != nullrev and self.deltaparent(rev2) == rev1:
             return bytes(self._chunk(rev2))
 
-        return mdiff.textdiff(self.revision(rev1),
-                              self.revision(rev2))
+        return mdiff.textdiff(self.revision(rev1, raw=True),
+                              self.revision(rev2, raw=True))
 
     def revision(self, nodeorrev, _df=None, raw=False):
diff --git a/tests/test-revlog-raw.py.out b/tests/test-revlog-raw.py.out
--- a/tests/test-revlog-raw.py.out
+++ b/tests/test-revlog-raw.py.out
@@ -1,2 +1,3 @@ 
 local test passed
+addgroupcopy test passed
 abort: crashed: invalid patch