[Commented On] D11270: issue6528: also filter delta on the fly when applying a changegroup
baymax (Baymax, Your Personal Patch-care Companion)
phabricator at mercurial-scm.org
Sun Aug 8 22:59:24 UTC 2021
baymax added a comment.
baymax updated this revision to Diff 29863.
✅ refresh by Heptapod after a successful CI run (🐙 💚)
⚠ This patch is intended for stable ⚠
<img src="https://phab.mercurial-scm.org/file/data/h5qzsk5iahjdvnl7gmhi/PHID-FILE-x6sscoeidpiv2cehz52q/source.gif" />
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D11270?vs=29861&id=29863
BRANCH
stable
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D11270/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D11270
AFFECTED FILES
mercurial/filelog.py
mercurial/revlogutils/rewrite.py
tests/bundles/issue6528.hg-v1
tests/bundles/issue6528.hg-v2
tests/test-issue6528.t
CHANGE DETAILS
diff --git a/tests/test-issue6528.t b/tests/test-issue6528.t
--- a/tests/test-issue6528.t
+++ b/tests/test-issue6528.t
@@ -431,3 +431,96 @@
$ hg debug-repair-issue6528
no affected revisions were found
$ hg st
+
+ $ cd ..
+
+Applying a bad bundle should fix it on the fly
+----------------------------------------------
+
+from a v1 bundle
+~~~~~~~~~~~~~~~~
+
+ $ hg debugbundle --spec "$TESTDIR"/bundles/issue6528.hg-v1
+ bzip2-v1
+
+ $ hg init unbundle-v1
+ $ cd unbundle-v1
+
+ $ hg unbundle "$TESTDIR"/bundles/issue6528.hg-v1
+ adding changesets
+ adding manifests
+ adding file changes
+ added 8 changesets with 12 changes to 4 files
+ new changesets f5a5a568022f:3beabb508514 (8 drafts)
+ (run 'hg update' to get a working copy)
+
+Check that revision were fixed on the fly
+
+ $ hg debugrevlogindex b.txt
+ rev linkrev nodeid p1 p2
+ 0 2 05b806ebe5ea 000000000000 000000000000
+ 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
+ 2 6 216a5fe8b8ed 000000000000 000000000000
+ 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
+
+ $ hg debugrevlogindex D.txt
+ rev linkrev nodeid p1 p2
+ 0 6 2a8d3833f2fb 000000000000 000000000000
+ 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
+
+That we don't see the symptoms of the bug
+
+ $ hg up -- -1
+ 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ hg status
+
+And that the repair command does not find anything to fix
+
+ $ hg debug-repair-issue6528
+ no affected revisions were found
+
+ $ cd ..
+
+from a v2 bundle
+~~~~~~~~~~~~~~~~
+
+ $ hg debugbundle --spec "$TESTDIR"/bundles/issue6528.hg-v2
+ bzip2-v2
+
+ $ hg init unbundle-v2
+ $ cd unbundle-v2
+
+ $ hg unbundle "$TESTDIR"/bundles/issue6528.hg-v2
+ adding changesets
+ adding manifests
+ adding file changes
+ added 8 changesets with 12 changes to 4 files
+ new changesets f5a5a568022f:3beabb508514 (8 drafts)
+ (run 'hg update' to get a working copy)
+
+Check that revision were fixed on the fly
+
+ $ hg debugrevlogindex b.txt
+ rev linkrev nodeid p1 p2
+ 0 2 05b806ebe5ea 000000000000 000000000000
+ 1 3 a58b36ad6b65 000000000000 05b806ebe5ea
+ 2 6 216a5fe8b8ed 000000000000 000000000000
+ 3 7 ea4f2f2463cc 000000000000 216a5fe8b8ed
+
+ $ hg debugrevlogindex D.txt
+ rev linkrev nodeid p1 p2
+ 0 6 2a8d3833f2fb 000000000000 000000000000
+ 1 7 2a80419dfc31 000000000000 2a8d3833f2fb
+
+That we don't see the symptoms of the bug
+
+ $ hg up -- -1
+ 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ hg status
+
+And that the repair command does not find anything to fix
+
+ $ hg debug-repair-issue6528
+ no affected revisions were found
+
+ $ cd ..
diff --git a/tests/bundles/issue6528.hg-v2 b/tests/bundles/issue6528.hg-v2
new file mode 100644
index 0000000000000000000000000000000000000000..7c9c362ea561838727c608886d728bd3b311c21f
GIT binary patch
literal 2406
zc$@)d37Pgt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ue6528.hg-v1 b/tests/bundles/issue6528.hg-v1
new file mode 100644
index 0000000000000000000000000000000000000000..fcc34db8300a7a93729057f6440ca2a760cfabeb
GIT binary patch
literal 2223
zc$@*R2vGM(M=>x$T4*^jL0KkKSwm`a9RL7ofB*mg|NsC0|NsB~^QHg)|M})l`+xuc
z|NH0vumA7=|9{{IdGM^MfCFV}QCk%x0E($hBz~y!ntGqAG(4uBru9sRsCt<*QR;hA
zdTM%r^#+YSKzfZmM$%;RnWX(Gpv+0-JxA(+>R~skVGk%ar=-(Os2-rtQaq-cNwkkm
z6Vg3R7)_-8D1ZO}13)wY00E;wXahh10gyBR8W=z{(Vzg(000dD&;S4ifuPU;2~Z{i
z69`oCK+pgH007VdpaVbyKmZy513&-(000000000000;m805k(Y000^^27ojG02u>7
z0ilEgO&S0V0002c4FCWDXc`Rw0ssI24FJ#p00xZ#pbY>320+jNXkh@;Mt}oA001-t
zKmY(527^EVB#})t8kwn)Cygnmp*=EBQ`9{}Pf3D$hMQ9$4H|lCdY)4?G}9meZ6i%G
z0C_+F4Wu;nJxw$K8Us&A(?dWS1Jw0BKy7}M!9NzY{cF7In#MC-DA~4Dsu160_Q5G+
zm((Xs;V4 at CIvuU=)_3e%TG&N!jo^f3vD_zcF&k4*i?aF+Sj;T|;qy3_2D}`aRo%LZ
znP`Gr$jJzel|V4!xOYKtQB!p414ea2u325MJy|)-46GX<007Jk3=EkhuY|zl!!i<(
zsFU)(aB3F-UL{a0R7 at 7xFa(q^xRY)<8|pDf75H)osS9L!M)-*dZFw_xl>q+ at H(Xem
z%`Teve}%HhVq9`O0nKQP(&=EuX55vfBg%?`0U)R<9LHv<i%S`*N{3{P>Zs5T%$8=%
zGl at zdMygtJSu>j)j6s7uwhoCl0fL-!Se!x0C4pi$rqzmLw1zwA9myDahd!N at z1g#E
zi}c^7=#cy8B^=L`$-yn|Cj4N;bcGnvbV*a2YiBd8q&d#a5DftLvDu7#P!E#KFzrJf
zDmO=M<YD+LyeBH41i#^oXQL(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A*9UQ8wjYW9^A(WlaNI_L(3uLa(}z
zo>5p-7n&J1z7d_4H;WORB6{N at B^sIRnW)>2;7gLClFHJYX(-0Z13Dd at 1^7ilPoh>C
ze`?#*rD3Ft%W_RXw4t>E;|STrqEvKfMG#+vVN~?B*T#@p7^zHRu%B5(lLJ%7h|iUd
z0f~6y7>|@8B;#o?l3c0+Bhv*q77ilV5`^%3Cggdb!P*6o&nG{EF;gHEq#>Ov%W}w&
zT^1h-D at B7nVj{RQrevIOW5MHO!USQE1wb(fsfzJ1iD3V5F^M8AXKuw3rU``NX`xC$
zXUQYCDGP>VtHxU80iB)`L)}6Tj)wCA8kxyT`h~0tNI{RA3*E-Wlprr4`-X^n4{0x|
zhAD<!lF8be)uF at q3%RACQ>SZY+M_<NMD}gSzOpmZF&30rAkFb-nq!`_UBUXNAZ{=r
zhD~z at Dc^sFos6BD>Jrjxdj|Vxl3Com3?c-X at vMY1CUW2`4UylCcSb<DrP8%c4+%8G
z+zw3OLMH+(&1{mEDf=y<oj4IdUZJL&18j1^^n at L$PiSFw8$)N<g;B^JsI`P!*&yB@
z!H%%eW^7RsW5k#m^jnrGYs;i$OY<p~$YMmGOVU7S(|0&onW4HJ#8X!DW+4cKO;h}-
z!y7&^NKp*Qw at TN*7zcJ`hwM3ac+EO}l_8JUEum7CYfr at +Bk3Wec@%fq;z8tb2MjhO
zYV at N|D8)JiwIVLBC}Vg@>W%<tQefi~;SO5xoi#Iaf0 at 9qFWR#3wkOkA6cwdm`d|;d
zaZNFz9zWEXv$j3dsU{E9f8f!ZP_AtW78MK5pOE4X0Wz1Er;a(4*BP at a#E%&yhUn6-
xJnF3XnifqVVq}=)N6;7-Z9$BtmoZAEm>{L8)1}EDI#Yk*?ntK!5(sThL!c?%+ARP8
literal 0
Hc$@<O00001
diff --git a/mercurial/revlogutils/rewrite.py b/mercurial/revlogutils/rewrite.py
--- a/mercurial/revlogutils/rewrite.py
+++ b/mercurial/revlogutils/rewrite.py
@@ -29,6 +29,7 @@
ENTRY_SIDEDATA_COMPRESSED_LENGTH,
ENTRY_SIDEDATA_COMPRESSION_MODE,
ENTRY_SIDEDATA_OFFSET,
+ REVIDX_ISCENSORED,
REVLOGV0,
REVLOGV1,
)
@@ -36,6 +37,7 @@
from .. import (
error,
+ mdiff,
pycompat,
revlogutils,
util,
@@ -719,6 +721,88 @@
_reorder_filelog_parents(repo, fl, sorted(to_fix))
+def filter_delta_issue6528(revlog, deltas_iter):
+ """filter incomind deltas to repaire issue 6528 on the fly"""
+ metadata_cache = {}
+
+ deltacomputer = deltas.deltacomputer(revlog)
+
+ for rev, d in enumerate(deltas_iter, len(revlog)):
+ (
+ node,
+ p1_node,
+ p2_node,
+ linknode,
+ deltabase,
+ delta,
+ flags,
+ sidedata,
+ ) = d
+
+ if not revlog.index.has_node(deltabase):
+ raise error.LookupError(
+ deltabase, revlog.radix, _(b'unknown parent')
+ )
+ base_rev = revlog.rev(deltabase)
+ if not revlog.index.has_node(p1_node):
+ raise error.LookupError(p1_node, revlog.radix, _(b'unknown parent'))
+ p1_rev = revlog.rev(p1_node)
+ if not revlog.index.has_node(p2_node):
+ raise error.LookupError(p2_node, revlog.radix, _(b'unknown parent'))
+ p2_rev = revlog.rev(p2_node)
+
+ is_censored = lambda: bool(flags & REVIDX_ISCENSORED)
+ delta_base = lambda: revlog.rev(delta_base)
+ delta_base = lambda: base_rev
+ parent_revs = lambda: (p1_rev, p2_rev)
+
+ def full_text():
+ # note: being able to reuse the full text computation in the
+ # underlying addrevision would be useful however this is a bit too
+ # intrusive the for the "quick" issue6528 we are writing before the
+ # 5.8 release
+ textlen = mdiff.patchedsize(revlog.size(base_rev), delta)
+
+ revinfo = revlogutils.revisioninfo(
+ node,
+ p1_node,
+ p2_node,
+ [None],
+ textlen,
+ (base_rev, delta),
+ flags,
+ )
+ # cached by the global "writing" context
+ assert revlog._writinghandles is not None
+ if revlog._inline:
+ fh = revlog._writinghandles[0]
+ else:
+ fh = revlog._writinghandles[1]
+ return deltacomputer.buildtext(revinfo, fh)
+
+ is_affected = _is_revision_affected_fast_inner(
+ is_censored,
+ delta_base,
+ lambda: delta,
+ full_text,
+ parent_revs,
+ rev,
+ metadata_cache,
+ )
+ if is_affected:
+ d = (
+ node,
+ p2_node,
+ p1_node,
+ linknode,
+ deltabase,
+ delta,
+ flags,
+ sidedata,
+ )
+ yield d
+
+
def repair_issue6528(
ui, repo, dry_run=False, to_report=None, from_report=None, paranoid=False
):
diff --git a/mercurial/filelog.py b/mercurial/filelog.py
--- a/mercurial/filelog.py
+++ b/mercurial/filelog.py
@@ -20,6 +20,7 @@
from .utils import storageutil
from .revlogutils import (
constants as revlog_constants,
+ rewrite,
)
@@ -158,6 +159,9 @@
)
with self._revlog._writing(transaction):
+
+ deltas = rewrite.filter_delta_issue6528(self._revlog, deltas)
+
return self._revlog.addgroup(
deltas,
linkmapper,
To: marmoute, #hg-reviewers
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210808/414471af/attachment-0002.html>
More information about the Mercurial-patches
mailing list