changeset 35841:369aadf7a326 stable 4.5.1

revlog: resolve lfs rawtext to vanilla rawtext before applying delta 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. Differential Revision: https://phab.mercurial-scm.org/D2069
author Jun Wu <quark@fb.com>
date Tue, 13 Feb 2018 11:35:32 -0800
parents 33275ab5e837
children 9648b954e394
files mercurial/revlog.py tests/test-lfs-bundle.t
diffstat 2 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Tue Feb 13 11:35:32 2018 -0800
+++ b/mercurial/revlog.py	Tue Feb 13 11:35:32 2018 -0800
@@ -336,7 +336,9 @@
                                                    len(delta) - hlen):
             btext[0] = delta[hlen:]
         else:
-            basetext = revlog.revision(baserev, _df=fh, raw=True)
+            # deltabase is rawtext before changed by flag processors, which is
+            # equivalent to non-raw text
+            basetext = revlog.revision(baserev, _df=fh, raw=False)
             btext[0] = mdiff.patch(basetext, delta)
 
         try:
@@ -2084,7 +2086,10 @@
         # 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]),
+            # need rawtext size, before changed by flag processors, which is
+            # the non-raw size. use revlog explicitly to avoid filelog's extra
+            # logic that might remove metadata size.
+            textlen = mdiff.patchedsize(revlog.size(self, cachedelta[0]),
                                         cachedelta[1])
         else:
             textlen = len(rawtext)
--- a/tests/test-lfs-bundle.t	Tue Feb 13 11:35:32 2018 -0800
+++ b/tests/test-lfs-bundle.t	Tue Feb 13 11:35:32 2018 -0800
@@ -90,7 +90,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 ----