changeset 44803:affe0fb42250 stable

nodemap: fix validity checking when revlog is too short We cannot check the nodeid of a revision that is not even there. We add a simple fix and simple test.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 13 Jun 2020 11:57:58 +0200
parents 6c8384afbf77
children b77d5b568496
files mercurial/revlog.py tests/test-persistent-nodemap.t
diffstat 2 files changed, 26 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Tue Jun 09 05:24:45 2020 +0200
+++ b/mercurial/revlog.py	Sat Jun 13 11:57:58 2020 +0200
@@ -651,7 +651,10 @@
                 nodemap_data = nodemaputil.persisted_data(self)
                 if nodemap_data is not None:
                     docket = nodemap_data[0]
-                    if d[0][docket.tip_rev][7] == docket.tip_node:
+                    if (
+                        len(d[0]) > docket.tip_rev
+                        and d[0][docket.tip_rev][7] == docket.tip_node
+                    ):
                         # no changelog tampering
                         self._nodemap_docket = docket
                         index.update_nodemap_data(*nodemap_data)
--- a/tests/test-persistent-nodemap.t	Tue Jun 09 05:24:45 2020 +0200
+++ b/tests/test-persistent-nodemap.t	Sat Jun 13 11:57:58 2020 +0200
@@ -411,3 +411,25 @@
   .hg/store/00changelog-????????????????.nd: size=123584, sha256=8c6cef6fd3d3fac291968793ee19a4be6d0b8375e9508bd5c7d4a8879e8df180 (glob) (pure !)
   .hg/store/00changelog-????????????????.nd: size=123584, sha256=eb9e9a4bcafdb5e1344bc8a0cbb3288b2106413b8efae6265fb8a7973d7e97f9 (glob) (rust !)
   .hg/store/00changelog-????????????????.nd: size=123136, sha256=4f504f5a834db3811ced50ab3e9e80bcae3581bb0f9b13a7a9f94b7fc34bcebe (glob) (no-pure no-rust !)
+
+Check that removing content does not confuse the nodemap
+--------------------------------------------------------
+
+removing data with rollback
+
+  $ echo aso > a
+  $ hg ci -m a4
+  $ hg rollback
+  repository tip rolled back to revision 5005 (undo commit)
+  working directory now based on revision 5005
+  $ hg id -r .
+  bae4d45c759e tip
+
+roming data with strip
+
+  $ echo aso > a
+  $ hg ci -m a4
+  $ hg --config extensions.strip= strip -r . --no-backup
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg id -r . --traceback
+  bae4d45c759e tip