evolve: handle relocation during divergence resolution producing no changes
When resolving divergence and the two divergent commits have different
parents, we start by rebasing one of them to have the same parent as
the other. That step can result in no changes to commit. When it does,
we would crash with a TypeError before this patch.
This patch fixes it by instead creating an empty commit in that
scenario. The existing code then continues to attempt to merge it,
which produces no changes, and no commit is created on top. The other
side of the divergence is marked as successor as usual, so orphans
from the side that became empty will be evolved to the right place
(see test).
--- a/hgext3rd/evolve/evolvecmd.py Mon Dec 09 10:05:24 2019 -0800
+++ b/hgext3rd/evolve/evolvecmd.py Mon Dec 09 11:09:11 2019 -0800
@@ -446,7 +446,10 @@
def _relocatedivergent(repo, orig, dest, evolvestate):
"""relocates a divergent commit and saves the evolve state"""
- with state.saver(evolvestate, {b'current': orig.node()}):
+ configoverride = repo.ui.configoverride(
+ {(b'ui', b'allowemptycommit'): b'true'}, b'evolve'
+ )
+ with state.saver(evolvestate, {b'current': orig.node()}), configoverride:
return _relocate(repo, orig, dest, evolvestate, keepbranch=True)
def _solvedivergent(ui, repo, divergent, evolvestate, displayer, dryrun=False,
--- a/tests/test-evolve-content-divergent-relocation.t Mon Dec 09 10:05:24 2019 -0800
+++ b/tests/test-evolve-content-divergent-relocation.t Mon Dec 09 11:09:11 2019 -0800
@@ -652,7 +652,58 @@
|/ () [default] draft
o 0:98a3f8f02ba7 initial
() [default] draft
- $ hg evolve --content-divergent 2>&1 | grep TypeError
- TypeError: expected *, NoneType found (glob)
+ $ hg evolve --content-divergent
+ merge:[3] divergent
+ with: [4] divergent
+ base: [2] divergent
+ rebasing "other" content-divergent changeset 4cc21313ecee on 33c576d20069
+ 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+ 1 new orphan changesets
+ $ hg glog
+ o 7:dfabf49594ff divergent
+ | () [default] draft
+ | * 5:88473f9137d1 child
+ | | () [default] draft
+ | x 4:4cc21313ecee divergent
+ | | () [default] draft
+ o | 1:33c576d20069 upstream
+ |/ () [default] draft
+ o 0:98a3f8f02ba7 initial
+ () [default] draft
+ $ hg evolve --any
+ move:[5] child
+ atop:[7] divergent
+ $ hg glog
+ o 8:6da8b7911364 child
+ | () [default] draft
+ o 7:dfabf49594ff divergent
+ | () [default] draft
+ o 1:33c576d20069 upstream
+ | () [default] draft
+ o 0:98a3f8f02ba7 initial
+ () [default] draft
+ $ hg debugobsolete
+ 898ddd4443b3d5520bf48f22f9411d5a0751cf2e befae61385695f1ae4b78b030ad91075b2b523ef 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'rebase', 'user': 'test'}
+ 898ddd4443b3d5520bf48f22f9411d5a0751cf2e 4cc21313ecee97ce33265514a0596a192bfa6b3f 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
+ 4cc21313ecee97ce33265514a0596a192bfa6b3f bf4fe3a3afeb14c338094f41a35863921856592f 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '12', 'operation': 'evolve', 'user': 'test'}
+ befae61385695f1ae4b78b030ad91075b2b523ef dfabf49594ff9aa09d71ca6cc8e574e84bf0e651 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '10', 'operation': 'evolve', 'user': 'test'}
+ bf4fe3a3afeb14c338094f41a35863921856592f dfabf49594ff9aa09d71ca6cc8e574e84bf0e651 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '2', 'operation': 'evolve', 'user': 'test'}
+ 88473f9137d12e90055d30bbb9b78dd786520870 6da8b7911364bc7f4cde60ba07e57213c6dfb14e 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'evolve', 'user': 'test'}
+ $ hg obslog -r 'desc("divergent")' --all
+ o dfabf49594ff (7) divergent
+ |\
+ x | befae6138569 (3) divergent
+ | | rewritten(meta, content) as dfabf49594ff using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+ | |
+ | x bf4fe3a3afeb (6) divergent
+ | | meta-changed(meta) as dfabf49594ff using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+ | |
+ | x 4cc21313ecee (4) divergent
+ |/ rewritten(parent, content) as bf4fe3a3afeb using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+ |
+ x 898ddd4443b3 (2) divergent
+ amended(content) as 4cc21313ecee using amend by test (Thu Jan 01 00:00:00 1970 +0000)
+ rebased(parent) as befae6138569 using rebase by test (Thu Jan 01 00:00:00 1970 +0000)
+
$ cd ..