evolve: add logic to cover --continue case when relocating "divergent"
Changes in test file demonstrate the added behaviour.
--- a/hgext3rd/evolve/evolvecmd.py Mon Nov 25 21:28:52 2019 +0530
+++ b/hgext3rd/evolve/evolvecmd.py Wed Nov 27 12:34:19 2019 +0530
@@ -320,6 +320,9 @@
# below.
evolvestate[b'relocated-other'] = None
evolvestate[b'relocating-other'] = False
+ evolvestate[b'relocated-div'] = None
+ evolvestate[b'relocating-div'] = False
+ evolvestate[b'relocation-req'] = False
# in case or relocation we get a new other node, we need to store the old
# other for purposes like `--abort` or `--stop`
evolvestate[b'old-other'] = None
@@ -500,6 +503,9 @@
% divergent))
return (False, b".")
+ if relocatereq:
+ evolvestate[b'relocation-req'] = True
+ evolvestate[b'resolutionparent'] = resolutionparent
try:
succsdivp1 = utility._singlesuccessor(repo, divergent.p1())
except utility.MultipleSuccessorsError:
@@ -507,12 +513,15 @@
raise error.Abort(msg % divergent.hex()[:12])
# relocate divergent cset to its obsolete parent's successsor
if succsdivp1 != divergent.p1().rev():
+ evolvestate[b'relocating-div'] = True
ui.status(_(b'rebasing "divergent" content-divergent changeset %s on'
b' %s\n' % (divergent, repo[succsdivp1])))
with state.saver(evolvestate, {b'current': divergent.node()}):
newdivergent = relocate(repo, divergent, repo[succsdivp1],
evolvestate, keepbranch=True)
divergent = repo[newdivergent]
+ evolvestate[b'relocating-div'] = False
+ evolvestate[b'relocated-div'] = divergent.node()
evolvestate[b'temprevs'].append(divergent.node())
evolvestate[b'divergent'] = divergent.node()
@@ -520,7 +529,6 @@
if relocatereq and other == divergent.p1():
relocatereq = False
- evolvestate[b'resolutionparent'] = resolutionparent
# relocate the other divergent if required
if relocatereq:
# relocating will help us understand during the time of conflicts that
@@ -2013,6 +2021,39 @@
divergent = evolvestate[b'divergent']
base = evolvestate[b'base']
repo = repo.unfiltered()
+ if evolvestate[b'relocating-div']:
+ newdiv = _completerelocation(ui, repo, evolvestate)
+ current = repo[evolvestate[b'current']]
+ obsolete.createmarkers(repo, [(current, (repo[newdiv],))],
+ operation=b'evolve')
+ evolvestate[b'relocating-div'] = False
+ evolvestate[b'relocated-div'] = newdiv
+ evolvestate[b'temprevs'].append(newdiv)
+ evolvestate[b'divergent'] = newdiv
+
+ relocatereq = evolvestate[b'relocation-req']
+ if relocatereq:
+ divergent = repo[evolvestate[b'divergent']]
+ other = repo[evolvestate[b'other-divergent']]
+ evolvestate[b'relocating-other'] = True
+ ui.status(_(b'rebasing "other" content-divergent changeset %s on'
+ b' %s\n' % (other, divergent.p1())))
+ with state.saver(evolvestate, {b'current': other.node()}):
+ newother = relocate(repo, other, divergent.p1(), evolvestate,
+ keepbranch=True)
+ evolvestate[b'old-other'] = other.node()
+ other = repo[newother]
+ evolvestate[b'relocating-other'] = False
+ evolvestate[b'relocated-other'] = other.node()
+ evolvestate[b'temprevs'].append(other.node())
+ evolvestate[b'other-divergent'] = other.node()
+ # continue the resolution by merging the content-divergence
+ _mergecontentdivergents(repo, progresscb,
+ repo[divergent],
+ repo[newother],
+ repo[base],
+ evolvestate)
+
if evolvestate[b'relocating-other']:
newother = _completerelocation(ui, repo, evolvestate)
current = repo[evolvestate[b'current']]
@@ -2029,6 +2070,7 @@
repo[base],
evolvestate)
+ divergent = evolvestate[b'divergent']
other = evolvestate[b'other-divergent']
ret = _completecontentdivergent(ui, repo, progresscb,
repo[divergent],
--- a/tests/test-evolve-content-divergent-stack.t Mon Nov 25 21:28:52 2019 +0530
+++ b/tests/test-evolve-content-divergent-stack.t Wed Nov 27 12:34:19 2019 +0530
@@ -389,8 +389,48 @@
$ hg res -m
(no more unresolved files)
continue: hg evolve --continue
- $ hg evolve --continue 2>&1 | grep "KeyError"
- KeyError: 'resolutionparent'
+ $ hg evolve --continue
+ evolving 11:6eb54b5af3fb "added b"
+ rebasing "other" content-divergent changeset d5f148423c16 on 119989a4317e
+ merging b
+ warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
+ unresolved merge conflicts
+ (see 'hg help evolve.interrupted')
+ [1]
+
+ $ echo b > b
+ $ hg res -m
+ (no more unresolved files)
+ continue: hg evolve --continue
+ $ hg evolve --continue
+ evolving 6:d5f148423c16 "added b"
+ 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ merge:[12] added c
+ with: [7] added c
+ base: [3] added c
+ rebasing "divergent" content-divergent changeset 8ed612937375 on 646bd3372ee7
+ rebasing "other" content-divergent changeset 3ce4be6d8e5e on 646bd3372ee7
+ 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ merge:[13] added d
+ with: [8] added d
+ base: [4] added d
+ rebasing "divergent" content-divergent changeset d45f050514c2 on 67abc597e636
+ rebasing "other" content-divergent changeset c72d2885eb51 on 67abc597e636
+ 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ working directory is now at 119989a4317e
+ $ hg glog
+ o 25:5e2572194f59 added d
+ | () [default] draft
+ o 22:67abc597e636 added c
+ | () [default] draft
+ o 19:646bd3372ee7 added b
+ | () [default] draft
+ @ 16:119989a4317e watbar to a
+ | () [default] draft
+ o 9:2228e3b74514 add newfile
+ | () [default] draft
+ o 0:8fa14d15e168 added hgignore
+ () [default] draft
$ cd ..