evolve: fix content-divergence resolution when p1 is null (issue6201) stable
authorManuel Jacob <me@manueljacob.de>
Fri, 06 Dec 2019 14:01:29 +0100
branchstable
changeset 4984 b779b40f996e
parent 4981 60be1bd580c7
child 4988 588b3484c131
evolve: fix content-divergence resolution when p1 is null (issue6201) Before this fix, in cases like in the added test, the revision number -1 of the parent was misinterpreted to mean the tipmost revision instead of the null revision, causing the content-divergence resolution to fail.
hgext3rd/evolve/evolvecmd.py
tests/test-evolve-content-divergent-first-changeset.t
--- a/hgext3rd/evolve/evolvecmd.py	Tue Dec 03 09:43:10 2019 -0800
+++ b/hgext3rd/evolve/evolvecmd.py	Fri Dec 06 14:01:29 2019 +0100
@@ -391,7 +391,15 @@
     # the changeset on which resolution changeset will be based on
     resolutionparent = repo[divp1].node()
 
-    gca = repo.revs(b"ancestor(%d, %d)" % (otherp1, divp1))
+    # the nullrev has to be handled specially because -1 is overloaded to both
+    # mean nullrev (this meaning is used for the result of changectx.rev(), as
+    # called above) and the tipmost revision (this meaning is used for the %d
+    # format specifier, as used below)
+    if nodemod.nullrev in (otherp1, divp1):
+        # nullrev is the only possible ancestor if otherp1 or divp1 is nullrev
+        gca = [nodemod.nullrev]
+    else:
+        gca = repo.revs(b"ancestor(%d, %d)" % (otherp1, divp1))
     # divonly: non-obsolete csets which are topological ancestor of "divergent"
     # but not "other"
     divonly = repo.revs(b"only(%d, %d) - obsolete()" % (divergent.rev(),
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-evolve-content-divergent-first-changeset.t	Fri Dec 06 14:01:29 2019 +0100
@@ -0,0 +1,41 @@
+  $ . $TESTDIR/testlib/pythonpath.sh
+  $ echo "[extensions]" >> $HGRCPATH
+  $ echo "evolve=" >> $HGRCPATH
+
+This test file tests the case of content-divergence resolution of changesets
+that have the null revision as the parent.
+
+  $ hg init issue6201
+  $ cd issue6201
+
+  $ touch test
+  $ hg add test
+  $ hg commit -m test
+  $ hg log -T '{node|short}\n'
+  be090ea66256
+
+  $ echo a >> test
+  $ hg amend -m div1
+  $ hg log -T '{node|short}\n'
+  79fa0eb22d65
+
+  $ hg up be090ea66256 --hidden --quiet
+  updated to hidden changeset be090ea66256
+  (hidden revision 'be090ea66256' was rewritten as: 79fa0eb22d65)
+  working directory parent is obsolete! (be090ea66256)
+  $ echo a >> test
+  $ echo b >> test
+  $ hg amend -m div2
+  2 new content-divergent changesets
+  $ hg log -T '{node|short}\n'
+  4b2524b7508e
+  79fa0eb22d65
+
+  $ hg evolve --content-divergent --config ui.merge=internal:other
+  merge:[1] div1
+  with: [2] div2
+  base: [0] test
+  0 files updated, 1 files merged, 0 files removed, 0 files unresolved
+  working directory is now at 12772224141b
+
+  $ hg evolve --list