[Request] [+- ] D10724: revlog: fix index computation during inline->non-inline transition
joerg.sonnenberger (Joerg Sonnenberger)
phabricator at mercurial-scm.org
Tue May 18 00:42:07 UTC 2021
joerg.sonnenberger created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
The computation 63edc384d3b7 <https://phab.mercurial-scm.org/rHG63edc384d3b7f497fba4c1797bab86eede583dca> failed to factor in the index entries
themselve as revlog.start() doesn't count them. Fonud by Valtenin
Gatienbaron with a precise test case from me.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D10724
AFFECTED FILES
mercurial/revlog.py
tests/helper-killhook.py
tests/test-transaction-rollback-on-revlog-split.t
CHANGE DETAILS
diff --git a/tests/test-transaction-rollback-on-revlog-split.t b/tests/test-transaction-rollback-on-revlog-split.t
new file mode 100644
--- /dev/null
+++ b/tests/test-transaction-rollback-on-revlog-split.t
@@ -0,0 +1,29 @@
+Test correctness of revlog inline -> non-inline transition
+----------------------------------------------------------
+
+Test offset computation to correctly factor in the index entries themselve.
+Test repo has one small, one moderate and one big change. The clone has
+the small and moderate change and will transition to non-inline storage when
+adding the big change.
+
+ $ hg init troffset-computation --config format.revlog-compression=none
+ $ cd troffset-computation
+ $ printf '% 20d' '1' > file
+ $ hg commit -Aqm_
+ $ printf '% 1024d' '1' > file
+ $ hg commit -Aqm_
+ $ dd if=/dev/zero of=file bs=1k count=128 > /dev/null 2>&1
+ $ hg commit -Aqm_
+ $ cd ..
+
+ $ hg clone -r 1 troffset-computation troffset-computation-copy --config format.revlog-compression=none -q
+ $ cd troffset-computation-copy
+ $ cat > .hg/hgrc <<EOF
+ > [hooks]
+ > pretxnchangegroup = python:$TESTDIR/helper-killhook.py:killme
+ > EOF
+ $ hg pull ../troffset-computation
+ pulling from ../troffset-computation
+ [80]
+ $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file | tail -1
+ data/file.i 128
diff --git a/tests/helper-killhook.py b/tests/helper-killhook.py
new file mode 100644
--- /dev/null
+++ b/tests/helper-killhook.py
@@ -0,0 +1,4 @@
+import os
+
+def killme(ui, repo, hooktype, **wkargs):
+ os._exit(80)
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1985,7 +1985,7 @@
with self._indexfp(b'r') as ifh, self._datafp(b'w') as dfh:
for r in self:
dfh.write(self._getsegmentforrevs(r, r, df=ifh)[1])
- if troffset <= self.start(r):
+ if troffset <= self.start(r) + r * self.index.entry_size:
trindex = r
with self._indexfp(b'w') as fp:
To: joerg.sonnenberger, indygreg, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20210518/8f0720e8/attachment-0001.html>
More information about the Mercurial-patches
mailing list