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
--- 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 ----