D2069: revlog: resolve lfs rawtext to vanilla rawtext before applying delta

quark (Jun Wu) phabricator at mercurial-scm.org
Tue Feb 6 20:14:44 EST 2018


quark created this revision.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This happens when a LFS delta base gets a non-LFS delta from another client.
  In that case, the LFS delta base needs to be converted to non-LFS version
  before applying the delta.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2069

AFFECTED FILES
  mercurial/revlog.py
  tests/test-lfs-bundle.t

CHANGE DETAILS

diff --git a/tests/test-lfs-bundle.t b/tests/test-lfs-bundle.t
--- a/tests/test-lfs-bundle.t
+++ b/tests/test-lfs-bundle.t
@@ -91,7 +91,7 @@
   ---- Applying src-normal.bundle to dst-normal ----
   OK
   ---- Applying src-normal.bundle to dst-lfs ----
-  CRASHED
+  OK
   ---- Applying src-lfs.bundle to dst-normal ----
   OK
   ---- Applying src-lfs.bundle to dst-lfs ----
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -333,7 +333,9 @@
                                                    len(delta) - hlen):
             btext[0] = delta[hlen:]
         else:
-            basetext = revlog.revision(baserev, _df=fh, raw=True)
+            # Deltas are against "flags=0 rawtext".Need "flags=0" rawtext
+            # here, which is equivalent to non-raw text.
+            basetext = revlog.revision(baserev, _df=fh, raw=False)
             btext[0] = mdiff.patch(basetext, delta)
 
         try:
@@ -2076,8 +2078,8 @@
         # full versions are inserted when the needed deltas
         # become comparable to the uncompressed text
         if rawtext is None:
-            textlen = mdiff.patchedsize(self.rawsize(cachedelta[0]),
-                                        cachedelta[1])
+            # need flags=0 rawtext size, which is the non-raw size
+            textlen = mdiff.patchedsize(self.size(cachedelta[0]), cachedelta[1])
         else:
             textlen = len(rawtext)
 



To: quark, indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list