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

login
register
mail settings
Submitter phabricator
Date Feb. 7, 2018, 1:14 a.m.
Message ID <differential-rev-PHID-DREV-445ldwuflqb2cxujb2oz-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/27393/
State New
Headers show

Comments

phabricator - Feb. 7, 2018, 1:14 a.m.
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




To: quark, indygreg, #hg-reviewers
Cc: mercurial-devel
phabricator - Feb. 7, 2018, 10:36 p.m.
indygreg requested changes to this revision.
indygreg added a comment.
This revision now requires changes to proceed.


  I'd like to see the next versions of hte previous 2 patches before looking at this because this patch will likely get some minor rework as well.

REPOSITORY
  rHG Mercurial

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

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

Patch

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)