tests: demonstrate crash caused by pinning of non-existent mergestate node stable
authorMartin von Zweigbergk <martinvonz@google.com>
Wed, 23 Sep 2020 16:07:14 -0700
branchstable
changeset 45522 5a555d6e0d90
parent 45509 2bc978921e8a
child 45523 5ed6efedc457
tests: demonstrate crash caused by pinning of non-existent mergestate node If the mergestate somehow contains a reference to a non-existent node, it causes most commands to crash since aaeccdb6e654 (repoview: pin revisions for `local` and `other` when a merge is active, 2020-09-04). This patch adds a test showing that. Differential Revision: https://phab.mercurial-scm.org/D9077
tests/test-obsolete.t
--- a/tests/test-obsolete.t	Fri Sep 18 12:20:28 2020 +0200
+++ b/tests/test-obsolete.t	Wed Sep 23 16:07:14 2020 -0700
@@ -1790,3 +1790,44 @@
   d1b09fe3ad2b2a03e23a72f0c582e29a49570145 1a1a11184d2588af24e767e5335d5d9d07e8c550 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'note': 'Testing::Obsstore', 'operation': 'amend', 'user': 'test'}
   1bfd8e3868f641e048b6667cd672c68932f26d00 79959ca316d5b27ac6be1dd0cfd0843a5b5412eb 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'note': 'Testing::Obsstore2', 'operation': 'amend', 'user': 'test'}
   $ cd ..
+
+Test that pinning of revisions in broken mergestate doesn't cause crash
+
+  $ hg init pinning-broken-mergestate
+  $ cd pinning-broken-mergestate
+  $ echo a > file
+  $ hg ci -Aqm first
+Create a pruned commit so pinning comes into play
+  $ echo pruned > pruned
+  $ hg ci -Aqm pruned
+  $ hg co -q 0
+  $ hg debugobsolete $(getid pruned)
+  1 new obsolescence markers
+  obsoleted 1 changesets
+Back up changelog, so we can restore it later after causing merge conflicts
+with it, thus ending up with mergestate that points to a non-existent commit
+  $ cp .hg/store/00changelog.i .hg/store/00changelog.i.first
+  $ echo b > file
+  $ hg ci -qm second
+  $ echo c > file
+  $ hg co -m 0
+  merging file
+  warning: conflicts while merging file! (edit, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges
+  [1]
+  $ mv -f .hg/store/00changelog.i.first .hg/store/00changelog.i
+The local node should now point to a non-existent commit
+  $ hg debugmergestate
+  local (working copy): b73b8c9a4ab4da89a5a35a6f10dfb13edc84ca37
+  other (destination): f53e9479dce52f79c923908241fa54f7da90a7ad
+  file: file (state "u")
+    local path: file (hash 971c419dd609331343dee105fffd0f4608dc0bf2, flags "")
+    ancestor path: file (node bc7ebe2d260cff30d2a39a130d84add36216f791)
+    other path: file (node b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3)
+    extra: ancestorlinknode = b73b8c9a4ab4da89a5a35a6f10dfb13edc84ca37
+BROKEN: We should be able to see the log (without the deleted commit, of course)
+  $ hg log -G
+  abort: unknown revision 'b73b8c9a4ab4da89a5a35a6f10dfb13edc84ca37'!
+  [255]
+  $ cd ..