branching: merge default branch in stable to prepare 8.5.0 release stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 11 Apr 2019 22:13:55 +0200
branchstable
changeset 4507 de9089514833
parent 4486 099e0ca8285e (current diff)
parent 4498 99dbe605fda5 (diff)
child 4508 fce8f5ca10d8
branching: merge default branch in stable to prepare 8.5.0 release The release is not fully ready, but the merging is non-trivial.
tests/test-evolve-content-divergence-meta.t
tests/test-stabilize-result.t
tests/test-unstable.t
--- a/CHANGELOG	Wed Apr 10 16:11:59 2019 +0200
+++ b/CHANGELOG	Thu Apr 11 22:13:55 2019 +0200
@@ -1,6 +1,16 @@
 Changelog
 =========
 
+8.5.0 - in progress
+-------------------
+
+  * evolve: improved support for content-divergence with public changesets,
+  * stack: support ranges in revsets indexing,
+  * pick: add the standard `--tool` option,
+  * stack: improved and speed --children flag up,
+  * stack: mention all divergences too.
+  * evolve: share evolve related cache between `shares`
+
 8.4.1 - in progress
 -------------------
 
--- a/hgext3rd/evolve/__init__.py	Wed Apr 10 16:11:59 2019 +0200
+++ b/hgext3rd/evolve/__init__.py	Thu Apr 11 22:13:55 2019 +0200
@@ -220,24 +220,22 @@
 via an extension).
 
 Instability
-==========
+===========
 
-(note: the vocabulary is in the process of being updated)
-
-Rewriting changesets might introduce instability (currently 'trouble').
+Rewriting changesets might introduce instability.
 
 There are two main kinds of instability: orphaning and diverging.
 
-Orphans are changesets left behind when their ancestors are rewritten, (currently: 'unstable').
+Orphans are changesets left behind when their ancestors are rewritten.
 Divergence has two variants:
 
 * Content-divergence occurs when independent rewrites of the same changesets
-  lead to different results. (currently: 'divergent')
+  lead to different results.
 
 * Phase-divergence occurs when the old (obsolete) version of a changeset
-  becomes public. (currently: 'bumped')
+  becomes public.
 
-If it possible to prevent local creation of orphans by using the following config::
+It is possible to prevent local creation of orphans by using the following config::
 
     [experimental]
     evolution=createmarkers,allnewcommands,exchange
--- a/hgext3rd/evolve/cmdrewrite.py	Wed Apr 10 16:11:59 2019 +0200
+++ b/hgext3rd/evolve/cmdrewrite.py	Thu Apr 11 22:13:55 2019 +0200
@@ -159,7 +159,6 @@
         old = repo['.']
         p1 = old.p1()
         rewriteutil.precheck(repo, [old.rev()], 'amend')
-        bookmarkupdater = rewriteutil.bookmarksupdater(repo, old.node(), tr)
         diffopts = patch.difffeatureopts(repo.ui, whitespace=True)
         diffopts.nodates = True
         diffopts.git = True
@@ -176,11 +175,11 @@
         metadata = {}
         if opts.get('note'):
             metadata['note'] = opts['note']
-        obsolete.createmarkers(repo, [(old, (repo[newnode],))],
-                               metadata=metadata, operation='amend')
+        replacements = {old.node(): [newnode]}
+        scmutil.cleanupnodes(repo, replacements, operation='amend',
+                             metadata=metadata)
         phases.retractboundary(repo, tr, old.phase(), [newnode])
         hg.updaterepo(repo, newnode, True)
-        bookmarkupdater(newnode)
         tr.close()
     finally:
         if tr is not None:
@@ -523,7 +522,6 @@
 
         # Recommit the filtered changeset
         tr = repo.transaction('uncommit')
-        updatebookmarks = rewriteutil.bookmarksupdater(repo, old.node(), tr)
         if interactive:
             opts['all'] = True
             match = scmutil.match(old, pats, opts)
@@ -548,8 +546,9 @@
         if opts.get('note'):
             metadata['note'] = opts['note']
 
-        obsolete.createmarkers(repo, [(old, (repo[newid],))], metadata=metadata,
-                               operation="uncommit")
+        replacements = {old.node(): [newid]}
+        scmutil.cleanupnodes(repo, replacements, operation="uncommit",
+                             metadata=metadata)
         phases.retractboundary(repo, tr, oldphase, [newid])
         if opts.get('revert'):
             hg.updaterepo(repo, newid, True)
@@ -557,7 +556,6 @@
             with repo.dirstate.parentchange():
                 repo.dirstate.setparents(newid, node.nullid)
                 _uncommitdirstate(repo, old, match, interactive)
-        updatebookmarks(newid)
         if not repo[newid].files():
             ui.warn(_("new changeset is empty\n"))
             ui.status(_("(use 'hg prune .' to remove it)\n"))
@@ -776,14 +774,9 @@
                                                          root.p2().node()],
                                                         commitopts=commitopts)
             phases.retractboundary(repo, tr, targetphase, [newid])
-            obsolete.createmarkers(repo, [(ctx, (repo[newid],))
-                                   for ctx in allctx], metadata=metadata,
-                                   operation="fold")
-            # move bookmarks from old nodes to the new one
-            # XXX: we should make rewriteutil.rewrite() handle such cases
-            for ctx in allctx:
-                bmupdater = rewriteutil.bookmarksupdater(repo, ctx.node(), tr)
-                bmupdater(newid)
+            replacements = {ctx.node(): [newid] for ctx in allctx}
+            scmutil.cleanupnodes(repo, replacements, operation="fold",
+                                 metadata=metadata)
             tr.close()
         finally:
             tr.release()
@@ -1044,9 +1037,9 @@
             msg = "please add --fold if you want to do a fold"
             raise error.Abort(msg)
         elif biject:
-            relations = [(p, (s,)) for p, s in zip(precs, sucs)]
+            replacements = {p.node(): [s.node()] for p, s in zip(precs, sucs)}
         else:
-            relations = [(p, sucs) for p in precs]
+            replacements = {p.node(): [s.node() for s in sucs] for p in precs}
 
         wdp = repo['.']
 
@@ -1106,14 +1099,8 @@
         if opts.get('note'):
             metadata['note'] = opts['note']
 
-        # create markers
-        obsolete.createmarkers(repo, relations, metadata=metadata,
-                               operation="prune")
-
-        # informs that changeset have been pruned
-        ui.status(_('%i changesets pruned\n') % len(precs))
-
         precrevs = (precursor.rev() for precursor in precs)
+        moves = {}
         for ctx in repo.unfiltered().set('bookmark() and %ld', precrevs):
             # used to be:
             #
@@ -1124,11 +1111,14 @@
             # but then revset took a lazy arrow in the knee and became much
             # slower. The new forms makes as much sense and a much faster.
             for dest in ctx.ancestors():
-                if not dest.obsolete():
-                    bookmarksupdater = rewriteutil.bookmarksupdater
-                    updatebookmarks = bookmarksupdater(repo, ctx.node(), tr)
-                    updatebookmarks(dest.node())
+                if not dest.obsolete() and dest.node() not in replacements:
+                    moves[ctx.node()] = dest.node()
                     break
+        scmutil.cleanupnodes(repo, replacements, operation="prune", moves=moves,
+                             metadata=metadata)
+
+        # informs that changeset have been pruned
+        ui.status(_('%i changesets pruned\n') % len(precs))
 
         tr.close()
     finally:
@@ -1404,7 +1394,7 @@
     [('r', 'rev', '', _('revision to pick'), _('REV')),
      ('c', 'continue', False, 'continue interrupted pick'),
      ('a', 'abort', False, 'abort interrupted pick'),
-    ],
+    ] + mergetoolopts,
     _('[-r] rev'))
 def cmdpick(ui, repo, *revs, **opts):
     """move a commit on the top of working directory parent and updates to it."""
@@ -1419,7 +1409,8 @@
     if opts.get('rev'):
         revs.append(opts['rev'])
 
-    with repo.wlock(), repo.lock(), repo.transaction('pick'):
+    overrides = {('ui', 'forcemerge'): opts.get('tool', '')}
+    with repo.wlock(), repo.lock(), repo.transaction('pick'), ui.configoverride(overrides, 'pick'):
         pickstate = state.cmdstate(repo, path='pickstate')
         pctx = repo['.']
 
@@ -1481,7 +1472,8 @@
         if pickstate:
             pickstate.delete()
         newctx = repo[newnode] if newnode else pctx
-        obsolete.createmarkers(repo, [(origctx, (newctx,))], operation="pick")
+        replacements = {origctx.node(): [newctx.node()]}
+        scmutil.cleanupnodes(repo, replacements, operation="pick")
 
         if newnode is None:
             ui.warn(_("note: picking %d:%s created no changes to commit\n") %
--- a/hgext3rd/evolve/compat.py	Wed Apr 10 16:11:59 2019 +0200
+++ b/hgext3rd/evolve/compat.py	Thu Apr 11 22:13:55 2019 +0200
@@ -16,11 +16,9 @@
     obsolete,
     obsutil,
     repair,
-    revset,
     scmutil,
     util,
     ui as uimod,
-    vfs as vfsmod,
 )
 from mercurial.hgweb import hgweb_mod
 
@@ -54,43 +52,11 @@
 
 # Evolution renaming compat
 
-TROUBLES = {}
-
-if not util.safehasattr(context.basectx, 'orphan'):
-    TROUBLES['ORPHAN'] = 'unstable'
-    context.basectx.orphan = context.basectx.unstable
-else:
-    TROUBLES['ORPHAN'] = 'orphan'
-
-if not util.safehasattr(context.basectx, 'contentdivergent'):
-    TROUBLES['CONTENTDIVERGENT'] = 'divergent'
-    context.basectx.contentdivergent = context.basectx.divergent
-else:
-    TROUBLES['CONTENTDIVERGENT'] = 'content-divergent'
-
-if not util.safehasattr(context.basectx, 'phasedivergent'):
-    TROUBLES['PHASEDIVERGENT'] = 'bumped'
-    context.basectx.phasedivergent = context.basectx.bumped
-else:
-    TROUBLES['PHASEDIVERGENT'] = 'phase-divergent'
-
-if not util.safehasattr(context.basectx, 'isunstable'):
-    context.basectx.isunstable = context.basectx.troubled
-
-if not util.safehasattr(revset, 'orphan'):
-    @eh.revsetpredicate('orphan')
-    def oprhanrevset(*args, **kwargs):
-        return revset.unstable(*args, **kwargs)
-
-if not util.safehasattr(revset, 'contentdivergent'):
-    @eh.revsetpredicate('contentdivergent')
-    def contentdivergentrevset(*args, **kwargs):
-        return revset.divergent(*args, **kwargs)
-
-if not util.safehasattr(revset, 'phasedivergent'):
-    @eh.revsetpredicate('phasedivergent')
-    def phasedivergentrevset(*args, **kwargs):
-        return revset.bumped(*args, **kwargs)
+TROUBLES = {
+    'ORPHAN': 'orphan',
+    'CONTENTDIVERGENT': 'content-divergent',
+    'PHASEDIVERGENT': 'phase-divergent',
+}
 
 if util.safehasattr(uimod.ui, 'makeprogress'):
     def progress(ui, topic, pos, item="", unit="", total=None):
@@ -103,26 +69,6 @@
     def progress(ui, topic, pos, item="", unit="", total=None):
         ui.progress(topic, pos, item="", unit="", total=None)
 
-if not util.safehasattr(context.basectx, 'instabilities'):
-    def instabilities(self):
-        """return the list of instabilities affecting this changeset.
-
-        Instabilities are returned as strings. possible values are:
-         - orphan,
-         - phase-divergent,
-         - content-divergent.
-         """
-        instabilities = []
-        if self.orphan():
-            instabilities.append('orphan')
-        if self.phasedivergent():
-            instabilities.append('phase-divergent')
-        if self.contentdivergent():
-            instabilities.append('content-divergent')
-        return instabilities
-
-    context.basectx.instabilities = instabilities
-
 # XXX: Better detection of property cache
 if 'predecessors' not in dir(obsolete.obsstore):
     @property
@@ -131,15 +77,6 @@
 
     obsolete.obsstore.predecessors = predecessors
 
-if not util.safehasattr(obsolete, '_computeorphanset'):
-    obsolete._computeorphanset = obsolete.cachefor('orphan')(obsolete._computeunstableset)
-
-if not util.safehasattr(obsolete, '_computecontentdivergentset'):
-    obsolete._computecontentdivergentset = obsolete.cachefor('contentdivergent')(obsolete._computedivergentset)
-
-if not util.safehasattr(obsolete, '_computephasedivergentset'):
-    obsolete._computephasedivergentset = obsolete.cachefor('phasedivergent')(obsolete._computebumpedset)
-
 def memfilectx(repo, ctx, fctx, flags, copied, path):
     # XXX Would it be better at the module level?
     varnames = context.memfilectx.__init__.__code__.co_varnames
@@ -162,13 +99,6 @@
                                   copied=copied.get(path))
     return mctx
 
-def getcachevfs(repo):
-    cachevfs = getattr(repo, 'cachevfs', None)
-    if cachevfs is None:
-        cachevfs = vfsmod.vfs(repo.vfs.join('cache'))
-        cachevfs.createmode = repo.store.createmode
-    return cachevfs
-
 def strdiff(a, b, fn1, fn2):
     """ A version of mdiff.unidiff for comparing two strings
     """
@@ -487,7 +417,9 @@
 
     return copy, movewithdir, diverge, renamedelete, dirmove
 
-if util.safehasattr(copies, '_fullcopytracing'):
+# hg <= 4.9 compat (7694b685bb10)
+fixupstreamed = util.safehasattr(scmutil, '_movedirstate')
+if not fixupstreamed:
     copies._fullcopytracing = fixedcopytracing
 
 if not util.safehasattr(obsutil, "_succs"):
--- a/hgext3rd/evolve/depthcache.py	Wed Apr 10 16:11:59 2019 +0200
+++ b/hgext3rd/evolve/depthcache.py	Thu Apr 11 22:13:55 2019 +0200
@@ -178,8 +178,7 @@
         """load data from disk"""
         assert repo.filtername is None
 
-        cachevfs = compat.getcachevfs(repo)
-        data = cachevfs.tryread(self._filepath)
+        data = repo.cachevfs.tryread(self._filepath)
         self._data = array.array('l')
         if not data:
             self._cachekey = self.emptykey
@@ -199,8 +198,7 @@
             return
 
         try:
-            cachevfs = compat.getcachevfs(repo)
-            cachefile = cachevfs(self._filepath, 'w', atomictemp=True)
+            cachefile = repo.cachevfs(self._filepath, 'w', atomictemp=True)
             headerdata = self._serializecachekey()
             cachefile.write(headerdata)
             cachefile.write(self._data.tostring())
--- a/hgext3rd/evolve/evolvecmd.py	Wed Apr 10 16:11:59 2019 +0200
+++ b/hgext3rd/evolve/evolvecmd.py	Thu Apr 11 22:13:55 2019 +0200
@@ -18,8 +18,8 @@
     context,
     copies,
     error,
+    encoding,
     hg,
-    lock as lockmod,
     merge,
     mergeutil,
     node as nodemod,
@@ -71,11 +71,7 @@
     else:
         displayer = compat.changesetdisplayer(ui, repo,
                                               {'template': shorttemplate})
-    wlock = lock = tr = None
-    try:
-        wlock = repo.wlock()
-        lock = repo.lock()
-        tr = repo.transaction("evolve")
+    with repo.wlock(), repo.lock(), repo.transaction("evolve"):
         if 'orphan' == category:
             result = _solveunstable(ui, repo, ctx, evolvestate, displayer,
                                     dryrun, confirm, progresscb,
@@ -89,10 +85,7 @@
                                      dryrun, confirm, progresscb)
         else:
             assert False, "unknown trouble category: %s" % (category)
-        tr.close()
         return result
-    finally:
-        lockmod.release(tr, lock, wlock)
 
 def _solveunstable(ui, repo, orig, evolvestate, displayer, dryrun=False,
                    confirm=False, progresscb=None, lastsolved=None):
@@ -236,7 +229,6 @@
         return (False, ".")
     if progresscb:
         progresscb()
-    tmpctx = bumped
 
     # Checking for whether the phase-divergent changeset has common parents as
     # it's precursors. Phase-divergent changeset and precursor having different
@@ -249,13 +241,14 @@
         repo.ui.status(
             _('rebasing to destination parent: %s\n') % prec.p1())
         try:
-            tmpid = relocate(repo, bumped, prec.p1(), evolvestate,
-                             category='phasedivergent')
-            if tmpid is not None:
-                tmpctx = repo[tmpid]
-                obsolete.createmarkers(repo, [(bumped, (tmpctx,))],
+            newnode = relocate(repo, bumped, prec.p1(), evolvestate,
+                               category='phasedivergent')
+            if newnode is not None:
+                new = repo[newnode]
+                obsolete.createmarkers(repo, [(bumped, (new,))],
                                        operation='evolve')
-                evolvestate['temprevs'].append(tmpid)
+                bumped = new
+                evolvestate['temprevs'].append(newnode)
         except MergeFailure:
             evolvestate['current'] = bumped.hex()
             evolvestate['precursor'] = prec.hex()
@@ -263,25 +256,27 @@
             raise error.InterventionRequired(_("fix conflicts and see `hg help "
                                                "evolve.interrupted`"))
 
-    return _resolvephasedivergent(ui, repo, prec, bumped, tmpctx)
+    return _resolvephasedivergent(ui, repo, prec, bumped)
 
-def _resolvephasedivergent(ui, repo, prec, bumped, tmpctx=None):
+def _resolvephasedivergent(ui, repo, prec, bumped):
+    """final step of a phase divergence resolution
 
+    This will create a new changesets (or nothing when applicable), the two
+    changesets needs to be on the same parents.
+    """
     tr = repo.currenttransaction()
     assert tr is not None
+
+    cl = repo.changelog
+    prec_parent = cl.parentrevs(prec.rev())
+    bump_parent = cl.parentrevs(bumped.rev())
+    assert prec_parent == bump_parent, (prec_parent, bump_parent)
+
     bmupdate = _bookmarksupdater(repo, bumped.node(), tr)
     newid = None
     replacementnode = None
 
-    # function to update the bookmark from the rebased changeset to new resolved
-    # changeset
-    rebasedbmupdate = None
-    if tmpctx and tmpctx.node() != bumped.node():
-        rebasedbmupdate = _bookmarksupdater(repo, tmpctx.node(), tr)
-        bumped = tmpctx
-
     # Create the new commit context
-    repo.ui.status(_('computing new diff\n'))
     files = set()
     copied = copies.pathcopies(prec, bumped)
     precmanifest = prec.manifest().copy()
@@ -320,17 +315,15 @@
         newid = repo.commitctx(new)
         replacementnode = newid
     if newid is None:
-        obsolete.createmarkers(repo, [(tmpctx, ())], operation='evolve')
+        repo.ui.status(_('no changes to commit\n'))
+        obsolete.createmarkers(repo, [(bumped, ())], operation='evolve')
         newid = prec.node()
     else:
+        repo.ui.status(_('committed as %s\n') % nodemod.short(newid))
         phases.retractboundary(repo, tr, bumped.phase(), [newid])
-        obsolete.createmarkers(repo, [(tmpctx, (repo[newid],))],
+        obsolete.createmarkers(repo, [(bumped, (repo[newid],))],
                                flag=obsolete.bumpedfix, operation='evolve')
     bmupdate(newid)
-    # if rebased happened, update bookmarks from there too
-    if rebasedbmupdate:
-        rebasedbmupdate(newid)
-    repo.ui.status(_('committed as %s\n') % nodemod.short(newid))
     # reroute the working copy parent to the new changeset
     with repo.dirstate.parentchange():
         repo.dirstate.setparents(newid, nodemod.nullid)
@@ -349,6 +342,7 @@
     repo = repo.unfiltered()
     divergent = repo[divergent.rev()]
     evolvestate['divergent'] = divergent.node()
+    evolvestate['orig-divergent'] = divergent.node()
     # sometimes we will relocate a node in case of different parents and we can
     # encounter conflicts after relocation is done while solving
     # content-divergence and if the user calls `hg evolve --stop`, we need to
@@ -382,6 +376,23 @@
     evolvestate['other-divergent'] = other.node()
     evolvestate['base'] = base.node()
 
+    def swapnodes(div, other):
+        div, other = other, div
+        evolvestate['divergent'] = div.node()
+        evolvestate['other-divergent'] = other.node()
+        return div, other
+    # haspubdiv: to keep track if we are solving public content-divergence
+    haspubdiv = False
+    if not (divergent.mutable() and other.mutable()):
+        haspubdiv = True
+        # for simplicity, we keep public one to local side while merging
+        # (as divergent is kept at local side, pinning public -> divergent)
+        if divergent.mutable():
+            publicdiv = other
+            divergent, other = swapnodes(divergent, other)
+        else:
+            publicdiv = divergent
+        evolvestate['public-divergent'] = publicdiv.node()
     # we don't handle merge content-divergent changesets yet
     if len(other.parents()) > 1:
         msg = _("skipping %s: %s changeset can't be "
@@ -411,7 +422,17 @@
     resolutionparent = repo[divp1].node()
 
     gca = repo.revs("ancestor(%d, %d)" % (otherp1, divp1))
-
+    # divonly: non-obsolete csets which are topological ancestor of "divergent"
+    # but not "other"
+    divonly = repo.revs("only(%d, %d) - obsolete()" % (divergent.rev(),
+                                                       other.rev()))
+    # otheronly: non-obsolete csets which are topological ancestor of "other"
+    # but not "div"
+    otheronly = repo.revs("only(%d, %d) - obsolete()" % (other.rev(),
+                                                         divergent.rev()))
+    # make it exclusive set
+    divonly = set(divonly) - {divergent.rev()}
+    otheronly = set(otheronly) - {other.rev()}
     # is relocation of one of the changeset required
     relocatereq = False
 
@@ -429,15 +450,44 @@
     # then solve the content-divergence the way we solve 1)
     # for 3) and 4), we still have to decide
     if otherp1 in gca and divp1 in gca:
-        # both are on the same parents
-        pass
+        if otherp1 == other.p1().rev() and divp1 == divergent.p1().rev():
+            # both are on the same parents
+            pass
+        else:
+            # both are not on the same parent but have same parents's succs.
+            if otheronly and divonly:
+                # case: we have visible csets on both side diverging from
+                # tca of "divergent" and "other". We still need to decide what
+                # to do in this case
+                pass
+            if otheronly:
+                relocatereq = True
+                if not haspubdiv:
+                    # can't swap when public divergence, as public can't move
+                    divergent, other = swapnodes(divergent, other)
+                    resolutionparent = repo[otherp1].node()
+            elif divonly:
+                relocatereq = True
+            else:
+                # no extra cset on either side; so not considering relocation
+                pass
     elif otherp1 in gca and divp1 not in gca:
         relocatereq = True
         pass
     elif divp1 in gca and otherp1 not in gca:
         relocatereq = True
-        divergent, other = other, divergent
-        resolutionparent = divergent.p1().node()
+
+        # When public branch is behind to the mutable branch, for now we
+        # relocate mutable cset to public one's side in every case.
+        #
+        # This behaviour might be sub optimal when ancestors of mutable
+        # cset has changes its relocated descendant rely on.
+        #
+        # Otherwise, we are going to rebase the "behind" branch up to the new
+        # brancmap level.
+        if not haspubdiv:
+            divergent, other = swapnodes(divergent, other)
+            resolutionparent = divergent.p1().node()
     else:
         msg = _("skipping %s: have a different parent than %s "
                 "(not handled yet)\n") % (divergent, other)
@@ -499,8 +549,24 @@
 
     _mergecontentdivergents(repo, progresscb, divergent, other, base,
                             evolvestate)
-    return _completecontentdivergent(ui, repo, progresscb, divergent, other,
-                                     base, evolvestate)
+    res, newnode = _completecontentdivergent(ui, repo, progresscb, divergent,
+                                             other, base, evolvestate)
+    if not haspubdiv:
+        return (res, newnode)
+    else:
+        # when we have content-divergence with a public cset: after completing
+        # content divergence resolution the resulting node will be phase
+        # divergent with that same public cset.
+        # here newnode is phase divergent, lets resolve this divergence.
+        if not res:
+            # resolution was not successful, return
+            return (res, newnode)
+        if newnode == publicdiv.node():
+            # no changes were found that are different from public cset
+            return (res, newnode)
+        prec = publicdiv
+        bumped = repo[newnode]
+        return _resolvephasedivergent(ui, repo, prec=prec, bumped=bumped)
 
 def _mergecontentdivergents(repo, progresscb, divergent, other, base,
                             evolvestate):
@@ -513,12 +579,13 @@
                    (TROUBLES['CONTENTDIVERGENT'], other.hex()[:12]))
     if progresscb:
         progresscb()
+    mergeancestor = repo.changelog.isancestor(divergent.node(), other.node())
     stats = merge.update(repo,
                          other.node(),
                          branchmerge=True,
                          force=False,
                          ancestor=base.node(),
-                         mergeancestor=True)
+                         mergeancestor=mergeancestor)
     hg._showstats(repo, stats)
 
     # conflicts while merging content-divergent changesets
@@ -542,6 +609,31 @@
     # whether to store the obsmarker in the evolvestate
     storemarker = False
     resparent = evolvestate['resolutionparent']
+
+    # whether we are solving public divergence
+    haspubdiv = False
+    if evolvestate.get('public-divergent'):
+        haspubdiv = True
+        publicnode = evolvestate['public-divergent']
+        publicdiv = repo[publicnode]
+        othernode = evolvestate['other-divergent']
+        otherdiv = repo[othernode]
+
+        with repo.dirstate.parentchange():
+            repo.dirstate.setparents(publicnode, nodemod.nullid)
+            dirstatedance(repo, divergent, publicnode, None)
+        # check if node to be committed has changes same as public one
+        s = publicdiv.status()
+        if not (s.added or s.removed or s.deleted or s.modified):
+            # warn user if metadata is being lost
+            if otherdiv.description() != publicdiv.description():
+                msg = _('content-divergent changesets differ by descriptions '
+                        'only, discarding %s\n') % str(otherdiv)
+                repo.ui.warn(msg)
+            # no changes, create markers to resolve divergence
+            obsolete.createmarkers(repo, [(otherdiv, (publicdiv,))],
+                                   operation='evolve')
+            return (True, publicnode)
     try:
         with repo.dirstate.parentchange():
             repo.dirstate.setparents(resparent, nodemod.nullid)
@@ -571,10 +663,17 @@
             new = repo[newnode]
             newnode = new.node()
             hg.updaterepo(repo, new.rev(), False)
-            obsolete.createmarkers(repo, [(divergent, (new,))], operation='evolve')
+            if haspubdiv and publicdiv == divergent:
+                bypassphase(repo, (divergent, new), operation='evolve')
+            else:
+                obsolete.createmarkers(repo, [(divergent, (new,))],
+                                       operation='evolve')
 
         # creating markers and moving phases post-resolution
-        obsolete.createmarkers(repo, [(other, (new,))], operation='evolve')
+        if haspubdiv and publicdiv == other:
+            bypassphase(repo, (other, new), operation='evolve')
+        else:
+            obsolete.createmarkers(repo, [(other, (new,))], operation='evolve')
         if storemarker:
             # storing the marker in the evolvestate
             # we just store the precursors and successor pair for now, we might
@@ -587,6 +686,50 @@
     finally:
         repo.ui.restoreconfig(emtpycommitallowed)
 
+def bypassphase(repo, relation, flag=0, metadata=None, operation='evolve'):
+    """function to create a single obsmarker relation even for public csets
+    where relation should be a single pair (prec, succ)"""
+
+    # prepare metadata
+    if metadata is None:
+        metadata = {}
+    if 'user' not in metadata:
+        luser = repo.ui.config('devel', 'user.obsmarker') or repo.ui.username()
+        metadata['user'] = encoding.fromlocal(luser)
+    # Operation metadata handling
+    useoperation = repo.ui.configbool('experimental',
+                                      'evolution.track-operation')
+    if useoperation and operation:
+        metadata['operation'] = operation
+
+    # Effect flag metadata handling
+    saveeffectflag = repo.ui.configbool('experimental',
+                                        'evolution.effect-flags')
+    with repo.transaction('add-obsolescence-marker') as tr:
+        prec, succ = relation
+        nprec = prec.node()
+        npare = None
+        nsucs = [succ.node()]
+        if not nsucs:
+            npare = tuple(p.node() for p in prec.parents())
+        if nprec in nsucs:
+            raise error.Abort(_("changeset %s cannot obsolete itself") % prec)
+
+        if saveeffectflag:
+            # The effect flag is saved in a versioned field name for
+            # future evolution
+            try:
+                effectflag = obsutil.geteffectflag(prec, (succ,))
+            except TypeError:
+                # hg <= 4.7
+                effectflag = obsutil.geteffectflag((prec, (succ,)))
+            metadata[obsutil.EFFECTFLAGFIELD] = "%d" % effectflag
+
+        # create markers
+        repo.obsstore.create(tr, nprec, nsucs, flag, parents=npare,
+                             metadata=metadata, ui=repo.ui)
+        repo.filteredrevcache.clear()
+
 def dirstatedance(repo, oldparent, newparent, match):
     """utility function to fix the dirstate when we change parents from
     oldparent to newparent with a dirty working directory using
@@ -1298,10 +1441,12 @@
         compat.progress(ui, _('evolve'), None)
 
     if not shouldupdate:
+        # Move back to startnode, or to its successor if the start node is
+        # obsolete (perhaps made obsolete by the current `hg evolve`)
         unfi = repo.unfiltered()
         succ = utility._singlesuccessor(repo, unfi[startnode])
         hg.updaterepo(repo, repo[succ].node(), False)
-    if repo['.'] != startnode:
+    if repo['.'].node() != startnode:
         ui.status(_('working directory is now at %s\n') % repo['.'])
 
 def divergentsets(repo, ctx):
@@ -1456,7 +1601,7 @@
     contopt = opts['continue']
     anyopt = opts['any']
     allopt = opts['all']
-    startnode = repo['.']
+    startnode = repo['.'].node()
     dryrunopt = opts['dry_run']
     confirmopt = opts['confirm']
     revopt = opts['rev']
@@ -1554,7 +1699,7 @@
         # cbor does not know how to serialize sets, using list for skippedrevs
         stateopts = {'category': targetcat, 'replacements': {},
                      'revs': list(revs), 'confirm': confirmopt,
-                     'startnode': startnode.node(), 'skippedrevs': [],
+                     'startnode': startnode, 'skippedrevs': [],
                      'command': 'evolve', 'orphanmerge': False,
                      'bookmarkchanges': [], 'temprevs': [], 'obsmarkers': []}
         evolvestate.addopts(stateopts)
@@ -1601,8 +1746,9 @@
     _cleanup(ui, repo, startnode, showprogress, shouldupdate)
 
 def solveobswdp(ui, repo, opts):
+    """this function updates to the successor of obsolete wdir parent"""
     oldid = repo['.'].node()
-    startnode = repo['.']
+    startctx = repo['.']
     dryrunopt = opts.get('dry_run', False)
     displayer = compat.changesetdisplayer(ui, repo,
                                           {'template': shorttemplate})
@@ -1625,7 +1771,7 @@
     res = hg.update(repo, ctx.rev())
     newid = ctx.node()
 
-    if ctx != startnode:
+    if ctx != startctx:
         with repo.wlock(), repo.lock(), repo.transaction('evolve') as tr:
             bmupdater = rewriteutil.bookmarksupdater(repo, oldid, tr)
             bmupdater(newid)
@@ -1820,8 +1966,25 @@
                                         repo[other],
                                         repo[base],
                                         evolvestate)
-        evolvestate['replacements'][divergent] = ret[1]
+        origdivergent = evolvestate['orig-divergent']
+        evolvestate['replacements'][origdivergent] = ret[1]
+        # logic to continue the public content-divergent
+        publicnode = evolvestate.get('public-divergent')
+        if publicnode:
+            res, newnode = ret
+            if not res:
+                # no need to proceed for phase divergence resolution step
+                pass
+            elif newnode == publicnode:
+                # merging had the same changes as public changeset and
+                # divergence has been resolved by creating markers
+                pass
+            else:
+                prec = repo[publicnode]
+                bumped = repo[newnode]
+                ret = _resolvephasedivergent(ui, repo, prec=prec, bumped=bumped)
         tr.close()
+        return ret
     finally:
         tr.release()
 
@@ -1845,7 +2008,7 @@
 
         # now continuing the phase-divergence resolution part
         prec = repo[evolvestate['precursor']]
-        retvalue = _resolvephasedivergent(ui, repo, prec, ctx, newctx)
+        retvalue = _resolvephasedivergent(ui, repo, prec, newctx)
         evolvestate['replacements'][ctx.node()] = retvalue[1]
         tr.close()
     finally:
--- a/hgext3rd/evolve/firstmergecache.py	Wed Apr 10 16:11:59 2019 +0200
+++ b/hgext3rd/evolve/firstmergecache.py	Thu Apr 11 22:13:55 2019 +0200
@@ -115,8 +115,7 @@
         """load data from disk"""
         assert repo.filtername is None
 
-        cachevfs = compat.getcachevfs(repo)
-        data = cachevfs.tryread(self._filepath)
+        data = repo.cachevfs.tryread(self._filepath)
         self._data = array.array('l')
         if not data:
             self._cachekey = self.emptykey
@@ -136,8 +135,7 @@
             return
 
         try:
-            cachevfs = compat.getcachevfs(repo)
-            cachefile = cachevfs(self._filepath, 'w', atomictemp=True)
+            cachefile = repo.cachevfs(self._filepath, 'w', atomictemp=True)
             headerdata = self._serializecachekey()
             cachefile.write(headerdata)
             cachefile.write(self._data.tostring())
--- a/hgext3rd/evolve/metadata.py	Wed Apr 10 16:11:59 2019 +0200
+++ b/hgext3rd/evolve/metadata.py	Thu Apr 11 22:13:55 2019 +0200
@@ -5,7 +5,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-__version__ = '8.4.1.dev'
+__version__ = '8.5.0.dev'
 testedwith = '4.4.2 4.5.2 4.6.2 4.7 4.8 4.9'
 minimumhgversion = '4.4'
 buglink = 'https://bz.mercurial-scm.org/'
--- a/hgext3rd/evolve/obscache.py	Wed Apr 10 16:11:59 2019 +0200
+++ b/hgext3rd/evolve/obscache.py	Thu Apr 11 22:13:55 2019 +0200
@@ -20,7 +20,6 @@
 )
 
 from . import (
-    compat,
     exthelper,
 )
 
@@ -323,7 +322,6 @@
     def __init__(self, repo):
         super(obscache, self).__init__()
         self._ondiskkey = None
-        self._vfs = compat.getcachevfs(repo)
 
     @util.propertycache
     def get(self):
@@ -405,7 +403,7 @@
             return
 
         try:
-            cachefile = self._vfs(self._filepath, 'w', atomictemp=True)
+            cachefile = repo.cachevfs(self._filepath, 'w', atomictemp=True)
             headerdata = struct.pack(self._headerformat, *self._cachekey)
             cachefile.write(headerdata)
             cachefile.write(self._data)
@@ -419,7 +417,7 @@
         """load data from disk"""
         assert repo.filtername is None
 
-        data = self._vfs.tryread(self._filepath)
+        data = repo.cachevfs.tryread(self._filepath)
         if not data:
             self._cachekey = self.emptykey
             self._setdata(bytearray())
--- a/hgext3rd/evolve/obsdiscovery.py	Wed Apr 10 16:11:59 2019 +0200
+++ b/hgext3rd/evolve/obsdiscovery.py	Thu Apr 11 22:13:55 2019 +0200
@@ -88,9 +88,15 @@
     common = set()
     undecided = set(probeset)
     totalnb = len(undecided)
+    heads = [rev for rev in cl.headrevs() if rev != node.nullrev]
     compat.progress(ui, _("comparing with other"), 0, total=totalnb,
                     unit=_("changesets"))
-    _takefullsample = setdiscovery._takefullsample
+    if util.safehasattr(setdiscovery, '_takefullsample'):
+        # hg compat <= hg-4.9 (e5ece0f46b40)
+        _takefullsample = setdiscovery._takefullsample
+    else:
+        obsdiscov = setdiscovery.partialdiscovery(local, heads)
+        _takefullsample = obsdiscov.takefullsample
     if remote.capable('_evoext_obshash_1'):
         getremotehash = remote.evoext_obshash1
         localhash = _obsrelsethashtreefm1(local)
@@ -104,13 +110,18 @@
         if len(undecided) < fullsamplesize:
             sample = set(undecided)
         else:
-            # Mercurial 4.8 changed calling convention.
-            if len(inspect.getargspec(_takefullsample)[0]) == 4:
-                sample = _takefullsample(local, None, undecided,
-                                         size=fullsamplesize)
+            if util.safehasattr(setdiscovery, '_takefullsample'):
+                # compat <= hg-4.9 (e5ece0f46b40)
+                if len(inspect.getargspec(_takefullsample)[0]) == 4:
+                    # Mercurial 4.8 changed calling convention.
+                    sample = _takefullsample(local, None, undecided,
+                                             size=fullsamplesize)
+                else:
+                    # hg <= 4.7 version
+                    sample = _takefullsample(dag, undecided,
+                                             size=fullsamplesize)
             else:
-                # hg <= 4.7 version
-                sample = _takefullsample(dag, undecided, size=fullsamplesize)
+                sample = _takefullsample(None, size=fullsamplesize)
 
         roundtrips += 1
         compat.progress(ui, _("comparing with other"), totalnb - len(undecided),
@@ -405,12 +416,12 @@
     _schemaversion = 3
 
     _cachename = 'evo-ext-obshashrange' # used for error message
-    _filename = 'cache/evoext_obshashrange_v2.sqlite'
+    _filename = 'evoext_obshashrange_v2.sqlite'
 
     def __init__(self, repo):
         super(_obshashcache, self).__init__()
         self._vfs = repo.vfs
-        self._path = repo.vfs.join(self._filename)
+        self._path = repo.cachevfs.join(self._filename)
         self._new = set()
         self._valid = True
         self._repo = weakref.ref(repo.unfiltered())
--- a/hgext3rd/evolve/obshistory.py	Wed Apr 10 16:11:59 2019 +0200
+++ b/hgext3rd/evolve/obshistory.py	Thu Apr 11 22:13:55 2019 +0200
@@ -780,46 +780,6 @@
 
     return True
 
-def geteffectflag(relation):
-    """compute the effect flag by comparing the source and destination"""
-    effects = 0
-
-    source = relation[0]
-
-    for changectx in relation[1]:
-        # Check if description has changed
-        if changectx.description() != source.description():
-            effects |= DESCCHANGED
-
-        # Check if known meta has changed
-        if changectx.user() != source.user():
-            effects |= USERCHANGED
-
-        if changectx.date() != source.date():
-            effects |= DATECHANGED
-
-        if changectx.branch() != source.branch():
-            effects |= BRANCHCHANGED
-
-        # Check if other meta has changed
-        changeextra = changectx.extra().items()
-        ctxmeta = filter(ismetablacklisted, changeextra)
-
-        sourceextra = source.extra().items()
-        srcmeta = filter(ismetablacklisted, sourceextra)
-
-        if ctxmeta != srcmeta:
-            effects |= METACHANGED
-
-        # Check if at least one of the parent has changes
-        if changectx.parents() != source.parents():
-            effects |= PARENTCHANGED
-
-        if not _cmpdiff(source, changectx):
-            effects |= DIFFCHANGED
-
-    return effects
-
 def _prepare_hunk(hunk):
     """Drop all information but the username and patch"""
     cleanunk = []
@@ -838,28 +798,6 @@
         return None
     return _prepare_hunk(lines)
 
-def _cmpdiff(leftctx, rightctx):
-    """return True if both ctx introduce the "same diff"
-
-    This is a first and basic implementation, with many shortcoming.
-    """
-
-    # Leftctx or right ctx might be filtered, so we need to use the contexts
-    # with an unfiltered repository to safely compute the diff
-    leftunfi = leftctx._repo.unfiltered()[leftctx.rev()]
-    leftdiff = leftunfi.diff(git=1)
-    rightunfi = rightctx._repo.unfiltered()[rightctx.rev()]
-    rightdiff = rightunfi.diff(git=1)
-
-    left, right = (0, 0)
-    while None not in (left, right):
-        left = _getdifflines(leftdiff)
-        right = _getdifflines(rightdiff)
-
-        if left != right:
-            return False
-    return True
-
 def _getobsfate(successorssets):
     """ Compute a changeset obsolescence fate based on his successorssets.
     Successors can be the tipmost ones or the immediate ones.
--- a/hgext3rd/evolve/stablerangecache.py	Wed Apr 10 16:11:59 2019 +0200
+++ b/hgext3rd/evolve/stablerangecache.py	Thu Apr 11 22:13:55 2019 +0200
@@ -176,7 +176,7 @@
     def __init__(self, repo, **kwargs):
         super(stablerangesqlbase, self).__init__(**kwargs)
         self._vfs = repo.vfs
-        self._path = repo.vfs.join(self._cachefile)
+        self._path = repo.cachevfs.join(self._cachefile)
         self._cl = repo.unfiltered().changelog # (okay to keep an old one)
         self._ondisktiprev = None
         self._ondisktipnode = None
@@ -390,13 +390,13 @@
 class mergepointsql(stablerangesql, stablerange.stablerange_mergepoint):
 
     _schemaversion = 3
-    _cachefile = 'cache/evoext_stablerange_v2.sqlite'
+    _cachefile = 'evoext_stablerange_v2.sqlite'
     _cachename = 'evo-ext-stablerange-mergepoint'
 
 class sqlstablerange(stablerangesqlbase, stablerange.stablerange):
 
     _schemaversion = 1
-    _cachefile = 'cache/evoext_stablerange_v1.sqlite'
+    _cachefile = 'evoext_stablerange_v1.sqlite'
 
     def warmup(self, repo, upto=None):
         self._con # make sure the data base is loaded
--- a/hgext3rd/evolve/stablesort.py	Wed Apr 10 16:11:59 2019 +0200
+++ b/hgext3rd/evolve/stablesort.py	Thu Apr 11 22:13:55 2019 +0200
@@ -608,8 +608,7 @@
         """
         assert repo.filtername is None
 
-        cachevfs = compat.getcachevfs(repo)
-        data = cachevfs.tryread(self._filepath)
+        data = repo.cachevfs.tryread(self._filepath)
         self._index = array.array('l')
         self._data = array.array('l')
         if not data:
@@ -635,8 +634,7 @@
         if self._cachekey is None or self._cachekey == self._ondiskkey:
             return
         try:
-            cachevfs = compat.getcachevfs(repo)
-            cachefile = cachevfs(self._filepath, 'w', atomictemp=True)
+            cachefile = repo.cachevfs(self._filepath, 'w', atomictemp=True)
 
             # data to write
             headerdata = self._serializecachekey()
--- a/hgext3rd/evolve/utility.py	Wed Apr 10 16:11:59 2019 +0200
+++ b/hgext3rd/evolve/utility.py	Thu Apr 11 22:13:55 2019 +0200
@@ -164,7 +164,7 @@
     promptmsg = customheader + "\n"
     for idx, rev in enumerate(revs):
         curctx = repo[rev]
-        revmsg = "%d: [%s] %s\n" % (idx, curctx,
+        revmsg = "%d: [%s] %s\n" % (idx + 1, curctx,
                                     curctx.description().split("\n")[0])
         promptmsg += revmsg
 
@@ -181,9 +181,9 @@
         ui.write_err(_("invalid value '%s' entered for index\n") % idxselected)
         return None
 
-    if intidx >= len(revs) or intidx < 0:
+    if intidx > len(revs) or intidx <= 0:
         # we can make this error message better
         ui.write_err(_("invalid value '%d' entered for index\n") % intidx)
         return None
 
-    return revs[intidx]
+    return revs[intidx - 1]
--- a/hgext3rd/topic/__init__.py	Wed Apr 10 16:11:59 2019 +0200
+++ b/hgext3rd/topic/__init__.py	Thu Apr 11 22:13:55 2019 +0200
@@ -167,7 +167,9 @@
               'topic.stack.state.current': 'cyan bold',  # random pick
               'topic.stack.desc.current': 'cyan',        # random pick
               'topic.stack.shortnode.current': 'cyan',   # random pick
-              'topic.stack.state.unstable': 'red',
+              'topic.stack.state.orphan': 'red',
+              'topic.stack.state.content-divergent': 'red',
+              'topic.stack.state.phase-divergent': 'red',
               'topic.stack.summary.behindcount': 'cyan',
               'topic.stack.summary.behinderror': 'red',
               'topic.stack.summary.headcount.multiple': 'yellow',
@@ -177,7 +179,7 @@
               'topic.active': 'green',
              }
 
-__version__ = '0.13.1.dev'
+__version__ = '0.14.0.dev'
 
 testedwith = '4.4.2 4.5.2 4.6.2 4.7 4.8 4.9'
 minimumhgversion = '4.4'
--- a/hgext3rd/topic/revset.py	Wed Apr 10 16:11:59 2019 +0200
+++ b/hgext3rd/topic/revset.py	Thu Apr 11 22:13:55 2019 +0200
@@ -108,7 +108,7 @@
     return revset.baseset(stack.stack(repo, branch=branch, topic=topic)[1:]) & subset
 
 if util.safehasattr(revset, 'subscriptrelations'):
-    def stackrel(repo, subset, x, rel, n, order):
+    def stackrel(repo, subset, x, rel, z, order):
         """This is a revset-flavored implementation of stack aliases.
 
         The syntax is: rev#stack[n] or rev#s[n]. Plenty of logic is borrowed
@@ -116,9 +116,25 @@
         (e.g. when stack index is too high), this returns empty set to be more
         revset-friendly.
         """
+        # hg 4.9 provides a number or None, hg 5.0 provides a tuple of tokens
+        if isinstance(z, tuple):
+            a, b = revset.getintrange(
+                z,
+                'relation subscript must be an integer or a range',
+                'relation subscript bounds must be integers',
+                None, None)
+        else:
+            a = b = z
+
         s = revset.getset(repo, revset.fullreposet(repo), x)
         if not s:
             return revset.baseset()
+
+        def getrange(st, a, b):
+            start = 1 if a is None else a
+            end = len(st.revs) if b is None else b + 1
+            return range(start, end)
+
         revs = []
         for r in s:
             topic = repo[r].topic()
@@ -126,32 +142,29 @@
                 st = stack.stack(repo, topic=topic)
             else:
                 st = stack.stack(repo, branch=repo[r].branch())
-            if n < 0:
-                st = list(st)[1:]
-            else:
-                st = list(st)
-            try:
-                rev = st[n]
-            except IndexError:
-                continue
-            if rev == -1 and n == 0:
-                continue
-            if rev not in revs:
-                revs.append(rev)
+            for n in getrange(st, a, b):
+                if abs(n) >= len(st.revs):
+                    # also means stack base is not accessible with n < 0, which
+                    # is by design
+                    continue
+                if n == 0 and b != 0 and a != 0:
+                    # quirk: we don't want stack base unless specifically asked
+                    # for it (at least one of the indices is 0)
+                    continue
+                rev = st.revs[n]
+                if rev == -1 and n == 0:
+                    continue
+                if rev not in revs:
+                    revs.append(rev)
+
         return subset & revset.baseset(revs)
 
     revset.subscriptrelations['stack'] = stackrel
     revset.subscriptrelations['s'] = stackrel
 
-    def topicrel(repo, subset, x, rel, n, order):
-        ancestors = revset._ancestors
-        descendants = revset._descendants
-        subset = topicset(repo, subset, x)
-        if n <= 0:
-            n = -n
-            return ancestors(repo, subset, x, startdepth=n, stopdepth=n + 1)
-        else:
-            return descendants(repo, subset, x, startdepth=n, stopdepth=n + 1)
+    def topicrel(repo, subset, x, *args):
+        subset &= topicset(repo, subset, x)
+        return revset.generationsrel(repo, subset, x, *args)
 
     revset.subscriptrelations['topic'] = topicrel
     revset.subscriptrelations['t'] = topicrel
--- a/hgext3rd/topic/stack.py	Wed Apr 10 16:11:59 2019 +0200
+++ b/hgext3rd/topic/stack.py	Thu Apr 11 22:13:55 2019 +0200
@@ -5,7 +5,6 @@
 from mercurial.i18n import _
 from mercurial import (
     destutil,
-    context,
     error,
     node,
     phases,
@@ -20,14 +19,6 @@
 
 short = node.short
 
-# TODO: compat
-
-if not util.safehasattr(context.basectx, 'orphan'):
-    context.basectx.orphan = context.basectx.unstable
-
-if not util.safehasattr(context.basectx, 'isunstable'):
-    context.basectx.isunstable = context.basectx.troubled
-
 def parseusername(user):
     """parses the ctx user and returns the username without email ID if
     possible, otherwise returns the mail address from that"""
@@ -51,16 +42,11 @@
     The intend is to build something more efficient than what revsets do in
     this area.
     """
-    phasecache = repo._phasecache
-    if not phasecache._phasesets:
-        return repo.revs('(not public()) - obsolete()')
-    if any(s is None for s in phasecache._phasesets):
+    phasesets = repo._phasecache._phasesets
+    if not phasesets or None in phasesets[phases.draft:]:
         return repo.revs('(not public()) - obsolete()')
 
-    result = set()
-    for s in phasecache._phasesets[phases.draft:]:
-        result |= s
-
+    result = set.union(*phasesets[phases.draft:])
     result -= obsolete.getrevs(repo, 'obsolete')
     return result
 
@@ -228,7 +214,7 @@
     """ Takes a label prefix and a list of suffixes. Returns a string of the prefix
     formatted with each suffix separated with a space.
     """
-    return ' '.join(prefix % suffix for suffix in labelssuffix)
+    return ' '.join(prefix % suffix.replace(' ', '-') for suffix in labelssuffix)
 
 def showstack(ui, repo, branch=None, topic=None, opts=None):
     if opts is None:
@@ -293,7 +279,8 @@
     if empty:
         fm.plain(_("(stack is empty)\n"))
 
-    for idx, r in enumerate(stack(repo, branch=branch, topic=topic), 0):
+    st = stack(repo, branch=branch, topic=topic)
+    for idx, r in enumerate(st, 0):
         ctx = repo[r]
         # special case for t0, b0 as it's hard to plugin into rest of the logic
         if idx == 0:
@@ -329,32 +316,28 @@
 
         symbol = None
         states = []
-        msg = ''
-        iscurrentrevision = repo.revs('%d and parents()', ctx.rev())
         if opts.get('children'):
-            if branch:
-                t_msg = '-branch("%s")' % branch
-            if topic:
-                t_msg = '-topic("%s")' % topic
-            rev_msg = 'children(%s) and merge() %s'
-            revisions = repo.revs(rev_msg % (ctx.rev(), t_msg))
-            len_rev = len(revisions)
-            if len_rev > 0:
-                msg = 'external-children'
-
-        if iscurrentrevision:
-            symbol = '@'
-            if msg:
-                states.append('current - ' + msg)
-            else:
-                states.append('current')
+            expr = 'children(%d) and merge() - %ld'
+            revisions = repo.revs(expr, ctx.rev(), st.revs[1:])
+            if len(revisions) > 0:
+                states.append('external-children')
 
         if ctx.orphan():
             symbol = '$'
-            if msg:
-                states.append('unstable - ' + msg)
-            else:
-                states.append('unstable')
+            states.append('orphan')
+
+        if ctx.contentdivergent():
+            symbol = '$'
+            states.append('content divergent')
+
+        if ctx.phasedivergent():
+            symbol = '$'
+            states.append('phase divergent')
+
+        iscurrentrevision = repo.revs('%d and parents()', ctx.rev())
+        if iscurrentrevision:
+            symbol = '@'
+            states.append('current')
 
         if not isentry:
             symbol = '^'
@@ -364,10 +347,9 @@
         # none of the above if statments get executed
         if not symbol:
             symbol = ':'
-            if msg:
-                states.append(msg)
-            else:
-                states.append('clean')
+
+        if not states:
+            states.append('clean')
 
         states.sort()
 
--- a/tests/test-evolve-abort-phasediv.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-evolve-abort-phasediv.t	Thu Apr 11 22:13:55 2019 +0200
@@ -207,8 +207,7 @@
   recreate:[7] added d
   atop:[4] added d
   rebasing to destination parent: ca1b80f7960a
-  computing new diff
-  committed as c41c793e0ef1
+  no changes to commit
   recreate:[9] added c
   atop:[3] added c
   rebasing to destination parent: b1661037fa25
@@ -292,7 +291,6 @@
   continue: hg evolve --continue
   $ hg evolve --continue
   evolving 9:28cd06b3f801 "added c"
-  computing new diff
   committed as 95d746965290
   recreate:[10] added d
   atop:[4] added d
--- a/tests/test-evolve-content-divergence-meta.t	Wed Apr 10 16:11:59 2019 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-+====================================================
-+Tests the resolution of content divergence: metadata
-+====================================================
-
-This file intend to cover cases focused around meta data merging.
-
-Setup
------
-
-  $ cat >> $HGRCPATH <<EOF
-  > [alias]
-  > glog = log -GT "{rev}:{node|short} {desc|firstline}\n {phase} {troubles}\n\n"
-  > [phases]
-  > publish = False
-  > [extensions]
-  > rebase =
-  > EOF
-  $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
-
-Check we preserve the author properly
--------------------------------------
-
-Testing issue6113 to make sure that content-divergence resolution don't
-replace initial author with the user running the resolution command:
-
-  $ hg init userfoo
-  $ cd userfoo
-  $ unset HGUSER
-  $ echo "[ui]" >> ./.hg/hgrc
-  $ echo "username = foo <foo@test.com>" >> ./.hg/hgrc
-  $ for ch in a b c; do
-  > echo $ch > $ch;
-  > hg add $ch;
-  > hg ci -m "added "$ch;
-  > done;
-
-  $ cd ..
-  $ hg init userbar
-  $ cd userbar
-  $ unset HGUSER
-  $ echo "[ui]" >> ./.hg/hgrc
-  $ echo "username = bar <bar@test.com>" >> ./.hg/hgrc
-  $ hg pull ./../userfoo -q
-
-  $ cd ../userfoo
-  $ hg up -r "desc('added b')"
-  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  $ echo c > c
-  $ echo e > e
-  $ hg add c e
-  $ hg ci -m "added c e"
-  created new head
-
-  $ hg up -r "desc('added b')"
-  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
-  $ echo cc > c
-  $ hg add c
-  $ hg ci -m "added c"
-  created new head
-
-  $ hg prune -r "min(desc('added c'))" -s "desc('added c e')"
-  1 changesets pruned
-  $ hg prune -r "min(desc('added c'))" -s "max(desc('added c'))" --hidden
-  1 changesets pruned
-  2 new content-divergent changesets
-
-  $ hg glog
-  @  4:6c06cda6dc99 added c
-  |   draft content-divergent
-  |
-  | *  3:0c9267e23c9d added c e
-  |/    draft content-divergent
-  |
-  o  1:1740ad2a1eda added b
-  |   draft
-  |
-  o  0:f863f39764c4 added a
-      draft
-  
-
-  $ cd ../userbar
-  $ hg pull ./../userfoo -q
-  2 new content-divergent changesets
-
-  $ hg evolve --content-divergent --any
-  merge:[3] added c e
-  with: [4] added c
-  base: [2] added c
-  updating to "local" side of the conflict: 0c9267e23c9d
-  merging "other" content-divergent changeset '6c06cda6dc99'
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory is now at 443bd2972210
-
-Make sure resultant cset don't replace the initial user with user running the command:
-  $ hg log -r tip
-  changeset:   5:443bd2972210
-  tag:         tip
-  parent:      1:1740ad2a1eda
-  user:        foo <foo@test.com>
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     added c e
-  
--- a/tests/test-evolve-content-divergent-basic.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-evolve-content-divergent-basic.t	Thu Apr 11 22:13:55 2019 +0200
@@ -43,6 +43,21 @@
   $ hg ci -Aqm "added a"
   $ echo b > b
   $ hg ci -Aqm "added b"
+  $ hg export
+  # HG changeset patch
+  # User test
+  # Date 0 0
+  #      Thu Jan 01 00:00:00 1970 +0000
+  # Node ID 5f6d8a4bf34ab274ccc9f631c2536964b8a3666d
+  # Parent  9092f1db7931481f93b37d5c9fbcfc341bcd7318
+  added b
+  
+  diff --git a/b b/b
+  new file mode 100644
+  --- /dev/null
+  +++ b/b
+  @@ -0,0 +1,1 @@
+  +b
 
   $ hg up .^
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
@@ -50,6 +65,21 @@
   $ hg ci -Am "divergent"
   adding bdivergent1
   created new head
+  $ hg export
+  # HG changeset patch
+  # User test
+  # Date 0 0
+  #      Thu Jan 01 00:00:00 1970 +0000
+  # Node ID 593c57f2117e33dd0884382f02789d948f548557
+  # Parent  9092f1db7931481f93b37d5c9fbcfc341bcd7318
+  divergent
+  
+  diff --git a/bdivergent1 b/bdivergent1
+  new file mode 100644
+  --- /dev/null
+  +++ b/bdivergent1
+  @@ -0,0 +1,1 @@
+  +bdivergent
 
   $ hg up .^
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
@@ -57,6 +87,21 @@
   $ hg ci -Am "divergent"
   adding bdivergent2
   created new head
+  $ hg export
+  # HG changeset patch
+  # User test
+  # Date 0 0
+  #      Thu Jan 01 00:00:00 1970 +0000
+  # Node ID 8374d2ddc3a4d48428c3d2f80e4fc86f13736f96
+  # Parent  9092f1db7931481f93b37d5c9fbcfc341bcd7318
+  divergent
+  
+  diff --git a/bdivergent2 b/bdivergent2
+  new file mode 100644
+  --- /dev/null
+  +++ b/bdivergent2
+  @@ -0,0 +1,1 @@
+  +bdivergent
 
   $ hg prune -s 8374d2ddc3a4 "desc('added b')"
   1 changesets pruned
@@ -64,12 +109,30 @@
   1 changesets pruned
   2 new content-divergent changesets
 
-  $ hg log -G
+  $ hg log -G --patch
   @  3:8374d2ddc3a4@default(draft) divergent [content-divergent]
+  |  diff --git a/bdivergent2 b/bdivergent2
+  |  new file mode 100644
+  |  --- /dev/null
+  |  +++ b/bdivergent2
+  |  @@ -0,0 +1,1 @@
+  |  +bdivergent
   |
   | *  2:593c57f2117e@default(draft) divergent [content-divergent]
-  |/
+  |/   diff --git a/bdivergent1 b/bdivergent1
+  |    new file mode 100644
+  |    --- /dev/null
+  |    +++ b/bdivergent1
+  |    @@ -0,0 +1,1 @@
+  |    +bdivergent
+  |
   o  0:9092f1db7931@default(draft) added a []
+     diff --git a/a b/a
+     new file mode 100644
+     --- /dev/null
+     +++ b/a
+     @@ -0,0 +1,1 @@
+     +a
   
 
   $ hg evolve --all --any --content-divergent
@@ -85,6 +148,27 @@
   |
   o  0:9092f1db7931@default(draft) added a []
   
+  $ hg export
+  # HG changeset patch
+  # User test
+  # Date 0 0
+  #      Thu Jan 01 00:00:00 1970 +0000
+  # Node ID 45bf1312f45468b76158b33f8426e6530c8b35b1
+  # Parent  9092f1db7931481f93b37d5c9fbcfc341bcd7318
+  divergent
+  
+  diff --git a/bdivergent1 b/bdivergent1
+  new file mode 100644
+  --- /dev/null
+  +++ b/bdivergent1
+  @@ -0,0 +1,1 @@
+  +bdivergent
+  diff --git a/bdivergent2 b/bdivergent2
+  new file mode 100644
+  --- /dev/null
+  +++ b/bdivergent2
+  @@ -0,0 +1,1 @@
+  +bdivergent
 
   $ cd ..
 
@@ -368,8 +452,9 @@
 
   $ cd ..
 
-Stabilize divergent changesets with same parent
-===============================================
+Stabilize content-divergent changesets with same parent
+=======================================================
+
 
   $ glog() {
   >   hg log -G --template \
@@ -487,8 +572,9 @@
   +conflict
   +babar
 
-Check conflict during divergence resolution
--------------------------------------------------
+Check conflict during content-divergence resolution
+---------------------------------------------------
+
 
   $ hg up --hidden 'min(desc("More addition"))'
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -499,7 +585,9 @@
   $ echo 'gotta break' >> a
   $ hg amend
   2 new content-divergent changesets
+
 # reamend so that the case is not the first precursor.
+
   $ hg amend -m "More addition (2)"
   $ hg phase 'contentdivergent()'
   4: draft
@@ -576,3 +664,469 @@
   +conflict
   +babar
   $ cd ..
+
+Check case where one side undo some of the common predecessors change
+---------------------------------------------------------------------
+
+The goal is to make sure we merge using the right base.
+
+  $ hg init predecessors-as-merge-base
+  $ cd predecessors-as-merge-base
+  $ cat << EOF > numbers
+  > 1
+  > 2
+  > 3
+  > 4
+  > 5
+  > 6
+  > 7
+  > 8
+  > 9
+  > EOF
+  $ cat << EOF > letters
+  > a
+  > b
+  > c
+  > d
+  > e
+  > f
+  > g
+  > h
+  > i
+  > EOF
+  $ cat << EOF > romans
+  > I
+  > II
+  > III
+  > IV
+  > V
+  > VI
+  > VII
+  > VIII
+  > IX
+  > EOF
+  $ hg add numbers letters romans
+  $ hg commit -m root
+  $ cat << EOF > numbers
+  > 1
+  > 2
+  > 3
+  > four
+  > 5
+  > 6
+  > 7
+  > 8
+  > 9
+  > EOF
+  $ cat << EOF > letters
+  > a
+  > b
+  > c
+  > D
+  > e
+  > f
+  > g
+  > h
+  > i
+  > EOF
+  $ hg commit -m E1
+  $ cat << EOF > numbers
+  > 1
+  > 2
+  > 3
+  > 4
+  > 5
+  > 6
+  > seven
+  > 8
+  > 9
+  > EOF
+  $ cat << EOF > romans
+  > I
+  > II
+  > III
+  > IV
+  > V
+  > vi
+  > VII
+  > VIII
+  > IX
+  > EOF
+  $ hg commit --amend -m E2
+  $ hg --hidden update -r 'desc(E1)'
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  updated to hidden changeset 4a250e5bd992
+  (hidden revision '4a250e5bd992' was rewritten as: 084ae625fa51)
+  working directory parent is obsolete! (4a250e5bd992)
+  (use 'hg evolve' to update to its successor: 084ae625fa51)
+  $ cat << EOF > numbers
+  > one
+  > 2
+  > 3
+  > four
+  > 5
+  > 6
+  > 7
+  > 8
+  > 9
+  > EOF
+  $ cat << EOF > letters
+  > a
+  > b
+  > c
+  > d
+  > e
+  > f
+  > g
+  > h
+  > i
+  > EOF
+  $ cat << EOF > romans
+  > I
+  > ii
+  > III
+  > IV
+  > V
+  > VI
+  > VII
+  > VIII
+  > IX
+  > EOF
+  $ hg commit --amend -m E3
+  2 new content-divergent changesets
+  $ hg log -G --patch --hidden
+  @  3:19ed1bf64a2c@default(draft) E3 [content-divergent]
+  |  diff --git a/numbers b/numbers
+  |  --- a/numbers
+  |  +++ b/numbers
+  |  @@ -1,1 +1,1 @@
+  |  -1
+  |  +one
+  |  @@ -4,1 +4,1 @@
+  |  -4
+  |  +four
+  |  diff --git a/romans b/romans
+  |  --- a/romans
+  |  +++ b/romans
+  |  @@ -2,1 +2,1 @@
+  |  -II
+  |  +ii
+  |
+  | *  2:084ae625fa51@default(draft) E2 [content-divergent]
+  |/   diff --git a/letters b/letters
+  |    --- a/letters
+  |    +++ b/letters
+  |    @@ -4,1 +4,1 @@
+  |    -d
+  |    +D
+  |    diff --git a/numbers b/numbers
+  |    --- a/numbers
+  |    +++ b/numbers
+  |    @@ -7,1 +7,1 @@
+  |    -7
+  |    +seven
+  |    diff --git a/romans b/romans
+  |    --- a/romans
+  |    +++ b/romans
+  |    @@ -6,1 +6,1 @@
+  |    -VI
+  |    +vi
+  |
+  | x  1:4a250e5bd992@default(draft) E1 []
+  |/   diff --git a/letters b/letters
+  |    --- a/letters
+  |    +++ b/letters
+  |    @@ -4,1 +4,1 @@
+  |    -d
+  |    +D
+  |    diff --git a/numbers b/numbers
+  |    --- a/numbers
+  |    +++ b/numbers
+  |    @@ -4,1 +4,1 @@
+  |    -4
+  |    +four
+  |
+  o  0:6d1fdf6de7e2@default(draft) root []
+     diff --git a/letters b/letters
+     new file mode 100644
+     --- /dev/null
+     +++ b/letters
+     @@ -0,0 +1,9 @@
+     +a
+     +b
+     +c
+     +d
+     +e
+     +f
+     +g
+     +h
+     +i
+     diff --git a/numbers b/numbers
+     new file mode 100644
+     --- /dev/null
+     +++ b/numbers
+     @@ -0,0 +1,9 @@
+     +1
+     +2
+     +3
+     +4
+     +5
+     +6
+     +7
+     +8
+     +9
+     diff --git a/romans b/romans
+     new file mode 100644
+     --- /dev/null
+     +++ b/romans
+     @@ -0,0 +1,9 @@
+     +I
+     +II
+     +III
+     +IV
+     +V
+     +VI
+     +VII
+     +VIII
+     +IX
+  
+  $ hg evolve --list
+  084ae625fa51: E2
+    content-divergent: 19ed1bf64a2c (draft) (precursor 4a250e5bd992)
+  
+  19ed1bf64a2c: E3
+    content-divergent: 084ae625fa51 (draft) (precursor 4a250e5bd992)
+  
+  $ hg obslog --all --patch
+  *  084ae625fa51 (2) E2
+  |
+  | @  19ed1bf64a2c (3) E3
+  |/
+  x  4a250e5bd992 (1) E1
+       rewritten(description, content) as 084ae625fa51 using amend by test (Thu Jan 01 00:00:00 1970 +0000)
+         diff -r 4a250e5bd992 -r 084ae625fa51 changeset-description
+         --- a/changeset-description
+         +++ b/changeset-description
+         @@ -1,1 +1,1 @@
+         -E1
+         +E2
+  
+         diff --git a/numbers b/numbers
+         --- a/numbers
+         +++ b/numbers
+         @@ -4,1 +4,1 @@
+         -four
+         +4
+         @@ -7,1 +7,1 @@
+         -7
+         +seven
+         diff --git a/romans b/romans
+         --- a/romans
+         +++ b/romans
+         @@ -6,1 +6,1 @@
+         -VI
+         +vi
+  
+       rewritten(description, content) as 19ed1bf64a2c using amend by test (Thu Jan 01 00:00:00 1970 +0000)
+         diff -r 4a250e5bd992 -r 19ed1bf64a2c changeset-description
+         --- a/changeset-description
+         +++ b/changeset-description
+         @@ -1,1 +1,1 @@
+         -E1
+         +E3
+  
+         diff --git a/letters b/letters
+         --- a/letters
+         +++ b/letters
+         @@ -4,1 +4,1 @@
+         -D
+         +d
+         diff --git a/numbers b/numbers
+         --- a/numbers
+         +++ b/numbers
+         @@ -1,1 +1,1 @@
+         -1
+         +one
+         diff --git a/romans b/romans
+         --- a/romans
+         +++ b/romans
+         @@ -2,1 +2,1 @@
+         -II
+         +ii
+  
+  
+
+  $ hg evolve --content-divergent --rev 'desc("E3")'
+  merge:[2] E2
+  with: [3] E3
+  base: [1] E1
+  updating to "local" side of the conflict: 084ae625fa51
+  merging "other" content-divergent changeset '19ed1bf64a2c'
+  merging numbers
+  merging romans
+  1 files updated, 2 files merged, 0 files removed, 0 files unresolved
+  working directory is now at aae293050980
+  $ hg status
+  $ hg amend -m 'E4'
+  $ hg export
+  # HG changeset patch
+  # User test
+  # Date 0 0
+  #      Thu Jan 01 00:00:00 1970 +0000
+  # Node ID 8c2a6aae4bc5c1cc00c68276017dcef3d468e895
+  # Parent  6d1fdf6de7e2d9fc9b098aa286b60785bbeaab7a
+  E4
+  
+  diff --git a/numbers b/numbers
+  --- a/numbers
+  +++ b/numbers
+  @@ -1,1 +1,1 @@
+  -1
+  +one
+  @@ -7,1 +7,1 @@
+  -7
+  +seven
+  diff --git a/romans b/romans
+  --- a/romans
+  +++ b/romans
+  @@ -2,1 +2,1 @@
+  -II
+  +ii
+  @@ -6,1 +6,1 @@
+  -VI
+  +vi
+  $ hg log -G
+  @  5:8c2a6aae4bc5@default(draft) E4 []
+  |
+  o  0:6d1fdf6de7e2@default(draft) root []
+  
+  $ hg obslog --patch
+  @  8c2a6aae4bc5 (5) E4
+  |
+  x    aae293050980 (4) <<<<<<< divergent
+  |\     rewritten(description) as 8c2a6aae4bc5 using amend by test (Thu Jan 01 00:00:00 1970 +0000)
+  | |      diff -r aae293050980 -r 8c2a6aae4bc5 changeset-description
+  | |      --- a/changeset-description
+  | |      +++ b/changeset-description
+  | |      @@ -1,4 +1,1 @@
+  | |      -<<<<<<< divergent
+  | |      -E2||||||| base
+  | |      -E1=======
+  | |      -E3>>>>>>> other
+  | |      +E4
+  | |
+  | |
+  x |  084ae625fa51 (2) E2
+  | |    rewritten(description, content) as aae293050980 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+  | |      diff -r 084ae625fa51 -r aae293050980 changeset-description
+  | |      --- a/changeset-description
+  | |      +++ b/changeset-description
+  | |      @@ -1,1 +1,4 @@
+  | |      -E2
+  | |      +<<<<<<< divergent
+  | |      +E2||||||| base
+  | |      +E1=======
+  | |      +E3>>>>>>> other
+  | |
+  | |      diff --git a/letters b/letters
+  | |      --- a/letters
+  | |      +++ b/letters
+  | |      @@ -4,1 +4,1 @@
+  | |      -D
+  | |      +d
+  | |      diff --git a/numbers b/numbers
+  | |      --- a/numbers
+  | |      +++ b/numbers
+  | |      @@ -1,1 +1,1 @@
+  | |      -1
+  | |      +one
+  | |      diff --git a/romans b/romans
+  | |      --- a/romans
+  | |      +++ b/romans
+  | |      @@ -2,1 +2,1 @@
+  | |      -II
+  | |      +ii
+  | |
+  | |
+  | x  19ed1bf64a2c (3) E3
+  |/     rewritten(description, content) as aae293050980 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+  |        diff -r 19ed1bf64a2c -r aae293050980 changeset-description
+  |        --- a/changeset-description
+  |        +++ b/changeset-description
+  |        @@ -1,1 +1,4 @@
+  |        -E3
+  |        +<<<<<<< divergent
+  |        +E2||||||| base
+  |        +E1=======
+  |        +E3>>>>>>> other
+  |
+  |        diff --git a/numbers b/numbers
+  |        --- a/numbers
+  |        +++ b/numbers
+  |        @@ -4,1 +4,1 @@
+  |        -four
+  |        +4
+  |        @@ -7,1 +7,1 @@
+  |        -7
+  |        +seven
+  |        diff --git a/romans b/romans
+  |        --- a/romans
+  |        +++ b/romans
+  |        @@ -6,1 +6,1 @@
+  |        -VI
+  |        +vi
+  |
+  |
+  x  4a250e5bd992 (1) E1
+       rewritten(description, content) as 084ae625fa51 using amend by test (Thu Jan 01 00:00:00 1970 +0000)
+         diff -r 4a250e5bd992 -r 084ae625fa51 changeset-description
+         --- a/changeset-description
+         +++ b/changeset-description
+         @@ -1,1 +1,1 @@
+         -E1
+         +E2
+  
+         diff --git a/numbers b/numbers
+         --- a/numbers
+         +++ b/numbers
+         @@ -4,1 +4,1 @@
+         -four
+         +4
+         @@ -7,1 +7,1 @@
+         -7
+         +seven
+         diff --git a/romans b/romans
+         --- a/romans
+         +++ b/romans
+         @@ -6,1 +6,1 @@
+         -VI
+         +vi
+  
+       rewritten(description, content) as 19ed1bf64a2c using amend by test (Thu Jan 01 00:00:00 1970 +0000)
+         diff -r 4a250e5bd992 -r 19ed1bf64a2c changeset-description
+         --- a/changeset-description
+         +++ b/changeset-description
+         @@ -1,1 +1,1 @@
+         -E1
+         +E3
+  
+         diff --git a/letters b/letters
+         --- a/letters
+         +++ b/letters
+         @@ -4,1 +4,1 @@
+         -D
+         +d
+         diff --git a/numbers b/numbers
+         --- a/numbers
+         +++ b/numbers
+         @@ -1,1 +1,1 @@
+         -1
+         +one
+         diff --git a/romans b/romans
+         --- a/romans
+         +++ b/romans
+         @@ -2,1 +2,1 @@
+         -II
+         +ii
+  
+  
--- a/tests/test-evolve-content-divergent-corner-cases.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-evolve-content-divergent-corner-cases.t	Thu Apr 11 22:13:55 2019 +0200
@@ -319,3 +319,67 @@
   ~
 
   $ cd ..
+
+Check that canceling of file deletion are merge correctly
+---------------------------------------------------------
+
+File addition/deletion tend to have special processing. So we better test them directory
+
+  $ hg init non-public
+  $ cd non-public
+  $ echo a > a
+  $ echo b > b
+  $ echo c > c
+  $ echo d > d
+  $ hg ci -Aqm initial
+
+oops, we meant to delete just 'a', but we deleted 'b' and 'c' too
+
+  $ hg rm a b c
+  $ hg ci -m 'delete a'
+  $ hg revert -r .^ b
+  $ hg amend
+
+create some content divergence
+
+  $ hg co dff6e52f5e41 --hidden
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  updated to hidden changeset dff6e52f5e41
+  (hidden revision 'dff6e52f5e41' was rewritten as: 0825dcee2670)
+  working directory parent is obsolete! (dff6e52f5e41)
+  (use 'hg evolve' to update to its successor: 0825dcee2670)
+  $ hg revert -r .^ c
+  $ hg amend
+  2 new content-divergent changesets
+  $ hg glog --hidden
+  @  3:92ecd58f9b05 delete a
+  |   () [default] draft
+  | *  2:0825dcee2670 delete a
+  |/    () [default] draft
+  | x  1:dff6e52f5e41 delete a
+  |/    () [default] draft
+  o  0:75d2b02c4a5c initial
+      () [default] draft
+
+Resolve the divergence, only "a" should be removed
+
+  $ hg evolve --content-divergent
+  merge:[3] delete a
+  with: [2] delete a
+  base: [1] delete a
+  merging "other" content-divergent changeset '0825dcee2670'
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  working directory is now at 7ca6a9fafcf6
+  $ hg glog
+  @  4:7ca6a9fafcf6 delete a
+  |   () [default] draft
+  o  0:75d2b02c4a5c initial
+      () [default] draft
+
+  $ hg diff --change .
+  diff --git a/a b/a
+  deleted file mode 100644
+  --- a/a
+  +++ /dev/null
+  @@ -1,1 +0,0 @@
+  -a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-evolve-content-divergent-meta.t	Thu Apr 11 22:13:55 2019 +0200
@@ -0,0 +1,102 @@
++====================================================
++Tests the resolution of content divergence: metadata
++====================================================
+
+This file intend to cover cases focused around meta data merging.
+
+Setup
+-----
+
+  $ cat >> $HGRCPATH <<EOF
+  > [alias]
+  > glog = log -GT "{rev}:{node|short} {desc|firstline}\n {phase} {troubles}\n\n"
+  > [phases]
+  > publish = False
+  > [extensions]
+  > rebase =
+  > EOF
+  $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
+
+Check we preserve the author properly
+-------------------------------------
+
+Testing issue6113 to make sure that content-divergence resolution don't
+replace initial author with the user running the resolution command:
+
+  $ hg init userfoo
+  $ cd userfoo
+  $ unset HGUSER
+  $ echo "[ui]" >> ./.hg/hgrc
+  $ echo "username = foo <foo@test.com>" >> ./.hg/hgrc
+  $ for ch in a b c; do
+  > echo $ch > $ch;
+  > hg add $ch;
+  > hg ci -m "added "$ch;
+  > done;
+
+  $ cd ..
+  $ hg init userbar
+  $ cd userbar
+  $ unset HGUSER
+  $ echo "[ui]" >> ./.hg/hgrc
+  $ echo "username = bar <bar@test.com>" >> ./.hg/hgrc
+  $ hg pull ./../userfoo -q
+
+  $ cd ../userfoo
+  $ hg up -r "desc('added b')"
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo c > c
+  $ echo e > e
+  $ hg add c e
+  $ hg ci -m "added c e"
+  created new head
+
+  $ hg up -r "desc('added b')"
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ echo cc > c
+  $ hg add c
+  $ hg ci -m "added c"
+  created new head
+
+  $ hg prune -r "min(desc('added c'))" -s "desc('added c e')"
+  1 changesets pruned
+  $ hg prune -r "min(desc('added c'))" -s "max(desc('added c'))" --hidden
+  1 changesets pruned
+  2 new content-divergent changesets
+
+  $ hg glog
+  @  4:6c06cda6dc99 added c
+  |   draft content-divergent
+  |
+  | *  3:0c9267e23c9d added c e
+  |/    draft content-divergent
+  |
+  o  1:1740ad2a1eda added b
+  |   draft
+  |
+  o  0:f863f39764c4 added a
+      draft
+  
+
+  $ cd ../userbar
+  $ hg pull ./../userfoo -q
+  2 new content-divergent changesets
+
+  $ hg evolve --content-divergent --any
+  merge:[3] added c e
+  with: [4] added c
+  base: [2] added c
+  updating to "local" side of the conflict: 0c9267e23c9d
+  merging "other" content-divergent changeset '6c06cda6dc99'
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  working directory is now at 443bd2972210
+
+Make sure resultant cset don't replace the initial user with user running the command:
+  $ hg log -r tip
+  changeset:   5:443bd2972210
+  tag:         tip
+  parent:      1:1740ad2a1eda
+  user:        foo <foo@test.com>
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     added c e
+  
--- a/tests/test-evolve-content-divergent-relocation.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-evolve-content-divergent-relocation.t	Thu Apr 11 22:13:55 2019 +0200
@@ -326,7 +326,7 @@
   @@ -0,0 +1,1 @@
   +bar
 
-Testing when the relocation will result in conflicts and merging wont
+Testing when the relocation will result in conflicts and merging also:
 ----------------------------------------------------------------------
 
   $ hg glog
@@ -391,7 +391,7 @@
   o  0:8fa14d15e168 added hgignore
       () [default] draft
 
-  $ hg evolve --content-divergent
+  $ hg evolve --content-divergent --any
   merge:[25] added z
   with: [23] added z
   base: [22] added z
--- a/tests/test-evolve-content-divergent-stack.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-evolve-content-divergent-stack.t	Thu Apr 11 22:13:55 2019 +0200
@@ -180,3 +180,187 @@
   |   () [default] draft
   o  0:8fa14d15e168 added hgignore
       () [default] draft
+Resolving content-divergence of a stack with different parents
+---------------------------------------------------------
+
+  $ cd ..
+  $ hg init stackrepo1
+  $ cd stackrepo1
+  $ echo ".*\.orig" > .hgignore
+  $ hg add .hgignore
+  $ hg ci -m "added hgignore"
+
+  $ for ch in a b c d;
+  > do echo foo > $ch;
+  > hg add $ch;
+  > hg ci -qm "added "$ch;
+  > done;
+
+  $ hg glog
+  @  4:c41c793e0ef1 added d
+  |   () [default] draft
+  o  3:ca1b80f7960a added c
+  |   () [default] draft
+  o  2:b1661037fa25 added b
+  |   () [default] draft
+  o  1:c7586e2a9264 added a
+  |   () [default] draft
+  o  0:8fa14d15e168 added hgignore
+      () [default] draft
+
+  $ cd ..
+  $ hg init stackrepo2
+  $ cd stackrepo2
+  $ hg pull ../stackrepo1
+  pulling from ../stackrepo1
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 5 changesets with 5 changes to 5 files
+  new changesets 8fa14d15e168:c41c793e0ef1 (5 drafts)
+  (run 'hg update' to get a working copy)
+
+  $ hg glog
+  o  4:c41c793e0ef1 added d
+  |   () [default] draft
+  o  3:ca1b80f7960a added c
+  |   () [default] draft
+  o  2:b1661037fa25 added b
+  |   () [default] draft
+  o  1:c7586e2a9264 added a
+  |   () [default] draft
+  o  0:8fa14d15e168 added hgignore
+      () [default] draft
+
+  $ hg up 8fa14d15e168
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo newfile > newfile
+  $ hg ci -Am "add newfile"
+  adding newfile
+  created new head
+  $ hg rebase -s c7586e2a9264 -d .
+  rebasing 1:c7586e2a9264 "added a"
+  rebasing 2:b1661037fa25 "added b"
+  rebasing 3:ca1b80f7960a "added c"
+  rebasing 4:c41c793e0ef1 "added d"
+
+  $ hg glog
+  o  9:d45f050514c2 added d
+  |   () [default] draft
+  o  8:8ed612937375 added c
+  |   () [default] draft
+  o  7:6eb54b5af3fb added b
+  |   () [default] draft
+  o  6:c04ff147ef79 added a
+  |   () [default] draft
+  @  5:2228e3b74514 add newfile
+  |   () [default] draft
+  o  0:8fa14d15e168 added hgignore
+      () [default] draft
+
+  $ cd ../stackrepo1
+  $ hg up .^^^
+  0 files updated, 0 files merged, 3 files removed, 0 files unresolved
+  $ echo wat > a
+  $ hg amend -m "watbar to a"
+  3 new orphan changesets
+  $ hg evolve --all
+  move:[2] added b
+  atop:[5] watbar to a
+  move:[3] added c
+  move:[4] added d
+  working directory is now at c72d2885eb51
+
+  $ hg glog
+  @  8:c72d2885eb51 added d
+  |   () [default] draft
+  o  7:3ce4be6d8e5e added c
+  |   () [default] draft
+  o  6:d5f148423c16 added b
+  |   () [default] draft
+  o  5:8e222f257bbf watbar to a
+  |   () [default] draft
+  o  0:8fa14d15e168 added hgignore
+      () [default] draft
+
+  $ hg pull ../stackrepo2
+  pulling from ../stackrepo2
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 5 changesets with 1 changes to 5 files (+1 heads)
+  4 new obsolescence markers
+  8 new content-divergent changesets
+  new changesets 2228e3b74514:d45f050514c2 (5 drafts)
+  (run 'hg heads' to see heads, 'hg merge' to merge)
+
+  $ hg glog
+  *  13:d45f050514c2 added d
+  |   () [default] draft
+  *  12:8ed612937375 added c
+  |   () [default] draft
+  *  11:6eb54b5af3fb added b
+  |   () [default] draft
+  *  10:c04ff147ef79 added a
+  |   () [default] draft
+  o  9:2228e3b74514 add newfile
+  |   () [default] draft
+  | @  8:c72d2885eb51 added d
+  | |   () [default] draft
+  | *  7:3ce4be6d8e5e added c
+  | |   () [default] draft
+  | *  6:d5f148423c16 added b
+  | |   () [default] draft
+  | *  5:8e222f257bbf watbar to a
+  |/    () [default] draft
+  o  0:8fa14d15e168 added hgignore
+      () [default] draft
+
+  $ hg evolve --all --content-divergent
+  merge:[10] added a
+  with: [5] watbar to a
+  base: [1] added a
+  rebasing "other" content-divergent changeset 8e222f257bbf on 2228e3b74514
+  updating to "local" side of the conflict: c04ff147ef79
+  merging "other" content-divergent changeset '186bdc2cdfa2'
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  6 new orphan changesets
+  merge:[11] added b
+  with: [6] added b
+  base: [2] added b
+  rebasing "other" content-divergent changeset d5f148423c16 on c04ff147ef79
+  updating to "local" side of the conflict: 6eb54b5af3fb
+  merging "other" content-divergent changeset '8542f15656e7'
+  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 "other" content-divergent changeset 3ce4be6d8e5e on 6eb54b5af3fb
+  updating to "local" side of the conflict: 8ed612937375
+  merging "other" content-divergent changeset 'a690ce53104a'
+  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 "other" content-divergent changeset c72d2885eb51 on 8ed612937375
+  updating to "local" side of the conflict: d45f050514c2
+  merging "other" content-divergent changeset '1d1772990a3b'
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  working directory is now at 5f7a38bdb75c
+
+  $ hg glog
+  @  21:5f7a38bdb75c added d
+  |   () [default] draft
+  o  19:9865d598f0e0 added c
+  |   () [default] draft
+  o  17:ac70b8c8eb63 added b
+  |   () [default] draft
+  o  15:74fbf3e6a0b6 watbar to a
+  |   () [default] draft
+  o  9:2228e3b74514 add newfile
+  |   () [default] draft
+  o  0:8fa14d15e168 added hgignore
+      () [default] draft
+  $ cd ..
--- a/tests/test-evolve-continue.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-evolve-continue.t	Thu Apr 11 22:13:55 2019 +0200
@@ -127,6 +127,7 @@
   $ hg evolve --continue
   evolving 7:ad0a59d83efe "added e"
   evolution of 7:ad0a59d83efe created no changes to commit
+  working directory is now at 00a5c774cc37
 
   $ hg glog
   @  8:00a5c774cc37 added d
--- a/tests/test-evolve-issue5832.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-evolve-issue5832.t	Thu Apr 11 22:13:55 2019 +0200
@@ -112,17 +112,17 @@
 Resolving instability using `hg evolve`
 
   $ hg evolve --any --all --config ui.interactive=True <<EOF
-  > 0
+  > 1
   > EOF
   move:[2] added b
   atop:[5] added a
   move:[4] merge commit
   ancestor '7235ef625ea3' split over multiple topological branches.
   choose an evolve destination:
-  0: [62fb70414f99] added c
-  1: [5841d7cf9893] added d
+  1: [62fb70414f99] added c
+  2: [5841d7cf9893] added d
   q: quit the prompt
-  enter the index of the revision you want to select: 0
+  enter the index of the revision you want to select: 1
   move:[9] merge commit
   atop:[6] added c
   working directory is now at 28a0775ac832
@@ -253,17 +253,17 @@
   could not solve instability, ambiguous destination: parent split across two branches
 
   $ hg evolve --any --all --config ui.interactive=True <<EOF
-  > 1
+  > 2
   > EOF
   move:[2] added b
   atop:[6] added a
   move:[4] merge commit
   ancestor 'cdf2ea1b9312' split over multiple topological branches.
   choose an evolve destination:
-  0: [62fb70414f99] added c
-  1: [5841d7cf9893] added d
+  1: [62fb70414f99] added c
+  2: [5841d7cf9893] added d
   q: quit the prompt
-  enter the index of the revision you want to select: 1
+  enter the index of the revision you want to select: 2
   move:[10] merge commit
   atop:[8] added d
   working directory is now at 460e6e72b7f9
@@ -398,16 +398,16 @@
   could not solve instability, ambiguous destination: parent split across two branches
 
   $ hg evolve --any --all --config ui.interactive=True <<EOF
-  > 1
+  > 2
   > EOF
   move:[2] added b
   atop:[6] added a
   ancestor 'b9b387427a53' split over multiple topological branches.
   choose an evolve destination:
-  0: [62fb70414f99] added c
-  1: [5841d7cf9893] added d
+  1: [62fb70414f99] added c
+  2: [5841d7cf9893] added d
   q: quit the prompt
-  enter the index of the revision you want to select: 1
+  enter the index of the revision you want to select: 2
   move:[4] merge commit
   atop:[8] added d
   move:[10] merge commit
--- a/tests/test-evolve-list.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-evolve-list.t	Thu Apr 11 22:13:55 2019 +0200
@@ -5,7 +5,7 @@
   > EOF
   $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
 
-Test the instability listing
+Test listing orphan changesets
   $ hg init r2
   $ cd r2
   $ echo a > a && hg ci -Am a
@@ -27,7 +27,7 @@
   
   $ cd ..
 
-Test the bumpedness listing
+Test listing phase-divergent changesets
   $ hg init r3
   $ cd r3
   $ echo a > a && hg ci -Am a
@@ -41,7 +41,7 @@
   
   $ cd ..
 
-Test the divergence listing
+Test listing content-divergent changesets
   $ hg init r1
   $ cd r1
   $ echo a > a && hg ci -Am a
--- a/tests/test-evolve-obshistory-lots-of-splits.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-evolve-obshistory-lots-of-splits.t	Thu Apr 11 22:13:55 2019 +0200
@@ -6,8 +6,8 @@
 
   $ . $TESTDIR/testlib/obshistory_setup.sh
 
-Test output with lots of splitted commit
-========================================
+Test output with lots of split commit
+=====================================
 
 Test setup
 ----------
--- a/tests/test-evolve-obshistory-split.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-evolve-obshistory-split.t	Thu Apr 11 22:13:55 2019 +0200
@@ -6,8 +6,8 @@
 
   $ . $TESTDIR/testlib/obshistory_setup.sh
 
-Test output with splitted commit
-================================
+Test output with split commit
+=============================
 
 Test setup
 ----------
@@ -98,7 +98,7 @@
 Check output on the client side
 -------------------------------
 
-Check that debugobshistory on splitted commit show both targets
+Check that debugobshistory on split commit show both targets
   $ hg obslog 471597cad322 --hidden --patch
   x  471597cad322 (1) A0
        rewritten(parent, content) as 337fec4d2edc, f257fde29c7a using split by test (Thu Jan 01 00:00:00 1970 +0000)
@@ -134,7 +134,7 @@
       }
   ]
 Check that debugobshistory on the first successor after split show
-the revision plus the splitted one
+the revision plus the split one
   $ hg obslog 337fec4d2edc --patch
   o  337fec4d2edc (2) A0
   |
@@ -155,7 +155,7 @@
          (No patch available, too many successors (2))
   
 Check that debugobshistory on the second successor after split show
-the revision plus the splitted one
+the revision plus the split one
   $ hg obslog f257fde29c7a --patch
   @  f257fde29c7a (3) A0
   |
@@ -175,7 +175,7 @@
          note: testing split
          (No patch available, too many successors (2))
   
-Obslog with all option all should also works on the splitted commit
+Obslog with all option all should also works on the split commit
   $ hg obslog -a 471597cad322 --hidden --patch
   o  337fec4d2edc (2) A0
   |
--- a/tests/test-evolve-order.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-evolve-order.t	Thu Apr 11 22:13:55 2019 +0200
@@ -231,8 +231,8 @@
   |
   ~
 
-Test multiple revision with some un-evolvable because parent is splitted
-------------------------------------------------------------------------
+Test multiple revision with some un-evolvable because parent is split
+---------------------------------------------------------------------
 
   $ hg up 'desc(c2prime)'
   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
--- a/tests/test-evolve-orphan-split.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-evolve-orphan-split.t	Thu Apr 11 22:13:55 2019 +0200
@@ -19,8 +19,8 @@
   $ hg add .hgignore
   $ hg ci -m "added hgignore"
 
-An orphan changeset with parent got splitted
---------------------------------------------
+An orphan changeset with parent got split
+-----------------------------------------
 
   $ for ch in a b c; do echo foo > $ch; done;
 
@@ -182,27 +182,27 @@
       () draft
 
   $ hg evolve --dry-run <<EOF
-  > 0
+  > 1
   > EOF
   ancestor 'd48a30875f01' split over multiple topological branches.
   choose an evolve destination:
-  0: [f2632392aefe] added a b c
-  1: [7f87764e5b64] added a b c
+  1: [f2632392aefe] added a b c
+  2: [7f87764e5b64] added a b c
   q: quit the prompt
-  enter the index of the revision you want to select: 0
+  enter the index of the revision you want to select: 1
   move:[7] added d
   atop:[8] added a b c
   hg rebase -r d48a30875f01 -d f2632392aefe
 
   $ hg evolve --dry-run <<EOF
-  > 1
+  > 2
   > EOF
   ancestor 'd48a30875f01' split over multiple topological branches.
   choose an evolve destination:
-  0: [f2632392aefe] added a b c
-  1: [7f87764e5b64] added a b c
+  1: [f2632392aefe] added a b c
+  2: [7f87764e5b64] added a b c
   q: quit the prompt
-  enter the index of the revision you want to select: 1
+  enter the index of the revision you want to select: 2
   move:[7] added d
   atop:[10] added a b c
   hg rebase -r d48a30875f01 -d 7f87764e5b64
@@ -215,8 +215,8 @@
   > EOF
   ancestor 'd48a30875f01' split over multiple topological branches.
   choose an evolve destination:
-  0: [f2632392aefe] added a b c
-  1: [7f87764e5b64] added a b c
+  1: [f2632392aefe] added a b c
+  2: [7f87764e5b64] added a b c
   q: quit the prompt
   enter the index of the revision you want to select: foo
   invalid value 'foo' entered for index
@@ -227,8 +227,8 @@
   > EOF
   ancestor 'd48a30875f01' split over multiple topological branches.
   choose an evolve destination:
-  0: [f2632392aefe] added a b c
-  1: [7f87764e5b64] added a b c
+  1: [f2632392aefe] added a b c
+  2: [7f87764e5b64] added a b c
   q: quit the prompt
   enter the index of the revision you want to select: 4
   invalid value '4' entered for index
@@ -239,8 +239,8 @@
   > EOF
   ancestor 'd48a30875f01' split over multiple topological branches.
   choose an evolve destination:
-  0: [f2632392aefe] added a b c
-  1: [7f87764e5b64] added a b c
+  1: [f2632392aefe] added a b c
+  2: [7f87764e5b64] added a b c
   q: quit the prompt
   enter the index of the revision you want to select: -1
   invalid value '-1' entered for index
@@ -251,8 +251,8 @@
   > EOF
   ancestor 'd48a30875f01' split over multiple topological branches.
   choose an evolve destination:
-  0: [f2632392aefe] added a b c
-  1: [7f87764e5b64] added a b c
+  1: [f2632392aefe] added a b c
+  2: [7f87764e5b64] added a b c
   q: quit the prompt
   enter the index of the revision you want to select: q
   could not solve instability, ambiguous destination: parent split across two branches
@@ -264,10 +264,10 @@
   > EOF
   ancestor 'd48a30875f01' split over multiple topological branches.
   choose an evolve destination:
-  0: [f2632392aefe] added a b c
-  1: [7f87764e5b64] added a b c
+  1: [f2632392aefe] added a b c
+  2: [7f87764e5b64] added a b c
   q: quit the prompt
   enter the index of the revision you want to select: 1
   move:[7] added d
-  atop:[10] added a b c
-  working directory is now at 1c6caa7c902a
+  atop:[8] added a b c
+  working directory is now at 71e4d45a7aaa
--- a/tests/test-evolve-phase-divergence.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-evolve-phase-divergence.t	Thu Apr 11 22:13:55 2019 +0200
@@ -32,7 +32,9 @@
 Setting up a private non-publishing repo
 ----------------------------------------
 
-  $ hg clone -U public private
+  $ hg clone public private
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ cd private
   $ cat >> .hg/hgrc <<EOF
   > [ui]
@@ -47,6 +49,13 @@
 
   $ cp -a private alice
   $ cp -a private bob
+  $ cp -a private split
+  $ cp -a private split-across-branches
+  $ cp -a private split-and-amend
+  $ cp -a private merge-no-conflict
+
+Simple phase-divergence case
+============================
 
 Creating a phase-divergence changeset
 -------------------------------------
@@ -54,8 +63,6 @@
 Alice creating a draft changeset and pushing to main private repo
 
   $ cd alice
-  $ hg update
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ echo a >> a
   $ hg commit -u alice -m 'modify a'
   $ hg push ../private
@@ -88,7 +95,7 @@
   $ hg glog
   o  1:4d1169d82e47 modify a
   |   () draft
-  o  0:d3873e73d99e init
+  @  0:d3873e73d99e init
       () public
 
   $ hg push ../public
@@ -102,7 +109,7 @@
   $ hg glog
   o  1:4d1169d82e47 modify a
   |   () public
-  o  0:d3873e73d99e init
+  @  0:d3873e73d99e init
       () public
 
 *But* Alice decided to amend the changeset she had and then pulling from public
@@ -195,8 +202,7 @@
   $ hg evolve --phase-divergent
   recreate:[2] tweak a
   atop:[1] modify a
-  computing new diff
-  committed as 4d1169d82e47
+  no changes to commit
   working directory is now at 4d1169d82e47
 
   $ hg glog
@@ -227,9 +233,11 @@
   2 new obsolescence markers
   [1]
 
+phase-divergence that lead to new commit and bookmark movement
+==============================================================
+
 Creating more phase-divergence where a new resolution commit will be formed and
 also testing bookmark movement
---------------------------------------------------------------------------------
 
 Alice created a commit and push to private non-publishing repo
 
@@ -310,7 +318,6 @@
   $ hg evolve --phase-divergent
   recreate:[4] added bar to foo
   atop:[3] added foo to foo
-  computing new diff
   committed as 3d62500c673d
   working directory is now at 3d62500c673d
 
@@ -388,11 +395,14 @@
   added 1 changesets with 1 changes to 1 files
   2 new obsolescence markers
 
+
+phase divergence rebasing back to old changeset - with (unrelated?) conflict
+============================================================================
+
 Creating a phasedivergence changeset where the divergent changeset changed in a
 way that we rebase that on old public changeset, there will be conflicts, but
 the `hg evolve` command handles it very well and uses `hg revert` logic to
 prevent any conflicts
--------------------------------------------------------------------------------
 
 Alice creates one more changeset and pushes to private repo
 
@@ -461,7 +471,6 @@
   $ hg evolve --phase-divergent
   recreate:[7] foo to bar
   atop:[6] added bar to bar
-  computing new diff
   committed as 502e73736632
   working directory is now at 502e73736632
 
@@ -517,9 +526,11 @@
   added 1 changesets with 1 changes to 1 files
   2 new obsolescence markers
 
+different parents for successors and predecessors
+=================================================
+
 Creating phase-divergence with divergent changeset and precursor having
 different parents
------------------------------------------------------------------------
 
 Alice creates a changeset and pushes to private repo
 
@@ -598,8 +609,7 @@
   atop:[9] added x to x
   rebasing to destination parent: 502e73736632
   (leaving bookmark bm)
-  computing new diff
-  committed as 2352021b3785
+  no changes to commit
   working directory is now at 2352021b3785
 
 XXX: we should move bookmark here
@@ -645,9 +655,11 @@
   @@ -0,0 +1,1 @@
   +x
 
-Creating divergence with parent and content change both but not resulting in
+divergence with parent+content change both, no conflict
+=======================================================
+
+Creating divergence with parent cand content change both but not resulting in
 conflicts
------------------------------------------------------------------------------
 
 Alice is tired of pushing and pulling and will create phase-divergence locally
 
@@ -717,7 +729,6 @@
   recreate:[14] y to y and foobar to foo
   atop:[12] y to y and foobar to foo
   rebasing to destination parent: 2352021b3785
-  computing new diff
   committed as 8c2bb6fb44e9
   working directory is now at 8c2bb6fb44e9
 
@@ -759,9 +770,11 @@
   o  0:d3873e73d99e init
       () public
 
+divergence with parent+content change both, with conflict
+=========================================================
+
 Creating divergence with parent and content change both which results in
 conflicts while rebasing on parent
------------------------------------------------------------------------------
 
   $ echo l > l
   $ hg ci -Aqm "added l to l"
@@ -821,7 +834,6 @@
 
   $ hg evolve --continue
   evolving 19:5fd38c0de46e "added l to l"
-  computing new diff
   committed as e3090241a10c
   working directory is now at e3090241a10c
 
@@ -918,8 +930,7 @@
   recreate:[24] added f
   atop:[23] added g
   rebasing to destination parent: 21ae52e414e6
-  computing new diff
-  committed as 428f7900a969
+  no changes to commit
   working directory is now at 428f7900a969
 
   $ hg glog -r f3794e5a91dc::
@@ -933,127 +944,141 @@
   |   () public
   ~
 
-When the public changesets is splitted causing phase-divergence
----------------------------------------------------------------
+When the public changesets is split causing phase-divergence
+------------------------------------------------------------
+
+  $ cd ../split
 
   $ echo m > m
   $ echo n > n
   $ hg ci -Aqm "added m and n"
 
-  $ hg glog -r 21ae52e414e6::
-  @  26:849cee0a874b added m and n
+  $ hg glog
+  @  1:a51bce62c219 added m and n
   |   () draft
-  o  23:428f7900a969 added g
-  |   () public
-  o  22:21ae52e414e6 added f
-  |   () public
-  ~
+  o  0:d3873e73d99e init
+      () public
 
   $ hg prev
   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
-  [23] added g
+  [0] init
   $ echo m > m
   $ hg ci -Aqm "added m"
   $ echo n > n
   $ hg ci -Aqm "added n"
 
-  $ hg glog -r 428f7900a969::
-  @  28:63ccb8ea7cae added n
+  $ hg glog
+  @  3:e1154ec0206a added n
   |   () draft
-  o  27:f313e2b90e70 added m
+  o  2:4f25cd9cd2bf added m
   |   () draft
-  | o  26:849cee0a874b added m and n
+  | o  1:a51bce62c219 added m and n
   |/    () draft
-  o  23:428f7900a969 added g
-  |   () public
-  ~
+  o  0:d3873e73d99e init
+      () public
 
-  $ hg prune -r 849cee0a874b --succ f313e2b90e70 --succ 63ccb8ea7cae --split
+  $ hg prune -r a51bce62c219 --succ 4f25cd9cd2bf --succ e1154ec0206a --split
   1 changesets pruned
 
-  $ hg phase -r 849cee0a874b --hidden --public
+  $ hg phase -r a51bce62c219 --hidden --public
   2 new phase-divergent changesets
 
-  $ hg glog -r 428f7900a969::
-  @  28:63ccb8ea7cae added n
+  $ hg glog
+  @  3:e1154ec0206a added n
   |   () draft
-  *  27:f313e2b90e70 added m
+  *  2:4f25cd9cd2bf added m
   |   () draft
-  | o  26:849cee0a874b added m and n
+  | o  1:a51bce62c219 added m and n
   |/    () public
-  o  23:428f7900a969 added g
-  |   () public
-  ~
+  o  0:d3873e73d99e init
+      () public
 
   $ hg evolve --all --phase-divergent
-  recreate:[27] added m
-  atop:[26] added m and n
-  computing new diff
-  committed as 870e1c3eddc3
+  recreate:[2] added m
+  atop:[1] added m and n
+  committed as 86419909e017
   1 new orphan changesets
-  recreate:[28] added n
-  atop:[26] added m and n
-  rebasing to destination parent: 428f7900a969
-  computing new diff
-  committed as 154b0179fb9b
-  working directory is now at 154b0179fb9b
+  recreate:[3] added n
+  atop:[1] added m and n
+  rebasing to destination parent: d3873e73d99e
+  committed as 89ba615ea1ec
+  working directory is now at 89ba615ea1ec
 
 XXX: this is messy, we should solve things in better way
-  $ hg glog -r 428f7900a969:: --hidden
-  @  31:154b0179fb9b phase-divergent update to 849cee0a874b:
+  $ hg glog --hidden
+  @  6:89ba615ea1ec phase-divergent update to a51bce62c219:
   |   () draft
-  | x  30:1ebf33547a82 added n
+  | x  5:ee4af146c5cf added n
   | |   () draft
-  +---o  29:870e1c3eddc3 phase-divergent update to 849cee0a874b:
+  +---o  4:86419909e017 phase-divergent update to a51bce62c219:
   | |     () draft
-  | | x  28:63ccb8ea7cae added n
+  | | x  3:e1154ec0206a added n
   | | |   () draft
-  | | x  27:f313e2b90e70 added m
+  | | x  2:4f25cd9cd2bf added m
   | |/    () draft
-  o |  26:849cee0a874b added m and n
+  o |  1:a51bce62c219 added m and n
   |/    () public
-  o  23:428f7900a969 added g
-  |   () public
-  ~
+  o  0:d3873e73d99e init
+      () public
+
+  $ hg obslog -r a51bce62c219 --all
+  o  86419909e017 (4) phase-divergent update to a51bce62c219:
+  |
+  | @  89ba615ea1ec (6) phase-divergent update to a51bce62c219:
+  | |
+  x |  4f25cd9cd2bf (2) added m
+  | |    rewritten(description, parent, content) as 86419909e017 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+  | |
+  | x  ee4af146c5cf (5) added n
+  | |    rewritten(description, parent, content) as 89ba615ea1ec using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+  | |
+  | x  e1154ec0206a (3) added n
+  |/     rewritten(parent) as ee4af146c5cf using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+  |
+  o  a51bce62c219 (1) added m and n
+       rewritten(description, parent, content) as 4f25cd9cd2bf, e1154ec0206a using prune by test (Thu Jan 01 00:00:00 1970 +0000)
+  
 
 XXX: not sure this is the correct
-  $ hg exp 154b0179fb9b
+  $ hg exp 89ba615ea1ec
   # HG changeset patch
   # User test
   # Date 0 0
   #      Thu Jan 01 00:00:00 1970 +0000
-  # Node ID 154b0179fb9b53d2f853d6ba04740bb3d7a5cabe
-  # Parent  849cee0a874be7c4e75dfacb5ad72aa5696951ba
-  phase-divergent update to 849cee0a874b:
+  # Node ID 89ba615ea1ec3ba5b25db9f7897eb29712d7e5d6
+  # Parent  a51bce62c219f024bc0ae0cc0e3957ee77d7cb46
+  phase-divergent update to a51bce62c219:
   
   added n
   
-  diff -r 849cee0a874b -r 154b0179fb9b m
+  diff -r a51bce62c219 -r 89ba615ea1ec m
   --- a/m	Thu Jan 01 00:00:00 1970 +0000
   +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   @@ -1,1 +0,0 @@
   -m
 
 XXX: not sure this is correct
-  $ hg exp 870e1c3eddc3
+  $ hg exp 86419909e017
   # HG changeset patch
   # User test
   # Date 0 0
   #      Thu Jan 01 00:00:00 1970 +0000
-  # Node ID 870e1c3eddc34cc475e8e13d2fe1934210c1937e
-  # Parent  849cee0a874be7c4e75dfacb5ad72aa5696951ba
-  phase-divergent update to 849cee0a874b:
+  # Node ID 86419909e01787959aa6471aee605c6d604a3e0d
+  # Parent  a51bce62c219f024bc0ae0cc0e3957ee77d7cb46
+  phase-divergent update to a51bce62c219:
   
   added m
   
-  diff -r 849cee0a874b -r 870e1c3eddc3 n
+  diff -r a51bce62c219 -r 86419909e017 n
   --- a/n	Thu Jan 01 00:00:00 1970 +0000
   +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   @@ -1,1 +0,0 @@
   -n
 
-When the public changeset is splitted across various branches
---------------------------------------------------------------
+When the public changeset is split across various topological branches
+======================================================================
+
+  $ cd ../split-across-branches
 
   $ echo p > p
   $ echo q > q
@@ -1061,177 +1086,870 @@
 
   $ hg prev
   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
-  [31] phase-divergent update to 849cee0a874b:
+  [0] init
   $ echo p > p
   $ hg ci -Aqm "added p"
   $ hg prev
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  [31] phase-divergent update to 849cee0a874b:
+  [0] init
   $ echo q > q
   $ hg ci -Aqm "added q"
 
-  $ hg glog -r 154b0179fb9b::
-  @  34:e046341aa97c added q
+  $ hg glog
+  @  3:bb87595f9a77 added q
   |   () draft
-  | o  33:6f8c250eecff added p
+  | o  2:a47263294745 added p
   |/    () draft
-  | o  32:8a70f55b2af3 added p and q
+  | o  1:90859808ece6 added p and q
   |/    () draft
-  o  31:154b0179fb9b phase-divergent update to 849cee0a874b:
-  |   () draft
-  ~
+  o  0:d3873e73d99e init
+      () public
 
-  $ hg prune -r 8a70f55b2af3 --succ 6f8c250eecff --succ e046341aa97c --split
+  $ hg prune -r 90859808ece6 --succ a47263294745 --succ bb87595f9a77 --split
   1 changesets pruned
 
-  $ hg phase -r 8a70f55b2af3 --public --hidden
+  $ hg phase -r 90859808ece6 --public --hidden
   2 new phase-divergent changesets
 
-  $ hg glog -r 154b0179fb9b::
-  @  34:e046341aa97c added q
+  $ hg glog
+  @  3:bb87595f9a77 added q
   |   () draft
-  | *  33:6f8c250eecff added p
+  | *  2:a47263294745 added p
   |/    () draft
-  | o  32:8a70f55b2af3 added p and q
+  | o  1:90859808ece6 added p and q
   |/    () public
-  o  31:154b0179fb9b phase-divergent update to 849cee0a874b:
-  |   () public
-  ~
+  o  0:d3873e73d99e init
+      () public
 
   $ hg evolve --list
-  6f8c250eecff: added p
-    phase-divergent: 8a70f55b2af3 (immutable precursor)
+  a47263294745: added p
+    phase-divergent: 90859808ece6 (immutable precursor)
   
-  e046341aa97c: added q
-    phase-divergent: 8a70f55b2af3 (immutable precursor)
+  bb87595f9a77: added q
+    phase-divergent: 90859808ece6 (immutable precursor)
   
   $ hg evolve --all --phase-divergent
-  recreate:[33] added p
-  atop:[32] added p and q
-  computing new diff
-  committed as f3e41d89b3c5
-  recreate:[34] added q
-  atop:[32] added p and q
-  computing new diff
-  committed as 605c306d4f87
-  working directory is now at 605c306d4f87
+  recreate:[2] added p
+  atop:[1] added p and q
+  committed as 25875a9cb640
+  recreate:[3] added q
+  atop:[1] added p and q
+  committed as 26f564f94bcc
+  working directory is now at 26f564f94bcc
 
-  $ hg glog -r 154b0179fb9b:: --hidden
-  @  36:605c306d4f87 phase-divergent update to 8a70f55b2af3:
+  $ hg glog --hidden
+  @  5:26f564f94bcc phase-divergent update to 90859808ece6:
   |   () draft
-  | o  35:f3e41d89b3c5 phase-divergent update to 8a70f55b2af3:
+  | o  4:25875a9cb640 phase-divergent update to 90859808ece6:
   |/    () draft
-  | x  34:e046341aa97c added q
+  | x  3:bb87595f9a77 added q
   | |   () draft
-  | | x  33:6f8c250eecff added p
+  | | x  2:a47263294745 added p
   | |/    () draft
-  o |  32:8a70f55b2af3 added p and q
+  o |  1:90859808ece6 added p and q
   |/    () public
-  o  31:154b0179fb9b phase-divergent update to 849cee0a874b:
-  |   () public
-  ~
+  o  0:d3873e73d99e init
+      () public
+
+  $ hg obslog -r 90859808ece6 --all
+  o  25875a9cb640 (4) phase-divergent update to 90859808ece6:
+  |
+  | @  26f564f94bcc (5) phase-divergent update to 90859808ece6:
+  | |
+  x |  a47263294745 (2) added p
+  | |    rewritten(description, parent, content) as 25875a9cb640 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+  | |
+  | x  bb87595f9a77 (3) added q
+  |/     rewritten(description, parent, content) as 26f564f94bcc using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+  |
+  o  90859808ece6 (1) added p and q
+       rewritten(description, content) as a47263294745, bb87595f9a77 using prune by test (Thu Jan 01 00:00:00 1970 +0000)
+  
 
 XXX: not sure this is correct
-  $ hg exp 605c306d4f87
+  $ hg exp 26f564f94bcc
   # HG changeset patch
   # User test
   # Date 0 0
   #      Thu Jan 01 00:00:00 1970 +0000
-  # Node ID 605c306d4f87fccfdb5e7dd1c750b6d4f813defb
-  # Parent  8a70f55b2af35452916dc89401a5ecf6553646a5
-  phase-divergent update to 8a70f55b2af3:
+  # Node ID 26f564f94bcc34e049eb112fd14ab1e5286f2325
+  # Parent  90859808ece64c9ca64dd29992db42353c70f164
+  phase-divergent update to 90859808ece6:
   
   added q
   
-  diff -r 8a70f55b2af3 -r 605c306d4f87 p
+  diff -r 90859808ece6 -r 26f564f94bcc p
   --- a/p	Thu Jan 01 00:00:00 1970 +0000
   +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   @@ -1,1 +0,0 @@
   -p
 
 XXX: not sure this is correct
-  $ hg exp f3e41d89b3c5
+  $ hg exp 25875a9cb640
   # HG changeset patch
   # User test
   # Date 0 0
   #      Thu Jan 01 00:00:00 1970 +0000
-  # Node ID f3e41d89b3c5f6ee49ccc734045856d7b025f048
-  # Parent  8a70f55b2af35452916dc89401a5ecf6553646a5
-  phase-divergent update to 8a70f55b2af3:
+  # Node ID 25875a9cb6400973b846c94f6a80410067c2cb1f
+  # Parent  90859808ece64c9ca64dd29992db42353c70f164
+  phase-divergent update to 90859808ece6:
   
   added p
   
-  diff -r 8a70f55b2af3 -r f3e41d89b3c5 q
+  diff -r 90859808ece6 -r 25875a9cb640 q
   --- a/q	Thu Jan 01 00:00:00 1970 +0000
   +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   @@ -1,1 +0,0 @@
   -q
 
-Testing the evolution of a phase-divergent merge with no conflicts
-------------------------------------------------------------------
+When the public changeset is split and amended
+==============================================
+
+  $ cd ../split-and-amend
+
+  $ echo m > m
+  $ echo n > n
+  $ hg ci -Aqm "added m and n"
+  $ hg prev
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  [0] init
+  $ echo m > m
+  $ hg ci -Aqm "added m"
+  $ echo n > n
+  $ hg ci -Aqm "added n"
+
+  $ hg glog
+  @  3:e1154ec0206a added n
+  |   () draft
+  o  2:4f25cd9cd2bf added m
+  |   () draft
+  | o  1:a51bce62c219 added m and n
+  |/    () draft
+  o  0:d3873e73d99e init
+      () public
+
+  $ hg prune -r a51bce62c219 --succ 4f25cd9cd2bf --succ e1154ec0206a --split
+  1 changesets pruned
+
+  $ echo n2 > n
+  $ hg amend
 
-  $ hg glog -r 154b0179fb9b::
-  @  36:605c306d4f87 phase-divergent update to 8a70f55b2af3:
+  $ hg phase -r a51bce62c219 --public --hidden
+  2 new phase-divergent changesets
+
+  $ hg glog
+  @  4:52ca78bb98c7 added n
+  |   () draft
+  *  2:4f25cd9cd2bf added m
+  |   () draft
+  | o  1:a51bce62c219 added m and n
+  |/    () public
+  o  0:d3873e73d99e init
+      () public
+
+  $ hg evolve --list
+  4f25cd9cd2bf: added m
+    phase-divergent: a51bce62c219 (immutable precursor)
+  
+  52ca78bb98c7: added n
+    phase-divergent: a51bce62c219 (immutable precursor)
+  
+  $ hg evolve --all --phase-divergent
+  recreate:[2] added m
+  atop:[1] added m and n
+  committed as 86419909e017
+  1 new orphan changesets
+  recreate:[4] added n
+  atop:[1] added m and n
+  rebasing to destination parent: d3873e73d99e
+  committed as 88b0dae5369a
+  working directory is now at 88b0dae5369a
+
+  $ hg glog --hidden
+  @  7:88b0dae5369a phase-divergent update to a51bce62c219:
   |   () draft
-  | o  35:f3e41d89b3c5 phase-divergent update to 8a70f55b2af3:
-  |/    () draft
-  o  32:8a70f55b2af3 added p and q
-  |   () public
-  o  31:154b0179fb9b phase-divergent update to 849cee0a874b:
-  |   () public
-  ~
+  | x  6:98dad8812511 added n
+  | |   () draft
+  +---o  5:86419909e017 phase-divergent update to a51bce62c219:
+  | |     () draft
+  | | x  4:52ca78bb98c7 added n
+  | | |   () draft
+  | | | x  3:e1154ec0206a added n
+  | | |/    () draft
+  | | x  2:4f25cd9cd2bf added m
+  | |/    () draft
+  o |  1:a51bce62c219 added m and n
+  |/    () public
+  o  0:d3873e73d99e init
+      () public
+
+  $ hg obslog -r a51bce62c219 --all
+  o  86419909e017 (5) phase-divergent update to a51bce62c219:
+  |
+  | @  88b0dae5369a (7) phase-divergent update to a51bce62c219:
+  | |
+  x |  4f25cd9cd2bf (2) added m
+  | |    rewritten(description, parent, content) as 86419909e017 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+  | |
+  | x  98dad8812511 (6) added n
+  | |    rewritten(description, parent, content) as 88b0dae5369a using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+  | |
+  | x  52ca78bb98c7 (4) added n
+  | |    rewritten(parent) as 98dad8812511 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+  | |
+  | x  e1154ec0206a (3) added n
+  |/     rewritten(content) as 52ca78bb98c7 using amend by test (Thu Jan 01 00:00:00 1970 +0000)
+  |
+  o  a51bce62c219 (1) added m and n
+       rewritten(description, parent, content) as 4f25cd9cd2bf, e1154ec0206a using prune by test (Thu Jan 01 00:00:00 1970 +0000)
+  
+
+XXX: not sure this is correct
+  $ hg exp 86419909e017
+  # HG changeset patch
+  # User test
+  # Date 0 0
+  #      Thu Jan 01 00:00:00 1970 +0000
+  # Node ID 86419909e01787959aa6471aee605c6d604a3e0d
+  # Parent  a51bce62c219f024bc0ae0cc0e3957ee77d7cb46
+  phase-divergent update to a51bce62c219:
+  
+  added m
+  
+  diff -r a51bce62c219 -r 86419909e017 n
+  --- a/n	Thu Jan 01 00:00:00 1970 +0000
+  +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +0,0 @@
+  -n
+
+XXX: not sure this is correct
+  $ hg exp 88b0dae5369a
+  # HG changeset patch
+  # User test
+  # Date 0 0
+  #      Thu Jan 01 00:00:00 1970 +0000
+  # Node ID 88b0dae5369aaa3bceb6c0b647542594e2c72fb7
+  # Parent  a51bce62c219f024bc0ae0cc0e3957ee77d7cb46
+  phase-divergent update to a51bce62c219:
+  
+  added n
+  
+  diff -r a51bce62c219 -r 88b0dae5369a m
+  --- a/m	Thu Jan 01 00:00:00 1970 +0000
+  +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +0,0 @@
+  -m
+  diff -r a51bce62c219 -r 88b0dae5369a n
+  --- a/n	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/n	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +1,1 @@
+  -n
+  +n2
+
+Testing the evolution of a phase-divergent merge with no conflicts
+==================================================================
+
+  $ cd ../merge-no-conflict
 
   $ echo h > h
   $ hg ci -Aqm "added h"
   $ hg prev
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  [36] phase-divergent update to 8a70f55b2af3:
+  [0] init
   $ echo i > i
   $ hg ci -Aqm "added i"
-  $ hg merge -r ef8c23f37b55
+  $ hg merge -r a53d182199c1
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ hg ci -m "merge h and i"
 
-  $ hg glog -r 605c306d4f87::
-  @    39:12ebe0d625d7 merge h and i
+  $ hg glog
+  @    3:205b2f5ecb7b merge h and i
   |\    () draft
-  | o  38:9bb561db4230 added i
+  | o  2:f0be5e638ecf added i
   | |   () draft
-  o |  37:ef8c23f37b55 added h
+  o |  1:a53d182199c1 added h
   |/    () draft
-  o  36:605c306d4f87 phase-divergent update to 8a70f55b2af3:
-  |   () draft
-  ~
+  o  0:d3873e73d99e init
+      () public
 
-  $ hg up ef8c23f37b55
+  $ hg up a53d182199c1
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  $ hg merge -r 9bb561db4230
+  $ hg merge -r f0be5e638ecf
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ hg ci -m "merge h and i successor"
   created new head
-  $ hg glog -r 605c306d4f87::
-  @    40:d2aeda868461 merge h and i successor
+  $ hg glog
+  @    4:8d4acf488ab5 merge h and i successor
   |\    () draft
-  +---o  39:12ebe0d625d7 merge h and i
+  +---o  3:205b2f5ecb7b merge h and i
   | |/    () draft
-  | o  38:9bb561db4230 added i
+  | o  2:f0be5e638ecf added i
   | |   () draft
-  o |  37:ef8c23f37b55 added h
+  o |  1:a53d182199c1 added h
   |/    () draft
-  o  36:605c306d4f87 phase-divergent update to 8a70f55b2af3:
-  |   () draft
-  ~
+  o  0:d3873e73d99e init
+      () public
 
-  $ hg prune -r 12ebe0d625d7 --succ .
+  $ hg prune -r 205b2f5ecb7b --succ .
   1 changesets pruned
 
-  $ hg phase 12ebe0d625d7 --hidden --public
+  $ hg phase 205b2f5ecb7b --hidden --public
   1 new phase-divergent changesets
 
 Resolution of phase-divergent merge commit using `hg evolve`
 
 XXX: we should handle phase-divergent merges
   $ hg evolve --phase-divergent
-  skipping d2aeda868461 : we do not handle merge yet
+  skipping 8d4acf488ab5 : we do not handle merge yet
+
+Check we preserve "cancelation" of changes
+==========================================
+
+This tests case where the phase divergence changesets cancelled some of the
+change made by the public predecessors. The cancellation of these changes need
+to be preserved.
+
+  $ hg init cancelled-changes
+  $ cd cancelled-changes
+  $ cat << EOF > numbers
+  > 1
+  > 2
+  > 3
+  > 4
+  > 5
+  > 6
+  > 7
+  > 8
+  > 9
+  > EOF
+  $ cat << EOF > letters
+  > a
+  > b
+  > c
+  > d
+  > e
+  > f
+  > g
+  > h
+  > i
+  > EOF
+  $ cat << EOF > romans
+  > I
+  > II
+  > III
+  > IV
+  > V
+  > VI
+  > VII
+  > VIII
+  > IX
+  > EOF
+  $ hg add numbers letters romans
+  $ hg commit -m root
+  $ cat << EOF > numbers
+  > 1
+  > 2
+  > 3
+  > four
+  > 5
+  > 6
+  > 7
+  > 8
+  > nine
+  > EOF
+  $ cat << EOF > letters
+  > a
+  > b
+  > c
+  > D
+  > e
+  > f
+  > g
+  > h
+  > i
+  > EOF
+  $ hg commit -m E1
+  $ cat << EOF > numbers
+  > 1
+  > 2
+  > 3
+  > 4
+  > 5
+  > 6
+  > seven
+  > 8
+  > nine
+  > EOF
+  $ cat << EOF > letters
+  > a
+  > b
+  > c
+  > d
+  > e
+  > f
+  > g
+  > h
+  > i
+  > EOF
+  $ cat << EOF > romans
+  > I
+  > ii
+  > III
+  > IV
+  > V
+  > VI
+  > VII
+  > VIII
+  > IX
+  > EOF
+  $ hg commit --amend -m E2
+  $ hg --hidden phase --public --rev 'desc(E1)'
+  1 new phase-divergent changesets
+  $ hg log -G --patch --hidden --rev 'not desc("root")'
+  @  changeset:   2:599454370881
+  |  tag:         tip
+  ~  parent:      0:6d1fdf6de7e2
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     instability: phase-divergent
+     summary:     E2
+  
+     diff -r 6d1fdf6de7e2 -r 599454370881 numbers
+     --- a/numbers	Thu Jan 01 00:00:00 1970 +0000
+     +++ b/numbers	Thu Jan 01 00:00:00 1970 +0000
+     @@ -4,6 +4,6 @@
+      4
+      5
+      6
+     -7
+     +seven
+      8
+     -9
+     +nine
+     diff -r 6d1fdf6de7e2 -r 599454370881 romans
+     --- a/romans	Thu Jan 01 00:00:00 1970 +0000
+     +++ b/romans	Thu Jan 01 00:00:00 1970 +0000
+     @@ -1,5 +1,5 @@
+      I
+     -II
+     +ii
+      III
+      IV
+      V
+  
+  o  changeset:   1:3074c7249d20
+  |  user:        test
+  ~  date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     E1
+  
+     diff -r 6d1fdf6de7e2 -r 3074c7249d20 letters
+     --- a/letters	Thu Jan 01 00:00:00 1970 +0000
+     +++ b/letters	Thu Jan 01 00:00:00 1970 +0000
+     @@ -1,7 +1,7 @@
+      a
+      b
+      c
+     -d
+     +D
+      e
+      f
+      g
+     diff -r 6d1fdf6de7e2 -r 3074c7249d20 numbers
+     --- a/numbers	Thu Jan 01 00:00:00 1970 +0000
+     +++ b/numbers	Thu Jan 01 00:00:00 1970 +0000
+     @@ -1,9 +1,9 @@
+      1
+      2
+      3
+     -4
+     +four
+      5
+      6
+      7
+      8
+     -9
+     +nine
+  
+  $ hg evolve --list
+  599454370881: E2
+    phase-divergent: 3074c7249d20 (immutable precursor)
+  
+  $ hg obslog --all --patch
+  @  599454370881 (2) E2
+  |
+  o  3074c7249d20 (1) E1
+       rewritten(description, content) as 599454370881 using amend by test (Thu Jan 01 00:00:00 1970 +0000)
+         diff -r 3074c7249d20 -r 599454370881 changeset-description
+         --- a/changeset-description
+         +++ b/changeset-description
+         @@ -1,1 +1,1 @@
+         -E1
+         +E2
+  
+         diff -r 3074c7249d20 -r 599454370881 letters
+         --- a/letters	Thu Jan 01 00:00:00 1970 +0000
+         +++ b/letters	Thu Jan 01 00:00:00 1970 +0000
+         @@ -1,7 +1,7 @@
+          a
+          b
+          c
+         -D
+         +d
+          e
+          f
+          g
+         diff -r 3074c7249d20 -r 599454370881 numbers
+         --- a/numbers	Thu Jan 01 00:00:00 1970 +0000
+         +++ b/numbers	Thu Jan 01 00:00:00 1970 +0000
+         @@ -1,9 +1,9 @@
+          1
+          2
+          3
+         -four
+         +4
+          5
+          6
+         -7
+         +seven
+          8
+          nine
+         diff -r 3074c7249d20 -r 599454370881 romans
+         --- a/romans	Thu Jan 01 00:00:00 1970 +0000
+         +++ b/romans	Thu Jan 01 00:00:00 1970 +0000
+         @@ -1,5 +1,5 @@
+          I
+         -II
+         +ii
+          III
+          IV
+          V
+  
+  
+
+  $ hg evolve --phase-divergent --rev 'desc("E2")'
+  recreate:[2] E2
+  atop:[1] E1
+  committed as 9eebcb77a7e2
+  working directory is now at 9eebcb77a7e2
+  $ hg export
+  # HG changeset patch
+  # User test
+  # Date 0 0
+  #      Thu Jan 01 00:00:00 1970 +0000
+  # Node ID 9eebcb77a7e2b240cb7dce095bbe608b5de91cc8
+  # Parent  3074c7249d2023b1fff891591d7e609695cd09c2
+  phase-divergent update to 3074c7249d20:
+  
+  E2
+  
+  diff -r 3074c7249d20 -r 9eebcb77a7e2 letters
+  --- a/letters	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/letters	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,7 +1,7 @@
+   a
+   b
+   c
+  -D
+  +d
+   e
+   f
+   g
+  diff -r 3074c7249d20 -r 9eebcb77a7e2 numbers
+  --- a/numbers	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/numbers	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,9 +1,9 @@
+   1
+   2
+   3
+  -four
+  +4
+   5
+   6
+  -7
+  +seven
+   8
+   nine
+  diff -r 3074c7249d20 -r 9eebcb77a7e2 romans
+  --- a/romans	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/romans	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,5 +1,5 @@
+   I
+  -II
+  +ii
+   III
+   IV
+   V
+  $ hg log -G --patch --rev 'not desc("root")'
+  @  changeset:   3:9eebcb77a7e2
+  |  tag:         tip
+  |  parent:      1:3074c7249d20
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     phase-divergent update to 3074c7249d20:
+  |
+  |  diff -r 3074c7249d20 -r 9eebcb77a7e2 letters
+  |  --- a/letters	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/letters	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -1,7 +1,7 @@
+  |   a
+  |   b
+  |   c
+  |  -D
+  |  +d
+  |   e
+  |   f
+  |   g
+  |  diff -r 3074c7249d20 -r 9eebcb77a7e2 numbers
+  |  --- a/numbers	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/numbers	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -1,9 +1,9 @@
+  |   1
+  |   2
+  |   3
+  |  -four
+  |  +4
+  |   5
+  |   6
+  |  -7
+  |  +seven
+  |   8
+  |   nine
+  |  diff -r 3074c7249d20 -r 9eebcb77a7e2 romans
+  |  --- a/romans	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/romans	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -1,5 +1,5 @@
+  |   I
+  |  -II
+  |  +ii
+  |   III
+  |   IV
+  |   V
+  |
+  o  changeset:   1:3074c7249d20
+  |  user:        test
+  ~  date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     E1
+  
+     diff -r 6d1fdf6de7e2 -r 3074c7249d20 letters
+     --- a/letters	Thu Jan 01 00:00:00 1970 +0000
+     +++ b/letters	Thu Jan 01 00:00:00 1970 +0000
+     @@ -1,7 +1,7 @@
+      a
+      b
+      c
+     -d
+     +D
+      e
+      f
+      g
+     diff -r 6d1fdf6de7e2 -r 3074c7249d20 numbers
+     --- a/numbers	Thu Jan 01 00:00:00 1970 +0000
+     +++ b/numbers	Thu Jan 01 00:00:00 1970 +0000
+     @@ -1,9 +1,9 @@
+      1
+      2
+      3
+     -4
+     +four
+      5
+      6
+      7
+      8
+     -9
+     +nine
+  
+  $ hg obslog --patch
+  @  9eebcb77a7e2 (3) phase-divergent update to 3074c7249d20:
+  |
+  x  599454370881 (2) E2
+  |    rewritten(description, parent, content) as 9eebcb77a7e2 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+  |      (No patch available, changesets rebased)
+  |
+  o  3074c7249d20 (1) E1
+       rewritten(description, content) as 599454370881 using amend by test (Thu Jan 01 00:00:00 1970 +0000)
+         diff -r 3074c7249d20 -r 599454370881 changeset-description
+         --- a/changeset-description
+         +++ b/changeset-description
+         @@ -1,1 +1,1 @@
+         -E1
+         +E2
+  
+         diff -r 3074c7249d20 -r 599454370881 letters
+         --- a/letters	Thu Jan 01 00:00:00 1970 +0000
+         +++ b/letters	Thu Jan 01 00:00:00 1970 +0000
+         @@ -1,7 +1,7 @@
+          a
+          b
+          c
+         -D
+         +d
+          e
+          f
+          g
+         diff -r 3074c7249d20 -r 599454370881 numbers
+         --- a/numbers	Thu Jan 01 00:00:00 1970 +0000
+         +++ b/numbers	Thu Jan 01 00:00:00 1970 +0000
+         @@ -1,9 +1,9 @@
+          1
+          2
+          3
+         -four
+         +4
+          5
+          6
+         -7
+         +seven
+          8
+          nine
+         diff -r 3074c7249d20 -r 599454370881 romans
+         --- a/romans	Thu Jan 01 00:00:00 1970 +0000
+         +++ b/romans	Thu Jan 01 00:00:00 1970 +0000
+         @@ -1,5 +1,5 @@
+          I
+         -II
+         +ii
+          III
+          IV
+          V
+  
+  
+  $ cd ..
+
+Phase divergence with file removal cancelation
+==============================================
+
+  $ hg init cancel-removal
+  $ cd cancel-removal
+  $ echo a > a
+  $ echo b > b
+  $ echo c > c
+  $ echo d > d
+  $ hg ci -Aqm initial
+
+Oops, we meant to delete just 'a', but we deleted 'b' and 'c' too
+
+  $ hg rm a b c
+  $ hg ci -m 'delete a'
+  $ hg revert -r .^ b
+  $ hg amend
+  $ hg glog --hidden --patch
+  @  2:0825dcee2670 delete a
+  |   () draftdiff -r 75d2b02c4a5c -r 0825dcee2670 a
+  |  --- a/a	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -1,1 +0,0 @@
+  |  -a
+  |  diff -r 75d2b02c4a5c -r 0825dcee2670 c
+  |  --- a/c	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -1,1 +0,0 @@
+  |  -c
+  |
+  | x  1:dff6e52f5e41 delete a
+  |/    () draftdiff -r 75d2b02c4a5c -r dff6e52f5e41 a
+  |    --- a/a	Thu Jan 01 00:00:00 1970 +0000
+  |    +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |    @@ -1,1 +0,0 @@
+  |    -a
+  |    diff -r 75d2b02c4a5c -r dff6e52f5e41 b
+  |    --- a/b	Thu Jan 01 00:00:00 1970 +0000
+  |    +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |    @@ -1,1 +0,0 @@
+  |    -b
+  |    diff -r 75d2b02c4a5c -r dff6e52f5e41 c
+  |    --- a/c	Thu Jan 01 00:00:00 1970 +0000
+  |    +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |    @@ -1,1 +0,0 @@
+  |    -c
+  |
+  o  0:75d2b02c4a5c initial
+      () draftdiff -r 000000000000 -r 75d2b02c4a5c a
+     --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+     +++ b/a	Thu Jan 01 00:00:00 1970 +0000
+     @@ -0,0 +1,1 @@
+     +a
+     diff -r 000000000000 -r 75d2b02c4a5c b
+     --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+     +++ b/b	Thu Jan 01 00:00:00 1970 +0000
+     @@ -0,0 +1,1 @@
+     +b
+     diff -r 000000000000 -r 75d2b02c4a5c c
+     --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+     +++ b/c	Thu Jan 01 00:00:00 1970 +0000
+     @@ -0,0 +1,1 @@
+     +c
+     diff -r 000000000000 -r 75d2b02c4a5c d
+     --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+     +++ b/d	Thu Jan 01 00:00:00 1970 +0000
+     @@ -0,0 +1,1 @@
+     +d
+  
+
+The public predecessors deletes'a', 'b' and 'c',
+If was amended to only delete 'a', and 'c'
+so the fixup should add back 'b'.
+
+  $ hg phase -p -r dff6e52f5e41 --hidden
+  1 new phase-divergent changesets
+  $ hg evolve --phase-divergent
+  recreate:[2] delete a
+  atop:[1] delete a
+  committed as 84aa492b3c37
+  working directory is now at 84aa492b3c37
+  $ hg glog --patch
+  @  3:84aa492b3c37 phase-divergent update to dff6e52f5e41:
+  |   () draftdiff -r dff6e52f5e41 -r 84aa492b3c37 b
+  |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/b	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -0,0 +1,1 @@
+  |  +b
+  |
+  o  1:dff6e52f5e41 delete a
+  |   () publicdiff -r 75d2b02c4a5c -r dff6e52f5e41 a
+  |  --- a/a	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -1,1 +0,0 @@
+  |  -a
+  |  diff -r 75d2b02c4a5c -r dff6e52f5e41 b
+  |  --- a/b	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -1,1 +0,0 @@
+  |  -b
+  |  diff -r 75d2b02c4a5c -r dff6e52f5e41 c
+  |  --- a/c	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -1,1 +0,0 @@
+  |  -c
+  |
+  o  0:75d2b02c4a5c initial
+      () publicdiff -r 000000000000 -r 75d2b02c4a5c a
+     --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+     +++ b/a	Thu Jan 01 00:00:00 1970 +0000
+     @@ -0,0 +1,1 @@
+     +a
+     diff -r 000000000000 -r 75d2b02c4a5c b
+     --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+     +++ b/b	Thu Jan 01 00:00:00 1970 +0000
+     @@ -0,0 +1,1 @@
+     +b
+     diff -r 000000000000 -r 75d2b02c4a5c c
+     --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+     +++ b/c	Thu Jan 01 00:00:00 1970 +0000
+     @@ -0,0 +1,1 @@
+     +c
+     diff -r 000000000000 -r 75d2b02c4a5c d
+     --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+     +++ b/d	Thu Jan 01 00:00:00 1970 +0000
+     @@ -0,0 +1,1 @@
+     +d
+  
+
+  $ hg diff --change .
+  diff -r dff6e52f5e41 -r 84aa492b3c37 b
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/b	Thu Jan 01 00:00:00 1970 +0000
+  @@ -0,0 +1,1 @@
+  +b
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-evolve-public-content-divergent.t	Thu Apr 11 22:13:55 2019 +0200
@@ -0,0 +1,2017 @@
+Test for handling of content divergence with public cset using `hg evolve`
+==========================================================================
+
+Setup
+=====
+  $ cat >> $HGRCPATH <<EOF
+  > [alias]
+  > glog = log -GT "{rev}:{node|short} {desc|firstline}\n {phase} {troubles}\n\n"
+  > [phases]
+  > publish = False
+  > [extensions]
+  > rebase =
+  > EOF
+  $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
+
+Testing the case when both divergent cset are on the same parent and no-conflict in merging:
+-------------------------------------------------------------------------------------
+
+Prepare the repository:
+
+  $ hg init pubdiv
+  $ cd pubdiv
+  $ for ch in a b; do
+  >   echo $ch > $ch;
+  >   hg ci -Aqm "added "$ch;
+  > done;
+  $ hg glog
+  @  1:5f6d8a4bf34a added b
+  |   draft
+  |
+  o  0:9092f1db7931 added a
+      draft
+  
+
+Make an amend and change phase to public:
+
+  $ sed -i "1 i I am first" b
+  $ hg amend
+  $ hg phase --public
+
+Amend again to create a cset divergent to public one:
+
+  $ hg up 1 --hidden -q
+  updated to hidden changeset 5f6d8a4bf34a
+  (hidden revision '5f6d8a4bf34a' was rewritten as: 44f360db368f)
+  working directory parent is obsolete! (5f6d8a4bf34a)
+
+  $ echo "I am second" >> b
+  $ hg ci --amend -m "updated b"
+  1 new content-divergent changesets
+
+  $ hg glog
+  @  3:dcdaf152280a updated b
+  |   draft content-divergent
+  |
+  | o  2:44f360db368f added b
+  |/    public
+  |
+  o  0:9092f1db7931 added a
+      public
+  
+
+Lets resolve the public content-divergence:
+
+  $ hg evolve --content-divergent
+  merge:[2] added b
+  with: [3] updated b
+  base: [1] added b
+  updating to "local" side of the conflict: 44f360db368f
+  merging "other" content-divergent changeset 'dcdaf152280a'
+  merging b
+  0 files updated, 1 files merged, 0 files removed, 0 files unresolved
+  committed as c1aa9cfb6cf8
+  working directory is now at c1aa9cfb6cf8
+
+Following graph log shows that it correctly merged the two divergent csets:
+
+  $ hg glog -p
+  @  5:c1aa9cfb6cf8 phase-divergent update to 44f360db368f:
+  |   draft
+  |
+  |  diff -r 44f360db368f -r c1aa9cfb6cf8 b
+  |  --- a/b	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/b	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -1,2 +1,3 @@
+  |   I am first
+  |   b
+  |  +I am second
+  |
+  o  2:44f360db368f added b
+  |   public
+  |
+  |  diff -r 9092f1db7931 -r 44f360db368f b
+  |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/b	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -0,0 +1,2 @@
+  |  +I am first
+  |  +b
+  |
+  o  0:9092f1db7931 added a
+      public
+  
+     diff -r 000000000000 -r 9092f1db7931 a
+     --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+     +++ b/a	Thu Jan 01 00:00:00 1970 +0000
+     @@ -0,0 +1,1 @@
+     +a
+  
+  $ hg evolve -l
+
+  $ cd ..
+
+Testing the case when both divergent cset has same parent and has conflict in merging:
+------------------------------------------------------------------------------
+
+Prepare the repository:
+
+  $ hg init pubdiv1
+  $ cd pubdiv1
+  $ for ch in a b; do
+  >   echo $ch > $ch;
+  >   hg ci -Aqm "added "$ch;
+  > done;
+  $ hg glog
+  @  1:5f6d8a4bf34a added b
+  |   draft
+  |
+  o  0:9092f1db7931 added a
+      draft
+  
+
+Make an amend and change phase to public:
+
+  $ echo "I am foo" > b
+  $ hg amend
+  $ hg phase --public
+
+Amend again to create a cset divergent to public one:
+
+  $ hg up 1 --hidden -q
+  updated to hidden changeset 5f6d8a4bf34a
+  (hidden revision '5f6d8a4bf34a' was rewritten as: 580f2d01e52c)
+  working directory parent is obsolete! (5f6d8a4bf34a)
+
+  $ echo "I am bar" > b
+  $ hg ci --amend -m "updated b"
+  1 new content-divergent changesets
+
+  $ hg glog
+  @  3:0e805383168e updated b
+  |   draft content-divergent
+  |
+  | o  2:580f2d01e52c added b
+  |/    public
+  |
+  o  0:9092f1db7931 added a
+      public
+  
+
+Lets resolve the divergence:
+
+  $ hg evolve --content-divergent
+  merge:[2] added b
+  with: [3] updated b
+  base: [1] added b
+  updating to "local" side of the conflict: 580f2d01e52c
+  merging "other" content-divergent changeset '0e805383168e'
+  merging b
+  warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  fix conflicts and see `hg help evolve.interrupted`
+  [1]
+
+  $ echo "I am foobar" > b
+  $ hg resolve -m --tool union
+  (no more unresolved files)
+  continue: hg evolve --continue
+  $ hg evolve --continue
+  committed as 1a739394e9d4
+  working directory is now at 1a739394e9d4
+
+  $ hg glog
+  @  5:1a739394e9d4 phase-divergent update to 580f2d01e52c:
+  |   draft
+  |
+  o  2:580f2d01e52c added b
+  |   public
+  |
+  o  0:9092f1db7931 added a
+      public
+  
+Testing the case when divergence is not created by actual diff change, but because of rebasing:
+------------------------------------------------------------------------------------------------
+
+Prepare the repo:
+
+  $ cd ..
+  $ hg init rebasediv
+  $ cd rebasediv
+  $ for ch in a b c; do
+  >   echo $ch > $ch;
+  >   hg ci -Am "added "$ch;
+  > done;
+  adding a
+  adding b
+  adding c
+
+  $ hg glog
+  @  2:155349b645be added c
+  |   draft
+  |
+  o  1:5f6d8a4bf34a added b
+  |   draft
+  |
+  o  0:9092f1db7931 added a
+      draft
+  
+
+On server side: a new cset is added based on rev 1 and rev 2 is rebased on newly added cset:
+
+  $ hg up .^ -q
+  $ echo d > d
+  $ hg ci -Am "added d"
+  adding d
+  created new head
+
+  $ hg rebase -r 2 -d .
+  rebasing 2:155349b645be "added c"
+
+  $ hg glog
+  o  4:c0d7ee6604ea added c
+  |   draft
+  |
+  @  3:c9241b0f2d5b added d
+  |   draft
+  |
+  o  1:5f6d8a4bf34a added b
+  |   draft
+  |
+  o  0:9092f1db7931 added a
+      draft
+  
+
+On user side: user has not pulled yet and amended the rev 2 which created the divergence after pull:
+  $ hg up 2 --hidden -q
+  updated to hidden changeset 155349b645be
+  (hidden revision '155349b645be' was rewritten as: c0d7ee6604ea)
+  working directory parent is obsolete! (155349b645be)
+
+  $ echo cc >> c
+  $ hg ci --amend -m "updated c"
+  2 new content-divergent changesets
+
+Lets change the phase to --public of branch which is pulled from server:
+  $ hg phase --public -r 4
+  $ hg glog -p
+  @  5:f5f9b4fc8b77 updated c
+  |   draft content-divergent
+  |
+  |  diff -r 5f6d8a4bf34a -r f5f9b4fc8b77 c
+  |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/c	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -0,0 +1,2 @@
+  |  +c
+  |  +cc
+  |
+  | o  4:c0d7ee6604ea added c
+  | |   public
+  | |
+  | |  diff -r c9241b0f2d5b -r c0d7ee6604ea c
+  | |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  | |  +++ b/c	Thu Jan 01 00:00:00 1970 +0000
+  | |  @@ -0,0 +1,1 @@
+  | |  +c
+  | |
+  | o  3:c9241b0f2d5b added d
+  |/    public
+  |
+  |    diff -r 5f6d8a4bf34a -r c9241b0f2d5b d
+  |    --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |    +++ b/d	Thu Jan 01 00:00:00 1970 +0000
+  |    @@ -0,0 +1,1 @@
+  |    +d
+  |
+  o  1:5f6d8a4bf34a added b
+  |   public
+  |
+  |  diff -r 9092f1db7931 -r 5f6d8a4bf34a b
+  |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/b	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -0,0 +1,1 @@
+  |  +b
+  |
+  o  0:9092f1db7931 added a
+      public
+  
+     diff -r 000000000000 -r 9092f1db7931 a
+     --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+     +++ b/a	Thu Jan 01 00:00:00 1970 +0000
+     @@ -0,0 +1,1 @@
+     +a
+  
+
+Evolve:
+  $ hg evolve --content-divergent
+  merge:[4] added c
+  with: [5] updated c
+  base: [2] added c
+  rebasing "other" content-divergent changeset f5f9b4fc8b77 on c9241b0f2d5b
+  updating to "local" side of the conflict: c0d7ee6604ea
+  merging "other" content-divergent changeset 'c3d442d80993'
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  committed as 3b336cbee992
+  working directory is now at 3b336cbee992
+
+  $ hg glog -p
+  @  8:3b336cbee992 phase-divergent update to c0d7ee6604ea:
+  |   draft
+  |
+  |  diff -r c0d7ee6604ea -r 3b336cbee992 c
+  |  --- a/c	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/c	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -1,1 +1,2 @@
+  |   c
+  |  +cc
+  |
+  o  4:c0d7ee6604ea added c
+  |   public
+  |
+  |  diff -r c9241b0f2d5b -r c0d7ee6604ea c
+  |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/c	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -0,0 +1,1 @@
+  |  +c
+  |
+  o  3:c9241b0f2d5b added d
+  |   public
+  |
+  |  diff -r 5f6d8a4bf34a -r c9241b0f2d5b d
+  |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/d	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -0,0 +1,1 @@
+  |  +d
+  |
+  o  1:5f6d8a4bf34a added b
+  |   public
+  |
+  |  diff -r 9092f1db7931 -r 5f6d8a4bf34a b
+  |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/b	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -0,0 +1,1 @@
+  |  +b
+  |
+  o  0:9092f1db7931 added a
+      public
+  
+     diff -r 000000000000 -r 9092f1db7931 a
+     --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+     +++ b/a	Thu Jan 01 00:00:00 1970 +0000
+     @@ -0,0 +1,1 @@
+     +a
+  
+Check that we don't have any unstable cset now:
+  $ hg evolve -l
+  $ cd ..
+
+Testing the case when csets are on different parent and no conflict in relocation and merging:
+----------------------------------------------------------------------------------------------
+
+  $ hg init pubdiv2
+  $ cd pubdiv2
+  $ for ch in a b c d; do
+  >   echo $ch > $ch;
+  >   hg ci -Aqm "added "$ch;
+  > done;
+
+  $ hg up .^
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo dd > d
+  $ hg add d
+  $ hg ci -m "added d"
+  created new head
+
+  $ hg up 1
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ echo dd > d
+  $ echo e > e
+  $ hg add d e
+  $ hg ci -m "added d e"
+  created new head
+
+  $ hg glog
+  @  5:4291d72ee19a added d e
+  |   draft
+  |
+  | o  4:93cd84bbdaca added d
+  | |   draft
+  | |
+  | | o  3:9150fe93bec6 added d
+  | |/    draft
+  | |
+  | o  2:155349b645be added c
+  |/    draft
+  |
+  o  1:5f6d8a4bf34a added b
+  |   draft
+  |
+  o  0:9092f1db7931 added a
+      draft
+  
+
+  $ hg prune 3 -s 5
+  1 changesets pruned
+  $ hg prune 3 -s 4 --hidden
+  1 changesets pruned
+  2 new content-divergent changesets
+
+Change phase to public for one head:
+  $ hg phase -r 4 --public
+
+  $ hg glog
+  @  5:4291d72ee19a added d e
+  |   draft content-divergent
+  |
+  | o  4:93cd84bbdaca added d
+  | |   public
+  | |
+  | o  2:155349b645be added c
+  |/    public
+  |
+  o  1:5f6d8a4bf34a added b
+  |   public
+  |
+  o  0:9092f1db7931 added a
+      public
+  
+
+  $ hg evolve --content-divergent --any
+  merge:[4] added d
+  with: [5] added d e
+  base: [3] added d
+  rebasing "other" content-divergent changeset 4291d72ee19a on 155349b645be
+  updating to "local" side of the conflict: 93cd84bbdaca
+  merging "other" content-divergent changeset 'f88581407163'
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  committed as 4cbe48a0c3d9
+  working directory is now at 4cbe48a0c3d9
+
+  $ hg glog -l 1
+  @  8:4cbe48a0c3d9 phase-divergent update to 93cd84bbdaca:
+  |   draft
+  ~
+
+  $ hg evolve -l
+  $ cd ..
+
+Different parents, relocation conflict
+--------------------------------------
+
+Testing the case when csets are on different parent and conflict in relocation
+but not in merging.
+
+  $ hg init pubdiv3
+  $ cd pubdiv3
+  $ for ch in a b c d; do
+  >   echo $ch > $ch;
+  >   hg ci -Aqm "added "$ch;
+  > done;
+
+  $ hg up .^^
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ echo d > d
+  $ echo cfoo > c
+  $ echo e > e
+  $ hg add d c e
+  $ hg ci -m "added d c e"
+  created new head
+
+  $ hg up 'desc("added c")'
+  1 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ echo dd > d
+  $ hg add d
+  $ hg ci -m "added d"
+  created new head
+
+  $ hg glog
+  @  5:93cd84bbdaca added d
+  |   draft
+  |
+  | o  4:f31bcc378766 added d c e
+  | |   draft
+  | |
+  +---o  3:9150fe93bec6 added d
+  | |     draft
+  | |
+  o |  2:155349b645be added c
+  |/    draft
+  |
+  o  1:5f6d8a4bf34a added b
+  |   draft
+  |
+  o  0:9092f1db7931 added a
+      draft
+  
+  $ hg prune 'min(desc("re:added d$"))' -s 'max(desc("re:added d$"))'
+  1 changesets pruned
+  $ hg prune 'min(desc("re:added d$"))' -s 'desc("added d c e")' --hidden
+  1 changesets pruned
+  2 new content-divergent changesets
+
+Change phase to public for one head:
+  $ hg phase --public -r 'max(desc("re:added d$"))'
+
+  $ hg glog
+  @  5:93cd84bbdaca added d
+  |   public
+  |
+  | *  4:f31bcc378766 added d c e
+  | |   draft content-divergent
+  | |
+  o |  2:155349b645be added c
+  |/    public
+  |
+  o  1:5f6d8a4bf34a added b
+  |   public
+  |
+  o  0:9092f1db7931 added a
+      public
+  
+  $ hg evolve --content-divergent --any
+  merge:[5] added d
+  with: [4] added d c e
+  base: [3] added d
+  rebasing "other" content-divergent changeset f31bcc378766 on 155349b645be
+  merging c
+  warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
+  fix conflicts and see `hg help evolve.interrupted`
+  [1]
+
+  $ hg diff
+  diff -r 155349b645be c
+  --- a/c	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/c	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +1,5 @@
+  +<<<<<<< destination: 155349b645be - test: added c
+   c
+  +=======
+  +cfoo
+  +>>>>>>> evolving:    f31bcc378766 - test: added d c e
+  diff -r 155349b645be d
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/d	Thu Jan 01 00:00:00 1970 +0000
+  @@ -0,0 +1,1 @@
+  +d
+  diff -r 155349b645be e
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/e	Thu Jan 01 00:00:00 1970 +0000
+  @@ -0,0 +1,1 @@
+  +e
+
+  $ echo c > c
+  $ hg res -m
+  (no more unresolved files)
+  continue: hg evolve --continue
+
+  $ hg evolve --continue
+  evolving 4:f31bcc378766 "added d c e"
+  updating to "local" side of the conflict: 93cd84bbdaca
+  merging "other" content-divergent changeset 'bd28d3e4a228'
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  committed as 412dde898967
+  working directory is now at 412dde898967
+  $ hg export
+  # HG changeset patch
+  # User test
+  # Date 0 0
+  #      Thu Jan 01 00:00:00 1970 +0000
+  # Node ID 412dde898967b50e7d334aefff778a9af46d29d1
+  # Parent  93cd84bbdacaeb8f881c29a609dbdd30c38cbc57
+  phase-divergent update to 93cd84bbdaca:
+  
+  added d c e
+  
+  diff -r 93cd84bbdaca -r 412dde898967 e
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/e	Thu Jan 01 00:00:00 1970 +0000
+  @@ -0,0 +1,1 @@
+  +e
+
+  $ hg evolve -l
+  $ cd ..
+
+Testing the case when merging leads to conflicts but relocation won't:
+---------------------------------------------------------------------
+
+  $ hg init pubdiv3.5
+  $ cd pubdiv3.5
+  $ for ch in a b c d; do
+  >   echo $ch > $ch;
+  >   hg ci -Aqm "added "$ch;
+  > done;
+
+  $ hg up .^^
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ echo dconflict > d
+  $ hg add d
+  $ hg ci -m "added d"
+  created new head
+
+  $ hg up 2
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo dd > d
+  $ hg add d
+  $ hg ci -m "added d"
+  created new head
+
+  $ hg glog
+  @  5:93cd84bbdaca added d
+  |   draft
+  |
+  | o  4:9411ad1fe615 added d
+  | |   draft
+  | |
+  +---o  3:9150fe93bec6 added d
+  | |     draft
+  | |
+  o |  2:155349b645be added c
+  |/    draft
+  |
+  o  1:5f6d8a4bf34a added b
+  |   draft
+  |
+  o  0:9092f1db7931 added a
+      draft
+  
+  $ hg prune 3 -s 5
+  1 changesets pruned
+  $ hg prune 3 -s 4 --hidden
+  1 changesets pruned
+  2 new content-divergent changesets
+
+Change phase to public for one head:
+  $ hg phase --public -r 5
+
+  $ hg glog
+  @  5:93cd84bbdaca added d
+  |   public
+  |
+  | *  4:9411ad1fe615 added d
+  | |   draft content-divergent
+  | |
+  o |  2:155349b645be added c
+  |/    public
+  |
+  o  1:5f6d8a4bf34a added b
+  |   public
+  |
+  o  0:9092f1db7931 added a
+      public
+  
+  $ hg evolve --content-divergent --any
+  merge:[5] added d
+  with: [4] added d
+  base: [3] added d
+  rebasing "other" content-divergent changeset 9411ad1fe615 on 155349b645be
+  updating to "local" side of the conflict: 93cd84bbdaca
+  merging "other" content-divergent changeset 'b5c690cdf1d5'
+  merging d
+  warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  fix conflicts and see `hg help evolve.interrupted`
+  [1]
+
+  $ echo d > d
+  $ hg res -m
+  (no more unresolved files)
+  continue: hg evolve --continue
+
+  $ hg evolve --continue
+  committed as 2a0f44767904
+  working directory is now at 2a0f44767904
+
+  $ hg evolve -l
+  $ cd ..
+
+Testing the case when relocation and merging both leads to conflicts:
+--------------------------------------------------------------------
+
+  $ hg init pubdiv4
+  $ cd pubdiv4
+  $ for ch in a b c d; do
+  >   echo $ch > $ch;
+  >   hg ci -Aqm "added "$ch;
+  > done;
+
+  $ hg up .^^
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ echo cfoo > c
+  $ echo e > e
+  $ echo dconflict > d
+  $ hg add c e d
+  $ hg ci -m "added c e"
+  created new head
+
+  $ hg up 2
+  1 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ echo dd > d
+  $ hg add d
+  $ hg ci -m "added d"
+  created new head
+
+  $ hg glog
+  @  5:93cd84bbdaca added d
+  |   draft
+  |
+  | o  4:3c17c7afaf6e added c e
+  | |   draft
+  | |
+  +---o  3:9150fe93bec6 added d
+  | |     draft
+  | |
+  o |  2:155349b645be added c
+  |/    draft
+  |
+  o  1:5f6d8a4bf34a added b
+  |   draft
+  |
+  o  0:9092f1db7931 added a
+      draft
+  
+  $ hg prune 3 -s 5
+  1 changesets pruned
+  $ hg prune 3 -s 4 --hidden
+  1 changesets pruned
+  2 new content-divergent changesets
+
+Change phase to public for one head:
+  $ hg phase --public -r 5
+
+  $ hg glog
+  @  5:93cd84bbdaca added d
+  |   public
+  |
+  | *  4:3c17c7afaf6e added c e
+  | |   draft content-divergent
+  | |
+  o |  2:155349b645be added c
+  |/    public
+  |
+  o  1:5f6d8a4bf34a added b
+  |   public
+  |
+  o  0:9092f1db7931 added a
+      public
+  
+  $ hg evolve --content-divergent --any
+  merge:[5] added d
+  with: [4] added c e
+  base: [3] added d
+  rebasing "other" content-divergent changeset 3c17c7afaf6e on 155349b645be
+  merging c
+  warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
+  fix conflicts and see `hg help evolve.interrupted`
+  [1]
+
+  $ hg diff
+  diff -r 155349b645be c
+  --- a/c	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/c	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +1,5 @@
+  +<<<<<<< destination: 155349b645be - test: added c
+   c
+  +=======
+  +cfoo
+  +>>>>>>> evolving:    3c17c7afaf6e - test: added c e
+  diff -r 155349b645be d
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/d	Thu Jan 01 00:00:00 1970 +0000
+  @@ -0,0 +1,1 @@
+  +dconflict
+  diff -r 155349b645be e
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/e	Thu Jan 01 00:00:00 1970 +0000
+  @@ -0,0 +1,1 @@
+  +e
+
+  $ echo cfoo > c
+  $ hg res -m
+  (no more unresolved files)
+  continue: hg evolve --continue
+
+  $ hg evolve --continue
+  evolving 4:3c17c7afaf6e "added c e"
+  updating to "local" side of the conflict: 93cd84bbdaca
+  merging "other" content-divergent changeset 'c4ce3d34e784'
+  merging d
+  warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
+  2 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  fix conflicts and see `hg help evolve.interrupted`
+  [1]
+
+  $ echo d > d
+  $ hg res -m
+  (no more unresolved files)
+  continue: hg evolve --continue
+
+  $ hg evolve --continue
+  committed as b9082a9e66ce
+  working directory is now at b9082a9e66ce
+
+  $ hg evolve -l
+  $ cd ..
+
+Different parent, simple conflict on relocate, deleted file on actual merge
+---------------------------------------------------------------------------
+
+Changeset "added c e" is also removing 'd'. This should conflict with the update
+to 'd' in the successors of 'adding d' when solving the content divergence.
+
+  $ hg init pubdiv-parent-deleted-file
+  $ cd pubdiv-parent-deleted-file
+  $ for ch in a b c d; do
+  >   echo $ch > $ch;
+  >   hg ci -Aqm "added "$ch;
+  > done;
+
+  $ hg up 'desc("added b")'
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ echo cfoo > c
+  $ echo e > e
+  $ hg add c e
+  $ hg ci -m "added c e"
+  created new head
+
+  $ hg up 'desc("re:added c$")'
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo dd > d
+  $ hg add d
+  $ hg ci -m "added d"
+  created new head
+
+  $ hg glog --patch --rev 'sort(all(), "topo")'
+  @  5:93cd84bbdaca added d
+  |   draft
+  |
+  |  diff -r 155349b645be -r 93cd84bbdaca d
+  |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/d	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -0,0 +1,1 @@
+  |  +dd
+  |
+  | o  3:9150fe93bec6 added d
+  |/    draft
+  |
+  |    diff -r 155349b645be -r 9150fe93bec6 d
+  |    --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |    +++ b/d	Thu Jan 01 00:00:00 1970 +0000
+  |    @@ -0,0 +1,1 @@
+  |    +d
+  |
+  o  2:155349b645be added c
+  |   draft
+  |
+  |  diff -r 5f6d8a4bf34a -r 155349b645be c
+  |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/c	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -0,0 +1,1 @@
+  |  +c
+  |
+  | o  4:e568fd1029bb added c e
+  |/    draft
+  |
+  |    diff -r 5f6d8a4bf34a -r e568fd1029bb c
+  |    --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |    +++ b/c	Thu Jan 01 00:00:00 1970 +0000
+  |    @@ -0,0 +1,1 @@
+  |    +cfoo
+  |    diff -r 5f6d8a4bf34a -r e568fd1029bb e
+  |    --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |    +++ b/e	Thu Jan 01 00:00:00 1970 +0000
+  |    @@ -0,0 +1,1 @@
+  |    +e
+  |
+  o  1:5f6d8a4bf34a added b
+  |   draft
+  |
+  |  diff -r 9092f1db7931 -r 5f6d8a4bf34a b
+  |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/b	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -0,0 +1,1 @@
+  |  +b
+  |
+  o  0:9092f1db7931 added a
+      draft
+  
+     diff -r 000000000000 -r 9092f1db7931 a
+     --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+     +++ b/a	Thu Jan 01 00:00:00 1970 +0000
+     @@ -0,0 +1,1 @@
+     +a
+  
+  $ hg prune 'min(desc("added d"))' -s 'max(desc("added d"))'
+  1 changesets pruned
+  $ hg prune 'min(desc("added d"))' -s 'desc("added c e")' --hidden
+  1 changesets pruned
+  2 new content-divergent changesets
+
+Change phase to public for one head:
+  $ hg phase --public -r 'max(desc("added d"))'
+
+  $ hg glog
+  @  5:93cd84bbdaca added d
+  |   public
+  |
+  | *  4:e568fd1029bb added c e
+  | |   draft content-divergent
+  | |
+  o |  2:155349b645be added c
+  |/    public
+  |
+  o  1:5f6d8a4bf34a added b
+  |   public
+  |
+  o  0:9092f1db7931 added a
+      public
+  
+
+  $ hg glog --patch --rev 'sort(all(), "topo")' --hidden
+  @  5:93cd84bbdaca added d
+  |   public
+  |
+  |  diff -r 155349b645be -r 93cd84bbdaca d
+  |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/d	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -0,0 +1,1 @@
+  |  +dd
+  |
+  | x  3:9150fe93bec6 added d
+  |/    draft
+  |
+  |    diff -r 155349b645be -r 9150fe93bec6 d
+  |    --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |    +++ b/d	Thu Jan 01 00:00:00 1970 +0000
+  |    @@ -0,0 +1,1 @@
+  |    +d
+  |
+  o  2:155349b645be added c
+  |   public
+  |
+  |  diff -r 5f6d8a4bf34a -r 155349b645be c
+  |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/c	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -0,0 +1,1 @@
+  |  +c
+  |
+  | *  4:e568fd1029bb added c e
+  |/    draft content-divergent
+  |
+  |    diff -r 5f6d8a4bf34a -r e568fd1029bb c
+  |    --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |    +++ b/c	Thu Jan 01 00:00:00 1970 +0000
+  |    @@ -0,0 +1,1 @@
+  |    +cfoo
+  |    diff -r 5f6d8a4bf34a -r e568fd1029bb e
+  |    --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |    +++ b/e	Thu Jan 01 00:00:00 1970 +0000
+  |    @@ -0,0 +1,1 @@
+  |    +e
+  |
+  o  1:5f6d8a4bf34a added b
+  |   public
+  |
+  |  diff -r 9092f1db7931 -r 5f6d8a4bf34a b
+  |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/b	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -0,0 +1,1 @@
+  |  +b
+  |
+  o  0:9092f1db7931 added a
+      public
+  
+     diff -r 000000000000 -r 9092f1db7931 a
+     --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+     +++ b/a	Thu Jan 01 00:00:00 1970 +0000
+     @@ -0,0 +1,1 @@
+     +a
+  
+
+  $ hg obslog --all --rev tip --patch
+  @  93cd84bbdaca (5) added d
+  |
+  | *  e568fd1029bb (4) added c e
+  |/
+  x  9150fe93bec6 (3) added d
+       rewritten(content) as 93cd84bbdaca using prune by test (Thu Jan 01 00:00:00 1970 +0000)
+         diff -r 9150fe93bec6 -r 93cd84bbdaca d
+         --- a/d	Thu Jan 01 00:00:00 1970 +0000
+         +++ b/d	Thu Jan 01 00:00:00 1970 +0000
+         @@ -1,1 +1,1 @@
+         -d
+         +dd
+  
+       rewritten(description, parent, content) as e568fd1029bb using prune by test (Thu Jan 01 00:00:00 1970 +0000)
+         (No patch available, changesets rebased)
+  
+
+  $ hg evolve --content-divergent --any
+  merge:[5] added d
+  with: [4] added c e
+  base: [3] added d
+  rebasing "other" content-divergent changeset e568fd1029bb on 155349b645be
+  merging c
+  warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
+  fix conflicts and see `hg help evolve.interrupted`
+  [1]
+
+  $ hg diff
+  diff -r 155349b645be c
+  --- a/c	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/c	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +1,5 @@
+  +<<<<<<< destination: 155349b645be - test: added c
+   c
+  +=======
+  +cfoo
+  +>>>>>>> evolving:    e568fd1029bb - test: added c e
+  diff -r 155349b645be e
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/e	Thu Jan 01 00:00:00 1970 +0000
+  @@ -0,0 +1,1 @@
+  +e
+
+  $ echo c > c
+  $ hg res -m
+  (no more unresolved files)
+  continue: hg evolve --continue
+
+  $ hg evolve --continue
+  evolving 4:e568fd1029bb "added c e"
+  updating to "local" side of the conflict: 93cd84bbdaca
+  merging "other" content-divergent changeset '2af3359250d3'
+  file 'd' was deleted in other but was modified in local.
+  What do you want to do?
+  use (c)hanged version, (d)elete, or leave (u)nresolved? u
+  1 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  fix conflicts and see `hg help evolve.interrupted`
+  [1]
+
+  $ hg sum
+  parent: 5:93cd84bbdaca 
+   added d
+  parent: 6:2af3359250d3 tip (content-divergent)
+   added c e
+  branch: default
+  commit: 1 modified, 1 unknown, 1 unresolved (merge)
+  update: (current)
+  phases: 1 draft
+  content-divergent: 1 changesets
+  evolve: (evolve --continue)
+
+  $ echo resolved > d
+  $ hg resolve -m d
+  (no more unresolved files)
+  continue: hg evolve --continue
+
+  $ hg evolve --continue
+  committed as bc1f4610744c
+  working directory is now at bc1f4610744c
+
+  $ hg export
+  # HG changeset patch
+  # User test
+  # Date 0 0
+  #      Thu Jan 01 00:00:00 1970 +0000
+  # Node ID bc1f4610744c6aa0e851d3876a61bfff6243b31c
+  # Parent  93cd84bbdacaeb8f881c29a609dbdd30c38cbc57
+  phase-divergent update to 93cd84bbdaca:
+  
+  added c e
+  
+  diff -r 93cd84bbdaca -r bc1f4610744c d
+  --- a/d	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/d	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +1,1 @@
+  -dd
+  +resolved
+  diff -r 93cd84bbdaca -r bc1f4610744c e
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/e	Thu Jan 01 00:00:00 1970 +0000
+  @@ -0,0 +1,1 @@
+  +e
+
+  $ hg evolve -l
+  $ cd ..
+
+Testing the case when "merging results in same as public cset" where:
+both the csets are on same parent and no conflict in merging.
+---------------------------------------------------------------------
+
+Prepare the repo:
+
+  $ hg init pubdiv5
+  $ cd pubdiv5
+  $ for ch in a b c; do
+  >   echo $ch > $ch;
+  >   hg ci -Am "added "$ch;
+  > done;
+  adding a
+  adding b
+  adding c
+
+  $ hg up .^
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo ch > ch
+  $ hg add ch
+  $ hg ci -m "added ch"
+  created new head
+
+  $ hg up .^
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo ch > ch
+  $ hg add ch
+  $ hg ci -m "added c"
+  created new head
+
+  $ hg glog
+  @  4:f7c1071f1e7c added c
+  |   draft
+  |
+  | o  3:90522bccf499 added ch
+  |/    draft
+  |
+  | o  2:155349b645be added c
+  |/    draft
+  |
+  o  1:5f6d8a4bf34a added b
+  |   draft
+  |
+  o  0:9092f1db7931 added a
+      draft
+  
+
+  $ hg prune 2 -s 3
+  1 changesets pruned
+  $ hg prune 2 -s 4 --hidden
+  1 changesets pruned
+  2 new content-divergent changesets
+  $ hg phase --public -r 4
+
+  $ hg glog
+  @  4:f7c1071f1e7c added c
+  |   public
+  |
+  | *  3:90522bccf499 added ch
+  |/    draft content-divergent
+  |
+  o  1:5f6d8a4bf34a added b
+  |   public
+  |
+  o  0:9092f1db7931 added a
+      public
+  
+  $ hg evolve --content-divergent --any
+  merge:[4] added c
+  with: [3] added ch
+  base: [2] added c
+  merging "other" content-divergent changeset '90522bccf499'
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  content-divergent changesets differ by descriptions only, discarding 90522bccf499
+
+  $ hg evolve -l
+
+  $ hg par
+  changeset:   4:f7c1071f1e7c
+  tag:         tip
+  parent:      1:5f6d8a4bf34a
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     added c
+  
+
+Testing the case when "merging results in same as public cset" where:
+both the csets are on different parent and no conflict in merging and relocation.
+---------------------------------------------------------------------------------
+
+Prepare the repo:
+
+  $ cd ..
+  $ hg init pubdiv6
+  $ cd pubdiv6
+  $ for ch in a b c d; do
+  >   echo $ch > $ch;
+  >   hg ci -Am "added "$ch;
+  > done;
+  adding a
+  adding b
+  adding c
+  adding d
+
+  $ hg up 1
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ echo dh > dh
+  $ hg add dh
+  $ hg ci -m "added dh"
+  created new head
+
+  $ hg up 2
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo dh > dh
+  $ hg add dh
+  $ hg ci -m "added d"
+  created new head
+
+  $ hg glog
+  @  5:e800202333a4 added d
+  |   draft
+  |
+  | o  4:5acd58ef5066 added dh
+  | |   draft
+  | |
+  +---o  3:9150fe93bec6 added d
+  | |     draft
+  | |
+  o |  2:155349b645be added c
+  |/    draft
+  |
+  o  1:5f6d8a4bf34a added b
+  |   draft
+  |
+  o  0:9092f1db7931 added a
+      draft
+  
+
+  $ hg prune 3 -s 4
+  1 changesets pruned
+  $ hg prune 3 -s 5 --hidden
+  1 changesets pruned
+  2 new content-divergent changesets
+  $ hg phase --public -r 5
+
+  $ hg glog
+  @  5:e800202333a4 added d
+  |   public
+  |
+  | *  4:5acd58ef5066 added dh
+  | |   draft content-divergent
+  | |
+  o |  2:155349b645be added c
+  |/    public
+  |
+  o  1:5f6d8a4bf34a added b
+  |   public
+  |
+  o  0:9092f1db7931 added a
+      public
+  
+  $ hg evolve --content-divergent --any
+  merge:[5] added d
+  with: [4] added dh
+  base: [3] added d
+  rebasing "other" content-divergent changeset 5acd58ef5066 on 155349b645be
+  updating to "local" side of the conflict: e800202333a4
+  merging "other" content-divergent changeset 'ae3429430ef1'
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  content-divergent changesets differ by descriptions only, discarding ae3429430ef1
+
+  $ hg evolve -l
+
+  $ hg par
+  changeset:   5:e800202333a4
+  tag:         tip
+  parent:      2:155349b645be
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     added d
+  
+Testing the case when "merging results in same as public cset" where:
+both the csets are on same parent and merging leads to conflict.
+---------------------------------------------------------------------
+
+Prepare the repo:
+
+  $ cd ..
+  $ hg init pubdiv7
+  $ cd pubdiv7
+  $ for ch in a b c; do
+  >   echo $ch > $ch;
+  >   hg ci -Am "added "$ch;
+  > done;
+  adding a
+  adding b
+  adding c
+
+  $ hg up .^
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo chconflict > ch
+  $ hg add ch
+  $ hg ci -m "added ch"
+  created new head
+
+  $ hg up .^
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo ch > ch
+  $ hg add ch
+  $ hg ci -m "added c"
+  created new head
+
+  $ hg glog
+  @  4:f7c1071f1e7c added c
+  |   draft
+  |
+  | o  3:229da2719b19 added ch
+  |/    draft
+  |
+  | o  2:155349b645be added c
+  |/    draft
+  |
+  o  1:5f6d8a4bf34a added b
+  |   draft
+  |
+  o  0:9092f1db7931 added a
+      draft
+  
+
+  $ hg prune 2 -s 3
+  1 changesets pruned
+  $ hg prune 2 -s 4 --hidden
+  1 changesets pruned
+  2 new content-divergent changesets
+  $ hg phase --public -r 4
+
+  $ hg glog
+  @  4:f7c1071f1e7c added c
+  |   public
+  |
+  | *  3:229da2719b19 added ch
+  |/    draft content-divergent
+  |
+  o  1:5f6d8a4bf34a added b
+  |   public
+  |
+  o  0:9092f1db7931 added a
+      public
+  
+  $ hg evolve --content-divergent --any
+  merge:[4] added c
+  with: [3] added ch
+  base: [2] added c
+  merging "other" content-divergent changeset '229da2719b19'
+  merging ch
+  warning: conflicts while merging ch! (edit, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  fix conflicts and see `hg help evolve.interrupted`
+  [1]
+
+  $ hg diff
+  diff -r f7c1071f1e7c ch
+  --- a/ch	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/ch	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +1,5 @@
+  +<<<<<<< local: f7c1071f1e7c - test: added c
+   ch
+  +=======
+  +chconflict
+  +>>>>>>> other: 229da2719b19 - test: added ch
+
+  $ echo ch > ch
+  $ hg res -m
+  (no more unresolved files)
+  continue: hg evolve --continue
+
+  $ hg evolve --continue
+  content-divergent changesets differ by descriptions only, discarding 229da2719b19
+  working directory is now at f7c1071f1e7c
+
+  $ hg evolve -l
+
+  $ hg par
+  changeset:   4:f7c1071f1e7c
+  tag:         tip
+  parent:      1:5f6d8a4bf34a
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     added c
+  
+Testing the case when "merging results in same as public cset" where:
+both the csets are on different parent and relocation leads to conflict but merging won't.
+------------------------------------------------------------------------------------------
+Prepare the repo:
+
+  $ cd ..
+  $ hg init pubdiv8
+  $ cd pubdiv8
+  $ for ch in a b c d; do
+  >   echo $ch > $ch;
+  >   hg ci -Am "added "$ch;
+  > done;
+  adding a
+  adding b
+  adding c
+  adding d
+
+  $ hg up 1
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ echo dh > dh
+  $ echo cc > c
+  $ hg add dh c
+  $ hg ci -m "added dh"
+  created new head
+
+  $ hg up 2
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo dh > dh
+  $ hg add dh
+  $ hg ci -m "added d"
+  created new head
+
+  $ hg glog
+  @  5:e800202333a4 added d
+  |   draft
+  |
+  | o  4:f89a8e2f86ac added dh
+  | |   draft
+  | |
+  +---o  3:9150fe93bec6 added d
+  | |     draft
+  | |
+  o |  2:155349b645be added c
+  |/    draft
+  |
+  o  1:5f6d8a4bf34a added b
+  |   draft
+  |
+  o  0:9092f1db7931 added a
+      draft
+  
+
+  $ hg prune 3 -s 4
+  1 changesets pruned
+  $ hg prune 3 -s 5 --hidden
+  1 changesets pruned
+  2 new content-divergent changesets
+  $ hg phase --public -r 5
+
+  $ hg glog
+  @  5:e800202333a4 added d
+  |   public
+  |
+  | *  4:f89a8e2f86ac added dh
+  | |   draft content-divergent
+  | |
+  o |  2:155349b645be added c
+  |/    public
+  |
+  o  1:5f6d8a4bf34a added b
+  |   public
+  |
+  o  0:9092f1db7931 added a
+      public
+  
+  $ hg evolve --content-divergent --any
+  merge:[5] added d
+  with: [4] added dh
+  base: [3] added d
+  rebasing "other" content-divergent changeset f89a8e2f86ac on 155349b645be
+  merging c
+  warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
+  fix conflicts and see `hg help evolve.interrupted`
+  [1]
+
+  $ echo c > c
+  $ hg res -m
+  (no more unresolved files)
+  continue: hg evolve --continue
+
+  $ hg evolve --continue
+  evolving 4:f89a8e2f86ac "added dh"
+  updating to "local" side of the conflict: e800202333a4
+  merging "other" content-divergent changeset 'bc309da55b88'
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  content-divergent changesets differ by descriptions only, discarding bc309da55b88
+  working directory is now at e800202333a4
+
+  $ hg evolve -l
+
+  $ hg par
+  changeset:   5:e800202333a4
+  tag:         tip
+  parent:      2:155349b645be
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     added d
+  
+Testing the case when "merging results in same as public cset" where:
+both the csets are on different parent and merging leads to conflict but relocation won't.
+------------------------------------------------------------------------------------------
+Prepare the repo:
+
+  $ cd ..
+  $ hg init pubdiv9
+  $ cd pubdiv9
+  $ for ch in a b c d; do
+  >   echo $ch > $ch;
+  >   hg ci -Am "added "$ch;
+  > done;
+  adding a
+  adding b
+  adding c
+  adding d
+
+  $ hg up 1
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ echo dhconflict > dh
+  $ hg add dh
+  $ hg ci -m "added dh"
+  created new head
+
+  $ hg up 2
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo dh > dh
+  $ hg add dh
+  $ hg ci -m "added d"
+  created new head
+
+  $ hg glog
+  @  5:e800202333a4 added d
+  |   draft
+  |
+  | o  4:db0b7bba0aae added dh
+  | |   draft
+  | |
+  +---o  3:9150fe93bec6 added d
+  | |     draft
+  | |
+  o |  2:155349b645be added c
+  |/    draft
+  |
+  o  1:5f6d8a4bf34a added b
+  |   draft
+  |
+  o  0:9092f1db7931 added a
+      draft
+  
+
+  $ hg prune 3 -s 4
+  1 changesets pruned
+  $ hg prune 3 -s 5 --hidden
+  1 changesets pruned
+  2 new content-divergent changesets
+  $ hg phase --public -r 5
+
+  $ hg glog
+  @  5:e800202333a4 added d
+  |   public
+  |
+  | *  4:db0b7bba0aae added dh
+  | |   draft content-divergent
+  | |
+  o |  2:155349b645be added c
+  |/    public
+  |
+  o  1:5f6d8a4bf34a added b
+  |   public
+  |
+  o  0:9092f1db7931 added a
+      public
+  
+  $ hg evolve --content-divergent --any
+  merge:[5] added d
+  with: [4] added dh
+  base: [3] added d
+  rebasing "other" content-divergent changeset db0b7bba0aae on 155349b645be
+  updating to "local" side of the conflict: e800202333a4
+  merging "other" content-divergent changeset 'a5bbf2042450'
+  merging dh
+  warning: conflicts while merging dh! (edit, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  fix conflicts and see `hg help evolve.interrupted`
+  [1]
+
+  $ echo dh > dh
+  $ hg res -m
+  (no more unresolved files)
+  continue: hg evolve --continue
+
+  $ hg evolve --continue
+  content-divergent changesets differ by descriptions only, discarding a5bbf2042450
+  working directory is now at e800202333a4
+
+  $ hg evolve -l
+
+  $ hg par
+  changeset:   5:e800202333a4
+  tag:         tip
+  parent:      2:155349b645be
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     added d
+  
+
+Testing the case when "merging results in same as public cset" where:
+both the csets are on different parent and relocation and merging both leads to conflict:
+-----------------------------------------------------------------------------------------
+Prepare the repo:
+
+  $ cd ..
+  $ hg init pubdiv10
+  $ cd pubdiv10
+  $ for ch in a b c d; do
+  >   echo $ch > $ch;
+  >   hg ci -Am "added "$ch;
+  > done;
+  adding a
+  adding b
+  adding c
+  adding d
+
+  $ hg up 1
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ echo dhconflict > dh
+  $ echo cc > c
+  $ hg add dh c
+  $ hg ci -m "added dh"
+  created new head
+
+  $ hg up 2
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo dh > dh
+  $ hg add dh
+  $ hg ci -m "added d"
+  created new head
+
+  $ hg glog
+  @  5:e800202333a4 added d
+  |   draft
+  |
+  | o  4:67b19bbd770f added dh
+  | |   draft
+  | |
+  +---o  3:9150fe93bec6 added d
+  | |     draft
+  | |
+  o |  2:155349b645be added c
+  |/    draft
+  |
+  o  1:5f6d8a4bf34a added b
+  |   draft
+  |
+  o  0:9092f1db7931 added a
+      draft
+  
+
+  $ hg prune 3 -s 4
+  1 changesets pruned
+  $ hg prune 3 -s 5 --hidden
+  1 changesets pruned
+  2 new content-divergent changesets
+  $ hg phase --public -r 5
+
+  $ hg glog
+  @  5:e800202333a4 added d
+  |   public
+  |
+  | *  4:67b19bbd770f added dh
+  | |   draft content-divergent
+  | |
+  o |  2:155349b645be added c
+  |/    public
+  |
+  o  1:5f6d8a4bf34a added b
+  |   public
+  |
+  o  0:9092f1db7931 added a
+      public
+  
+  $ hg evolve --content-divergent --any
+  merge:[5] added d
+  with: [4] added dh
+  base: [3] added d
+  rebasing "other" content-divergent changeset 67b19bbd770f on 155349b645be
+  merging c
+  warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
+  fix conflicts and see `hg help evolve.interrupted`
+  [1]
+
+  $ echo c > c
+  $ hg res -m
+  (no more unresolved files)
+  continue: hg evolve --continue
+
+  $ hg evolve --continue
+  evolving 4:67b19bbd770f "added dh"
+  updating to "local" side of the conflict: e800202333a4
+  merging "other" content-divergent changeset '09054d1f3c97'
+  merging dh
+  warning: conflicts while merging dh! (edit, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  fix conflicts and see `hg help evolve.interrupted`
+  [1]
+
+  $ echo dh > dh
+  $ hg res -m
+  (no more unresolved files)
+  continue: hg evolve --continue
+
+  $ hg evolve --continue
+  content-divergent changesets differ by descriptions only, discarding 09054d1f3c97
+  working directory is now at e800202333a4
+
+  $ hg evolve -l
+
+  $ hg par
+  changeset:   5:e800202333a4
+  tag:         tip
+  parent:      2:155349b645be
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     added d
+  
+
+  $ cd ..
+
+Test a pratical "rebase" case
+=============================
+
+Initial setup
+
+  $ hg init rebase-divergence
+  $ cd rebase-divergence
+  $ echo root >> root
+  $ hg add root
+  $ hg commit -m root
+  $ for x in c_A c_B c_C c_D; do
+  >     echo $x >> $x
+  >     hg add $x
+  >     hg commit -m $x
+  > done
+
+  $ hg up 'desc("c_A")'
+  0 files updated, 0 files merged, 3 files removed, 0 files unresolved
+
+  $ for x in c_E c_F; do
+  >     echo $x >> $x
+  >     hg add $x
+  >     hg commit -m $x
+  > done
+  created new head
+
+(creating divergence locally for simplicity)
+
+  $ node=`hg log --rev 'desc("c_E")' -T '{node}'`
+  $ hg rebase -s $node -d 'desc("c_B")'
+  rebasing 5:4ab2719bbab9 "c_E"
+  rebasing 6:77ccbf8d837e "c_F" (tip)
+  $ hg phase --public tip
+  $ hg rebase --hidden -s $node -d 'desc("c_C")' --config experimental.evolution.allowdivergence=yes
+  rebasing 5:4ab2719bbab9 "c_E"
+  rebasing 6:77ccbf8d837e "c_F"
+  2 new content-divergent changesets
+
+  $ hg sum
+  parent: 8:a52ac76b45f5 
+   c_F
+  branch: default
+  commit: (clean)
+  update: 4 new changesets, 3 branch heads (merge)
+  phases: 4 draft
+  content-divergent: 2 changesets
+  $ hg evolve --list
+  b4a584aea4bd: c_E
+    content-divergent: c7d2d47c7240 (public) (precursor 4ab2719bbab9)
+  
+  8ae8db670b4a: c_F
+    content-divergent: a52ac76b45f5 (public) (precursor 77ccbf8d837e)
+  
+  $ hg log -G --patch
+  *  changeset:   10:8ae8db670b4a
+  |  tag:         tip
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  instability: content-divergent
+  |  summary:     c_F
+  |
+  |  diff -r b4a584aea4bd -r 8ae8db670b4a c_F
+  |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/c_F	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -0,0 +1,1 @@
+  |  +c_F
+  |
+  *  changeset:   9:b4a584aea4bd
+  |  parent:      3:abb77b893f28
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  instability: content-divergent
+  |  summary:     c_E
+  |
+  |  diff -r abb77b893f28 -r b4a584aea4bd c_E
+  |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/c_E	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -0,0 +1,1 @@
+  |  +c_E
+  |
+  | @  changeset:   8:a52ac76b45f5
+  | |  user:        test
+  | |  date:        Thu Jan 01 00:00:00 1970 +0000
+  | |  summary:     c_F
+  | |
+  | |  diff -r c7d2d47c7240 -r a52ac76b45f5 c_F
+  | |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  | |  +++ b/c_F	Thu Jan 01 00:00:00 1970 +0000
+  | |  @@ -0,0 +1,1 @@
+  | |  +c_F
+  | |
+  | o  changeset:   7:c7d2d47c7240
+  | |  parent:      2:eb1b4e1205b8
+  | |  user:        test
+  | |  date:        Thu Jan 01 00:00:00 1970 +0000
+  | |  summary:     c_E
+  | |
+  | |  diff -r eb1b4e1205b8 -r c7d2d47c7240 c_E
+  | |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  | |  +++ b/c_E	Thu Jan 01 00:00:00 1970 +0000
+  | |  @@ -0,0 +1,1 @@
+  | |  +c_E
+  | |
+  +---o  changeset:   4:dbb960d6c97c
+  | |    user:        test
+  | |    date:        Thu Jan 01 00:00:00 1970 +0000
+  | |    summary:     c_D
+  | |
+  | |    diff -r abb77b893f28 -r dbb960d6c97c c_D
+  | |    --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  | |    +++ b/c_D	Thu Jan 01 00:00:00 1970 +0000
+  | |    @@ -0,0 +1,1 @@
+  | |    +c_D
+  | |
+  o |  changeset:   3:abb77b893f28
+  |/   user:        test
+  |    date:        Thu Jan 01 00:00:00 1970 +0000
+  |    summary:     c_C
+  |
+  |    diff -r eb1b4e1205b8 -r abb77b893f28 c_C
+  |    --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |    +++ b/c_C	Thu Jan 01 00:00:00 1970 +0000
+  |    @@ -0,0 +1,1 @@
+  |    +c_C
+  |
+  o  changeset:   2:eb1b4e1205b8
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     c_B
+  |
+  |  diff -r e31751786014 -r eb1b4e1205b8 c_B
+  |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/c_B	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -0,0 +1,1 @@
+  |  +c_B
+  |
+  o  changeset:   1:e31751786014
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     c_A
+  |
+  |  diff -r 1e4be0697311 -r e31751786014 c_A
+  |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/c_A	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -0,0 +1,1 @@
+  |  +c_A
+  |
+  o  changeset:   0:1e4be0697311
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     root
+  
+     diff -r 000000000000 -r 1e4be0697311 root
+     --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+     +++ b/root	Thu Jan 01 00:00:00 1970 +0000
+     @@ -0,0 +1,1 @@
+     +root
+  
+
+Run automatic evolution
+
+  $ hg evolve --content-divergent --rev 'not public() and desc("c_E")::'
+  merge:[7] c_E
+  with: [9] c_E
+  base: [5] c_E
+  rebasing "other" content-divergent changeset b4a584aea4bd on eb1b4e1205b8
+  updating to "local" side of the conflict: c7d2d47c7240
+  merging "other" content-divergent changeset '0773642cfa95'
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  1 new orphan changesets
+  merge:[8] c_F
+  with: [10] c_F
+  base: [6] c_F
+  rebasing "other" content-divergent changeset 8ae8db670b4a on c7d2d47c7240
+  updating to "local" side of the conflict: a52ac76b45f5
+  merging "other" content-divergent changeset '6a87ed4aa317'
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg sum
+  parent: 8:a52ac76b45f5 tip
+   c_F
+  branch: default
+  commit: (clean)
+  update: 2 new changesets, 2 branch heads (merge)
+  phases: 2 draft
+
+  $ hg evolve --list
+
+  $ hg log -G --patch
+  @  changeset:   8:a52ac76b45f5
+  |  tag:         tip
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     c_F
+  |
+  |  diff -r c7d2d47c7240 -r a52ac76b45f5 c_F
+  |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/c_F	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -0,0 +1,1 @@
+  |  +c_F
+  |
+  o  changeset:   7:c7d2d47c7240
+  |  parent:      2:eb1b4e1205b8
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     c_E
+  |
+  |  diff -r eb1b4e1205b8 -r c7d2d47c7240 c_E
+  |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/c_E	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -0,0 +1,1 @@
+  |  +c_E
+  |
+  | o  changeset:   4:dbb960d6c97c
+  | |  user:        test
+  | |  date:        Thu Jan 01 00:00:00 1970 +0000
+  | |  summary:     c_D
+  | |
+  | |  diff -r abb77b893f28 -r dbb960d6c97c c_D
+  | |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  | |  +++ b/c_D	Thu Jan 01 00:00:00 1970 +0000
+  | |  @@ -0,0 +1,1 @@
+  | |  +c_D
+  | |
+  | o  changeset:   3:abb77b893f28
+  |/   user:        test
+  |    date:        Thu Jan 01 00:00:00 1970 +0000
+  |    summary:     c_C
+  |
+  |    diff -r eb1b4e1205b8 -r abb77b893f28 c_C
+  |    --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |    +++ b/c_C	Thu Jan 01 00:00:00 1970 +0000
+  |    @@ -0,0 +1,1 @@
+  |    +c_C
+  |
+  o  changeset:   2:eb1b4e1205b8
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     c_B
+  |
+  |  diff -r e31751786014 -r eb1b4e1205b8 c_B
+  |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/c_B	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -0,0 +1,1 @@
+  |  +c_B
+  |
+  o  changeset:   1:e31751786014
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     c_A
+  |
+  |  diff -r 1e4be0697311 -r e31751786014 c_A
+  |  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  |  +++ b/c_A	Thu Jan 01 00:00:00 1970 +0000
+  |  @@ -0,0 +1,1 @@
+  |  +c_A
+  |
+  o  changeset:   0:1e4be0697311
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     root
+  
+     diff -r 000000000000 -r 1e4be0697311 root
+     --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+     +++ b/root	Thu Jan 01 00:00:00 1970 +0000
+     @@ -0,0 +1,1 @@
+     +root
+  
+  $ hg export tip
+  # HG changeset patch
+  # User test
+  # Date 0 0
+  #      Thu Jan 01 00:00:00 1970 +0000
+  # Node ID a52ac76b45f523a039fc4a938d79874f4bdb1a85
+  # Parent  c7d2d47c7240562be5cbd1a24080dd0396178709
+  c_F
+  
+  diff -r c7d2d47c7240 -r a52ac76b45f5 c_F
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/c_F	Thu Jan 01 00:00:00 1970 +0000
+  @@ -0,0 +1,1 @@
+  +c_F
+
+  $ hg obslog --rev a52ac76b45f5
+  @    a52ac76b45f5 (8) c_F
+  |\
+  x |  6a87ed4aa317 (12) c_F
+  | |    rewritten as a52ac76b45f5 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+  | |
+  x |  8ae8db670b4a (10) c_F
+  |/     rewritten(parent) as 6a87ed4aa317 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
+  |
+  x  77ccbf8d837e (6) c_F
+       rewritten(parent) as 8ae8db670b4a using rebase by test (Thu Jan 01 00:00:00 1970 +0000)
+       rewritten(parent) as a52ac76b45f5 using rebase by test (Thu Jan 01 00:00:00 1970 +0000)
+  
--- a/tests/test-evolve-templates.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-evolve-templates.t	Thu Apr 11 22:13:55 2019 +0200
@@ -245,8 +245,8 @@
   o  ea207398892e
   
 
-Test templates with splitted commit
-===================================
+Test templates with split commit
+================================
 
   $ hg init $TESTTMP/templates-local-split
   $ cd $TESTTMP/templates-local-split
@@ -1313,7 +1313,7 @@
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     ROOT
   
-Diverge one of the splitted commit
+Diverge one of the split commit
 
   $ hg up 6
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
--- a/tests/test-evolve-topic.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-evolve-topic.t	Thu Apr 11 22:13:55 2019 +0200
@@ -126,8 +126,8 @@
   $ hg stack
   ### topic: foo
   ### target: default (branch)
-  s4$ add fff (current unstable)
-  s3$ add eee (unstable)
+  s4@ add fff (current orphan)
+  s3$ add eee (orphan)
   s2: add ddd
   s1: add ccc
   s0^ add bbb (base)
@@ -265,10 +265,10 @@
   $ hg stack
   ### topic: bar
   ### target: default (branch)
-  s5$ add jjj (unstable)
-  s4$ add iii (unstable)
-  s3$ add hhh (unstable)
-  s2$ add ggg (current unstable)
+  s5$ add jjj (orphan)
+  s4$ add iii (orphan)
+  s3$ add hhh (orphan)
+  s2@ add ggg (current orphan)
   s1: add fff
   s0^ add eee (base)
 
--- a/tests/test-evolve.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-evolve.t	Thu Apr 11 22:13:55 2019 +0200
@@ -81,23 +81,22 @@
       explicitly assert support for the obsolescence feature (this can currently
       only be done via an extension).
   
-      Instability ==========
+      Instability
+      ===========
   
-      (note: the vocabulary is in the process of being updated)
-  
-      Rewriting changesets might introduce instability (currently 'trouble').
+      Rewriting changesets might introduce instability.
   
       There are two main kinds of instability: orphaning and diverging.
   
-      Orphans are changesets left behind when their ancestors are rewritten,
-      (currently: 'unstable'). Divergence has two variants:
+      Orphans are changesets left behind when their ancestors are rewritten.
+      Divergence has two variants:
   
       * Content-divergence occurs when independent rewrites of the same
-        changesets lead to different results. (currently: 'divergent')
+        changesets lead to different results.
       * Phase-divergence occurs when the old (obsolete) version of a changeset
-        becomes public. (currently: 'bumped')
+        becomes public.
   
-      If it possible to prevent local creation of orphans by using the following
+      It is possible to prevent local creation of orphans by using the following
       config:
   
         [experimental]
@@ -390,12 +389,12 @@
   4	feature-A: a nifty feature - test
   0	: base - test
 
-phase change turning obsolete changeset public issue a bumped warning
+phase change turning obsolete changeset public issues a phase divergence warning
 
   $ hg phase --hidden --public 99833d22b0c6
   1 new phase-divergent changesets
 
-all solving bumped troubled
+all solving phase-divergent
 
   $ glog
   @  6:47d52a103155@default(draft) another feature that rox
@@ -409,7 +408,6 @@
   $ hg evolve --any --traceback --phase-divergent
   recreate:[6] another feature that rox
   atop:[5] another feature (child of ba0ec09b1bab)
-  computing new diff
   committed as aca219761afb
   working directory is now at aca219761afb
   $ glog
@@ -429,7 +427,7 @@
   @@ -3,1 +3,1 @@
   -Zwei
   +deux
-  $ hg log -r 'phasedivergent()' # no more bumped
+  $ hg log -r 'phasedivergent()' # no more phase-divergent
 
 test evolve --all
   $ sed -i'' -e s/deux/to/ main-file-1
@@ -1000,8 +998,8 @@
   o  0:07c1c36d9ef0@default(draft) a0
   
 
-Possibility to select what trouble to solve first, asking for bumped before
-divergent
+Possibility to select what instability to solve first, asking for
+phase-divergent before content-divergent
   $ hg up -r "desc('a1__')"
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg revert -r d952e93add6f --all
@@ -1040,8 +1038,8 @@
   o  0	: a0 - test
   
 
-Now we have a bumped and an unstable changeset, we solve the bumped first
-normally the unstable changeset would be solve first
+Now we have a phase-divergent and an orphan changeset, we solve the
+phase-divergent first. Normally the orphan changeset would be solved first
 
   $ hg log -G
   @  11	: add new file bumped - test
@@ -1061,7 +1059,6 @@
   $ hg evolve -r "desc('add new file bumped')" --phase-divergent
   recreate:[11] add new file bumped
   atop:[10] a2
-  computing new diff
   committed as a8bb31d4b7f2
   working directory is now at a8bb31d4b7f2
   $ hg evolve --any
@@ -1080,7 +1077,7 @@
   o  0:07c1c36d9ef0@default(public) a0
   
 
-Check that we can resolve troubles in a revset with more than one commit
+Check that we can resolve instabilities in a revset with more than one commit
   $ hg up b88539ad24d7 -C
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ mkcommit gg
@@ -1537,7 +1534,7 @@
   adding a
   adding b
   adding c
-Lets create a merge commit so that we can create orhpan merge later:
+Let's create a merge commit so that we can create orphan merge later:
   $ hg up 1 -q
   $ echo feature > f
   $ hg ci -Am "added feature f"
@@ -1584,7 +1581,7 @@
   
 
 To check `lastsolved` contain right value after completion of orphan-merge
-resolution there should be one more trouble to be evolved; lets create one:
+resolution there should be one more instability to be evolved; lets create one:
   $ hg up 1 -q
   $ echo d > d
   $ hg ci -Am "added d"
--- a/tests/test-obsolete.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-obsolete.t	Thu Apr 11 22:13:55 2019 +0200
@@ -236,7 +236,7 @@
   abort: push includes orphan changeset: 95de7fc6918d!
   (use 'hg evolve' to get a stable history or --force to ignore warnings)
   [255]
-  $ hg push ../other-new -f # use f because there is unstability
+  $ hg push ../other-new -f # use f because there is an orphan
   pushing to ../other-new
   searching for changes
   adding changesets
@@ -431,7 +431,7 @@
   1 new phase-divergent changesets
 83b5778897ad try to obsolete immutable changeset 1f0dee641bb7
 # at core level the warning is not issued
-# this is now a big issue now that we have bumped warning
+# this is now a big issue now that we have phase divergence warning
   $ qlog -r 'obsolete()'
   3
   - 0d3f46688ccc
@@ -574,7 +574,7 @@
   obsoleted 1 changesets
   $ cd ..
 
-check bumped detection
+check phase divergence detection
 (make an obsolete changeset public)
 
   $ cd local
--- a/tests/test-pick.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-pick.t	Thu Apr 11 22:13:55 2019 +0200
@@ -24,9 +24,10 @@
   
   options:
   
-   -r --rev REV  revision to pick
-   -c --continue continue interrupted pick
-   -a --abort    abort interrupted pick
+   -r --rev REV   revision to pick
+   -c --continue  continue interrupted pick
+   -a --abort     abort interrupted pick
+   -t --tool TOOL specify merge tool
   
   (some details hidden, use --verbose to show complete help)
 
--- a/tests/test-prev-next.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-prev-next.t	Thu Apr 11 22:13:55 2019 +0200
@@ -213,13 +213,13 @@
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   [3] added b (2)
   $ hg next <<EOF
-  > 1
+  > 2
   > EOF
   ambiguous next changeset, choose one to update:
-  0: [e3b6d5df389b] added c
-  1: [9df671ccd2c7] added d
+  1: [e3b6d5df389b] added c
+  2: [9df671ccd2c7] added d
   q: quit the prompt
-  enter the index of the revision you want to select: 1
+  enter the index of the revision you want to select: 2
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   [5] added d
 
@@ -236,13 +236,13 @@
   (2 unstable changesets to be evolved here, do you want --evolve?)
   [1]
   $ hg next --evolve <<EOF
-  > 0
+  > 1
   > EOF
   ambiguous next (unstable) changeset, choose one to evolve and update:
-  0: [e3b6d5df389b] added c
-  1: [9df671ccd2c7] added d
+  1: [e3b6d5df389b] added c
+  2: [9df671ccd2c7] added d
   q: quit the prompt
-  enter the index of the revision you want to select: 0
+  enter the index of the revision you want to select: 1
   move:[4] added c
   atop:[6] added b (3)
   working directory now at 5ce67c2407b0
@@ -284,8 +284,8 @@
   > q
   > EOF
   multiple parents, choose one to update:
-  0: [47ea25be8aea] added d
-  1: [5ce67c2407b0] added c
+  1: [47ea25be8aea] added d
+  2: [5ce67c2407b0] added c
   q: quit the prompt
   enter the index of the revision you want to select: q
   [8] added d
@@ -300,13 +300,13 @@
   [1]
 
   $ hg prev <<EOF
-  > 1
+  > 2
   > EOF
   multiple parents, choose one to update:
-  0: [47ea25be8aea] added d
-  1: [5ce67c2407b0] added c
+  1: [47ea25be8aea] added d
+  2: [5ce67c2407b0] added c
   q: quit the prompt
-  enter the index of the revision you want to select: 1
+  enter the index of the revision you want to select: 2
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   [7] added c
 
@@ -443,9 +443,14 @@
 
 Test that --merge still works fine with commands.update.check set
 
-XXX: yes we want --merge and we passed that!
+  $ hg config commands.update.check
+  noconflict
   $ echo hi > bar
   $ echo bar >> bar
+  $ hg next
+  abort: conflicting changes
+  (do you want --merge?)
+  [255]
   $ hg next --merge
   merging bar
   warning: conflicts while merging bar! (edit, then use 'hg resolve --mark')
@@ -459,7 +464,10 @@
 
 Testing --merge works with other values of commands.update.check also
 
-XXX: things are broken!
+  $ hg prev --config commands.update.check=abort
+  abort: uncommitted changes
+  (do you want --merge?)
+  [255]
   $ hg prev --merge --config commands.update.check=abort
   file 'bar' was deleted in other [destination] but was modified in local [working copy].
   What do you want to do?
@@ -477,6 +485,10 @@
   $ echo bar > bar
   $ hg add bar
 
+  $ hg next --config commands.update.check=abort
+  abort: uncommitted changes
+  (do you want --merge?)
+  [255]
   $ hg next --merge --config commands.update.check=abort
   merging bar
   warning: conflicts while merging bar! (edit, then use 'hg resolve --mark')
--- a/tests/test-push-checkheads-unpushed-D5.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-push-checkheads-unpushed-D5.t	Thu Apr 11 22:13:55 2019 +0200
@@ -24,7 +24,7 @@
 ..
 .. * push the new branch only -> push denied
 .. * push the existing branch only -> push allowed
-..   /!\ This push create unstability/orphaning on the other hand and we should
+..   /!\ This push create instability/orphaning on the other hand and we should
 ..  probably detect/warn agains that.
 ..
 .. graph-summary:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-share.t	Thu Apr 11 22:13:55 2019 +0200
@@ -0,0 +1,20 @@
+Test that share-clones use the cache in the original repository.
+
+  $ . $TESTDIR/testlib/common.sh
+
+  $ hg init share-base
+  $ cd share-base/
+  $ cat >> .hg/hgrc <<EOF
+  > [extensions]
+  > evolve=
+  > share=
+  > EOF
+  $ hg debugbuilddag .+3:branchpoint+4*branchpoint+2
+  $ cd ..
+  $ hg --config extensions.share= share -U share-base share-client
+  $ cd share-client
+  $ hg debugupdatecache
+  $ test -d .hg/cache
+  [1]
+  $ test -d ../share-base/.hg/cache
+
--- a/tests/test-sharing.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-sharing.t	Thu Apr 11 22:13:55 2019 +0200
@@ -423,8 +423,9 @@
   ~
   $ cd ..
 
-Setup for shared mutable history (to illustrate divergent
-and bumped changesets).
+Setup for shared mutable history (to illustrate content-divergence and
+phase-divergent changesets).
+
   $ rm -rf review alice bob
   $ hg clone public alice
   updating to branch default
--- a/tests/test-split.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-split.t	Thu Apr 11 22:13:55 2019 +0200
@@ -19,6 +19,8 @@
   > [diff]
   > git = 1
   > unified = 0
+  > [commands]
+  > commit.interactive.unified = 0
   > [ui]
   > interactive = true
   > [extensions]
@@ -485,15 +487,15 @@
   $ hg add SPLIT1 SPLIT2
   $ hg branch another-branch
   marked working directory as branch another-branch
-  $ hg commit -m "To be splitted"
+  $ hg commit -m "To be split"
   $ hg log -G -l 3
-  @  changeset:   21:8dad923bdb9b
+  @  changeset:   21:b6bf93dd314b
   |  branch:      another-branch
   |  tag:         tip
   |  topic:       mytopic
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     To be splitted
+  |  summary:     To be split
   |
   o  changeset:   20:2532b288af61
   |  branch:      new-branch
@@ -516,10 +518,10 @@
   # Date 0 0
   #      Thu Jan 01 00:00:00 1970 +0000
   # Branch another-branch
-  # Node ID 8dad923bdb9bb3b99291caa5baeb03bbc30dfd33
+  # Node ID b6bf93dd314ba47b838befc7488b2223981684ea
   # Parent  2532b288af61bd19239a95ae2a3ecb9b0ad4b8e1
   # EXP-Topic mytopic
-  To be splitted
+  To be split
   
   diff --git a/SPLIT1 b/SPLIT1
   new file mode 100644
@@ -550,7 +552,7 @@
   
   no more change to split
 
-The splitted changesets should be on the 'another-branch'
+The split changesets should be on the 'another-branch'
   $ hg log -G -l 3
   @  changeset:   23:56a59faa8af7
   |  branch:      another-branch
@@ -582,19 +584,19 @@
   marked working directory as branch yet-another-branch
   $ touch SPLIT3 SPLIT4
   $ hg add SPLIT3 SPLIT4
-  $ hg commit -m "To be splitted again"
+  $ hg commit -m "To be split again"
 
   $ hg up "tip~1"
   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
 
   $ hg log -G -l 2
-  o  changeset:   24:b1020d17c364
+  o  changeset:   24:9f56497dbac1
   |  branch:      yet-another-branch
   |  tag:         tip
   |  topic:       mytopic
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     To be splitted again
+  |  summary:     To be split again
   |
   @  changeset:   23:56a59faa8af7
   |  branch:      another-branch
@@ -628,13 +630,13 @@
   another-branch
 
   $ hg log -G -l 2
-  o  changeset:   24:b1020d17c364
+  o  changeset:   24:9f56497dbac1
   |  branch:      yet-another-branch
   |  tag:         tip
   |  topic:       mytopic
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     To be splitted again
+  |  summary:     To be split again
   |
   @  changeset:   23:56a59faa8af7
   |  branch:      another-branch
--- a/tests/test-stabilize-result.t	Wed Apr 10 16:11:59 2019 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,206 +0,0 @@
-  $ cat >> $HGRCPATH <<EOF
-  > [defaults]
-  > amend=-d "0 0"
-  > [extensions]
-  > hgext.rebase=
-  > EOF
-  $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
-
-  $ glog() {
-  >   hg log -G --template \
-  >     '{rev}:{node|short}@{branch}({phase}) bk:[{bookmarks}] {desc|firstline}\n' "$@"
-  > }
-
-Test evolve removing the changeset being evolved
-
-  $ hg init empty
-  $ cd empty
-  $ echo a > a
-  $ hg ci -Am adda a
-  $ echo b > b
-  $ hg ci -Am addb b
-  $ echo a >> a
-  $ hg ci -m changea
-  $ hg bookmark changea
-  $ hg up 1
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  (leaving bookmark changea)
-  $ echo a >> a
-  $ hg amend -m changea
-  1 new orphan changesets
-  $ hg evolve -v --confirm
-  move:[2] changea
-  atop:[3] changea
-  perform evolve? [Ny] n
-  abort: evolve aborted by user
-  [255]
-  $ echo y | hg evolve -v --confirm --config ui.interactive=True
-  move:[2] changea
-  atop:[3] changea
-  perform evolve? [Ny] y
-  hg rebase -r cce2c55b8965 -d fb9d051ec0a4
-  resolving manifests
-  evolution of 2:cce2c55b8965 created no changes to commit
-
-  $ glog --hidden
-  @  3:fb9d051ec0a4@default(draft) bk:[changea] changea
-  |
-  | x  2:cce2c55b8965@default(draft) bk:[] changea
-  | |
-  | x  1:102a90ea7b4a@default(draft) bk:[] addb
-  |/
-  o  0:07f494440405@default(draft) bk:[] adda
-  
-  $ hg debugobsolete
-  102a90ea7b4a3361e4082ed620918c261189a36a fb9d051ec0a450a4aa2ffc8c324979832ef88065 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'operation': 'amend', 'user': 'test'}
-  cce2c55b896511e0b6e04173c9450ba822ebc740 0 {102a90ea7b4a3361e4082ed620918c261189a36a} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'evolve', 'user': 'test'}
-
-Test evolve with conflict
-
-  $ ls
-  a
-  b
-  $ hg pdiff a
-  diff -r 07f494440405 a
-  --- a/a	Thu Jan 01 00:00:00 1970 +0000
-  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
-  @@ -1,1 +1,2 @@
-   a
-  +a
-  $ echo 'newer a' >> a
-  $ hg ci -m 'newer a'
-  $ hg gdown
-  gdown have been deprecated in favor of previous
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  [3] changea
-  $ echo 'a' > a
-  $ hg amend
-  1 new orphan changesets
-  $ hg evolve
-  move:[4] newer a
-  atop:[5] changea
-  merging a
-  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
-  fix conflicts and see `hg help evolve.interrupted`
-  [1]
-  $ hg revert -r "orphan()" a
-  $ hg diff
-  diff -r 66719795a494 a
-  --- a/a	Thu Jan 01 00:00:00 1970 +0000
-  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
-  @@ -1,1 +1,3 @@
-   a
-  +a
-  +newer a
-  $ hg evolve --continue
-  abort: unresolved merge conflicts (see 'hg help resolve')
-  [255]
-  $ hg resolve -m a
-  (no more unresolved files)
-  continue: hg evolve --continue
-  $ hg evolve --continue
-  evolving 4:3655f0f50885 "newer a"
-  working directory is now at 1cf0aacfd363
-
-Stabilize latecomer with different parent
-=========================================
-
-(the same-parent case is handled in test-evolve.t)
-
-  $ glog
-  @  6:1cf0aacfd363@default(draft) bk:[] newer a
-  |
-  o  5:66719795a494@default(draft) bk:[changea] changea
-  |
-  o  0:07f494440405@default(draft) bk:[] adda
-  
-Add another commit
-
-  $ hg gdown
-  gdown have been deprecated in favor of previous
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  [5] changea
-  $ echo 'c' > c
-  $ hg add c
-  $ hg commit -m 'add c'
-  created new head
-
-Get a successors of 8 on it
-
-  $ hg pick 1cf0aacfd363
-  picking 6:1cf0aacfd363 "newer a"
-
-Add real change to the successors
-
-  $ echo 'babar' >> a
-  $ hg amend
-
-Make precursors public
-
-  $ hg phase --hidden --public 1cf0aacfd363
-  1 new phase-divergent changesets
-  $ glog
-  @  9:99c21c89bcef@default(draft) bk:[] newer a
-  |
-  o  7:7bc2f5967f5e@default(draft) bk:[] add c
-  |
-  | o  6:1cf0aacfd363@default(public) bk:[] newer a
-  |/
-  o  5:66719795a494@default(public) bk:[changea] changea
-  |
-  o  0:07f494440405@default(public) bk:[] adda
-  
-
-Stabilize!
-
-  $ hg evolve --any --dry-run --phase-divergent
-  recreate:[9] newer a
-  atop:[6] newer a
-  hg rebase --rev 99c21c89bcef --dest 66719795a494;
-  hg update 1cf0aacfd363;
-  hg revert --all --rev 99c21c89bcef;
-  hg commit --msg "phase-divergent update to 99c21c89bcef"
-  $ hg evolve --any --confirm --phase-divergent
-  recreate:[9] newer a
-  atop:[6] newer a
-  perform evolve? [Ny] n
-  abort: evolve aborted by user
-  [255]
-  $ echo y | hg evolve --any --confirm --config ui.interactive=True --phase-divergent
-  recreate:[9] newer a
-  atop:[6] newer a
-  perform evolve? [Ny] y
-  rebasing to destination parent: 66719795a494
-  computing new diff
-  committed as 8fc63fe1f297
-  working directory is now at 8fc63fe1f297
-  $ glog
-  @  11:8fc63fe1f297@default(draft) bk:[] phase-divergent update to 1cf0aacfd363:
-  |
-  | o  7:7bc2f5967f5e@default(draft) bk:[] add c
-  | |
-  o |  6:1cf0aacfd363@default(public) bk:[] newer a
-  |/
-  o  5:66719795a494@default(public) bk:[changea] changea
-  |
-  o  0:07f494440405@default(public) bk:[] adda
-  
-  $ hg exp
-  # HG changeset patch
-  # User test
-  # Date 0 0
-  #      Thu Jan 01 00:00:00 1970 +0000
-  # Node ID 8fc63fe1f297f356d1156bbbbe865b9911efad74
-  # Parent  1cf0aacfd36310b18e403e1594871187e0364a82
-  phase-divergent update to 1cf0aacfd363:
-  
-  newer a
-  
-  diff -r 1cf0aacfd363 -r 8fc63fe1f297 a
-  --- a/a	Thu Jan 01 00:00:00 1970 +0000
-  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
-  @@ -1,3 +1,4 @@
-   a
-   a
-   newer a
-  +babar
--- a/tests/test-stack-branch.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-stack-branch.t	Thu Apr 11 22:13:55 2019 +0200
@@ -105,7 +105,7 @@
   phases: 4 draft
 
 Case with some of the branch unstable
-------------------------------------
+-------------------------------------
 
   $ echo bbb > ddd
   $ hg commit --amend
@@ -127,8 +127,8 @@
   
   $ hg stack
   ### target: foo (branch)
-  s4$ c_f (unstable)
-  s3$ c_e (unstable)
+  s4$ c_f (orphan)
+  s3$ c_e (orphan)
   s2@ c_d (current)
   s1: c_c
   s0^ c_b (base)
@@ -136,8 +136,8 @@
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg stack
   ### target: foo (branch)
-  s4$ c_f (unstable)
-  s3$ c_e (current unstable)
+  s4$ c_f (orphan)
+  s3@ c_e (current orphan)
   s2: c_d
   s1: c_c
   s0^ c_b (base)
@@ -217,7 +217,7 @@
   s1: c_c
   s0^ c_b (base)
 
-Case with multiple heads on the topic with unstability involved
+Case with multiple heads on the topic with instability involved
 ---------------------------------------------------------------
 
 We amend the message to make sure the display base pick the right changeset
@@ -255,8 +255,8 @@
   s6: c_h
   s5: c_g
   s2^ c_D (base current)
-  s4$ c_f (unstable)
-  s3$ c_e (unstable)
+  s4$ c_f (orphan)
+  s3$ c_e (orphan)
   s2@ c_D (current)
   s1: c_c
   s0^ c_b (base)
@@ -289,8 +289,8 @@
   s6: c_h
   s5: c_g
   s2^ c_D (base current)
-  s4$ c_f (unstable)
-  s3$ c_e (unstable)
+  s4$ c_f (orphan)
+  s3$ c_e (orphan)
   s2@ c_D (current)
   s1: c_c
   s0^ c_b (base)
@@ -300,8 +300,8 @@
   s5: c_h
   s4: c_g
   s1^ c_D (base current)
-  s3$ c_f (unstable)
-  s2$ c_e (unstable)
+  s3$ c_f (orphan)
+  s2$ c_e (orphan)
   s1@ c_D (current)
   s0^ c_c (base)
 
@@ -312,7 +312,7 @@
   changed topic on 2 changesets to "sometopic"
   $ hg stack
   ### target: foo (branch)
-  s3$ c_f (unstable)
-  s2$ c_e (unstable)
+  s3$ c_f (orphan)
+  s2$ c_e (orphan)
   s1@ c_D (current)
   s0^ c_c (base)
--- a/tests/test-topic-stack-complex.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-topic-stack-complex.t	Thu Apr 11 22:13:55 2019 +0200
@@ -86,7 +86,7 @@
   $ hg stack
   ### topic: foo
   ### target: default (branch)
-  s4$ Added e and f (unstable)
+  s4$ Added e and f (orphan)
   s3@ split2 (current)
   s2: split1
   s1: Added a and b
@@ -129,8 +129,8 @@
   $ hg stack
   ### topic: foo (2 heads)
   ### target: default (branch), 2 behind
-  s4$ Added e and f (unstable)
-  s3$ split2 (unstable)
+  s4$ Added e and f (orphan)
+  s3$ split2 (orphan)
   s2@ split1 (current)
   s1: Added a and b
   s0^ Added foo (base)
@@ -161,9 +161,9 @@
   $ hg stack
   ### topic: foo (2 heads)
   ### target: default (branch)
-  s5: Added e and f
+  s5$ Added e and f (content divergent)
   s3^ split2 (base)
-  s4@ Added e and f (current)
+  s4@ Added e and f (content divergent current)
   s3: split2
   s2: split1
   s1: Added a and b
--- a/tests/test-topic-stack-data.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-topic-stack-data.t	Thu Apr 11 22:13:55 2019 +0200
@@ -61,7 +61,7 @@
   (see 'hg help topics' for more information)
   $ mkcommit baz_b
 
-A simple topic with unstability
+A simple topic with instability
 
   $ hg up 'desc(base_d)'
   1 files updated, 0 files merged, 2 files removed, 0 files unresolved
@@ -266,7 +266,7 @@
   ### target: default (branch)
   s5: add bar_c
   s2^ add bar_b (base)
-  s4$ add bar_e (unstable)
+  s4$ add bar_e (orphan)
   s3: bar1_d
   s2: add bar_b
   s1: add bar_a
@@ -276,7 +276,7 @@
   ### target: default (branch)
   s5(9cbadf11b44d): add bar_c
   s2(e555c7e8c767)^ add bar_b (base)
-  s4(a920412b5a05)$ add bar_e (unstable)
+  s4(a920412b5a05)$ add bar_e (orphan)
   s3(6915989374b1): bar1_d
   s2(e555c7e8c767): add bar_b
   s1(a5c2b4e00bbf): add bar_a
@@ -296,7 +296,7 @@
   $ hg stack fuz
   ### topic: fuz
   ### target: default (branch), 1 behind
-  s3$ add fuz_c (unstable)
-  s2$ add fuz_b (unstable)
+  s3$ add fuz_c (orphan)
+  s2$ add fuz_b (orphan)
   s1: fuz1_a
   s0^ add base_d (base)
--- a/tests/test-topic-stack.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-topic-stack.t	Thu Apr 11 22:13:55 2019 +0200
@@ -331,8 +331,8 @@
   $ hg topic --list
   ### topic: foo
   ### target: default (branch)
-  s4$ c_f (unstable)
-  s3$ c_e (unstable)
+  s4$ c_f (orphan)
+  s3$ c_e (orphan)
   s2@ c_d (current)
   s1: c_c
   s0^ c_b (base)
@@ -341,16 +341,16 @@
   $ hg topic --list
   ### topic: foo
   ### target: default (branch)
-  s4$ c_f (unstable)
-  s3$ c_e (current unstable)
+  s4$ c_f (orphan)
+  s3@ c_e (current orphan)
   s2: c_d
   s1: c_c
   s0^ c_b (base)
   $ hg topic --list --color=debug
   [topic.stack.summary.topic|### topic: [topic.active|foo]]
   [topic.stack.summary.branches|### target: default (branch)]
-  [topic.stack.index topic.stack.index.unstable|s4][topic.stack.state topic.stack.state.unstable|$] [topic.stack.desc topic.stack.desc.unstable|c_f][topic.stack.state topic.stack.state.unstable| (unstable)]
-  [topic.stack.index topic.stack.index.current topic.stack.index.unstable|s3][topic.stack.state topic.stack.state.current topic.stack.state.unstable|$] [topic.stack.desc topic.stack.desc.current topic.stack.desc.unstable|c_e][topic.stack.state topic.stack.state.current topic.stack.state.unstable| (current unstable)]
+  [topic.stack.index topic.stack.index.orphan|s4][topic.stack.state topic.stack.state.orphan|$] [topic.stack.desc topic.stack.desc.orphan|c_f][topic.stack.state topic.stack.state.orphan| (orphan)]
+  [topic.stack.index topic.stack.index.current topic.stack.index.orphan|s3][topic.stack.state topic.stack.state.current topic.stack.state.orphan|@] [topic.stack.desc topic.stack.desc.current topic.stack.desc.orphan|c_e][topic.stack.state topic.stack.state.current topic.stack.state.orphan| (current orphan)]
   [topic.stack.index topic.stack.index.clean|s2][topic.stack.state topic.stack.state.clean|:] [topic.stack.desc topic.stack.desc.clean|c_d]
   [topic.stack.index topic.stack.index.clean|s1][topic.stack.state topic.stack.state.clean|:] [topic.stack.desc topic.stack.desc.clean|c_c]
   [topic.stack.index topic.stack.index.base|s0][topic.stack.state topic.stack.state.base|^] [topic.stack.desc topic.stack.desc.base|c_b][topic.stack.state topic.stack.state.base| (base)]
@@ -488,8 +488,8 @@
   s6: c_h
   s5: c_g
   s2^ c_D (base current)
-  s4$ c_f (unstable)
-  s3$ c_e (unstable)
+  s4$ c_f (orphan)
+  s3$ c_e (orphan)
   s2@ c_D (current)
   s1: c_c
   s0^ c_b (base)
@@ -767,24 +767,24 @@
   $ hg stack red
   ### topic: red
   ### target: default (branch), ambiguous rebase destination - topic 'red' has 3 heads
-  s5$ c_H (unstable)
+  s5$ c_H (orphan)
     ^ c_G
     ^ c_D
-  s4$ c_C (unstable)
+  s4$ c_C (orphan)
   s1^ c_B (base)
-  s3$ c_F (unstable)
-  s2$ c_E (unstable)
+  s3$ c_F (orphan)
+  s2$ c_E (orphan)
   s1: c_B
   s0^ c_A (base)
   $ hg stack blue
   ### topic: blue
   ### target: default (branch), ambiguous rebase destination - topic 'blue' has 3 heads
-  s3$ c_I (unstable)
+  s3$ c_I (orphan)
     ^ c_H
-  s2$ c_G (unstable)
+  s2$ c_G (orphan)
     ^ c_F
-  s1$ c_D (current unstable)
-  s0^ c_C (base unstable)
+  s1@ c_D (current orphan)
+  s0^ c_C (base orphan)
 
 more obsolescence
 
@@ -841,24 +841,24 @@
   $ hg stack red
   ### topic: red
   ### target: default (branch), ambiguous rebase destination - topic 'red' has 3 heads
-  s5$ c_H (unstable)
+  s5$ c_H (orphan)
     ^ c_G
     ^ c_D
-  s4$ c_F (unstable)
-  s3$ c_E (unstable)
+  s4$ c_F (orphan)
+  s3$ c_E (orphan)
   s1^ c_B (base)
-  s2$ c_C (unstable)
+  s2$ c_C (orphan)
   s1: c_B
   s0^ c_A (base)
   $ hg stack blue
   ### topic: blue
   ### target: default (branch), ambiguous rebase destination - topic 'blue' has 3 heads
-  s3$ c_I (unstable)
+  s3$ c_I (orphan)
     ^ c_H
-  s2$ c_G (unstable)
+  s2$ c_G (orphan)
     ^ c_F
-  s1$ c_D (current unstable)
-  s0^ c_C (base unstable)
+  s1@ c_D (current orphan)
+  s0^ c_C (base orphan)
 
 Test stack behavior with a split
 --------------------------------
@@ -897,7 +897,7 @@
   $ hg stack
   ### topic: blue
   ### target: default (branch)
-  s3$ c_I (unstable)
+  s3$ c_I (orphan)
   s2@ c_G (current)
   s1: c_D
   s0^ c_A (base)
@@ -977,7 +977,7 @@
   $ hg stack
   ### topic: blue
   ### target: default (branch)
-  s4$ c_I (unstable)
+  s4$ c_I (orphan)
   s3@ c_G (current)
   s2: c_G
   s1: c_D
--- a/tests/test-topic-tutorial.t	Wed Apr 10 16:11:59 2019 +0200
+++ b/tests/test-topic-tutorial.t	Thu Apr 11 22:13:55 2019 +0200
@@ -1358,8 +1358,8 @@
   $ hg stack
   ### topic: tools
   ### target: default (branch), 2 behind
-  s3$ Adding drill (unstable)
-  s2$ Adding saw (unstable)
+  s3$ Adding drill (orphan)
+  s2$ Adding saw (orphan)
   s1@ Adding hammer to the shopping list (current)
   s0^ add a pair of shoes (base)
 
@@ -1375,7 +1375,7 @@
   $ hg stack
   ### topic: tools
   ### target: default (branch), 2 behind
-  s3$ Adding drill (unstable)
+  s3$ Adding drill (orphan)
   s2@ Adding saw (current)
   s1: Adding hammer to the shopping list
   s0^ add a pair of shoes (base)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-unstability-resolution-result.t	Thu Apr 11 22:13:55 2019 +0200
@@ -0,0 +1,215 @@
+=================================================================
+Test automatic unstability resolution for multiple advanced cases
+=================================================================
+
+There are dedicated test case for each instability, but this file check some
+basic case for each type.
+
+XXX dispatching each these test case in appropriate file would make sense.
+
+  $ cat >> $HGRCPATH <<EOF
+  > [defaults]
+  > amend=-d "0 0"
+  > [extensions]
+  > hgext.rebase=
+  > EOF
+  $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
+
+  $ glog() {
+  >   hg log -G --template \
+  >     '{rev}:{node|short}@{branch}({phase}) bk:[{bookmarks}] {desc|firstline}\n' "$@"
+  > }
+
+Test evolve removing the orphan changeset being evolved
+
+  $ hg init empty
+  $ cd empty
+  $ echo a > a
+  $ hg ci -Am adda a
+  $ echo b > b
+  $ hg ci -Am addb b
+  $ echo a >> a
+  $ hg ci -m changea
+  $ hg bookmark changea
+  $ hg up 1
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (leaving bookmark changea)
+  $ echo a >> a
+  $ hg amend -m changea
+  1 new orphan changesets
+  $ hg evolve -v --confirm
+  move:[2] changea
+  atop:[3] changea
+  perform evolve? [Ny] n
+  abort: evolve aborted by user
+  [255]
+  $ echo y | hg evolve -v --confirm --config ui.interactive=True
+  move:[2] changea
+  atop:[3] changea
+  perform evolve? [Ny] y
+  hg rebase -r cce2c55b8965 -d fb9d051ec0a4
+  resolving manifests
+  evolution of 2:cce2c55b8965 created no changes to commit
+
+  $ glog --hidden
+  @  3:fb9d051ec0a4@default(draft) bk:[changea] changea
+  |
+  | x  2:cce2c55b8965@default(draft) bk:[] changea
+  | |
+  | x  1:102a90ea7b4a@default(draft) bk:[] addb
+  |/
+  o  0:07f494440405@default(draft) bk:[] adda
+  
+  $ hg debugobsolete
+  102a90ea7b4a3361e4082ed620918c261189a36a fb9d051ec0a450a4aa2ffc8c324979832ef88065 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'operation': 'amend', 'user': 'test'}
+  cce2c55b896511e0b6e04173c9450ba822ebc740 0 {102a90ea7b4a3361e4082ed620918c261189a36a} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'evolve', 'user': 'test'}
+
+Test evolve of orphan that run into conflict
+
+  $ ls
+  a
+  b
+  $ hg pdiff a
+  diff -r 07f494440405 a
+  --- a/a	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +1,2 @@
+   a
+  +a
+  $ echo 'newer a' >> a
+  $ hg ci -m 'newer a'
+  $ hg gdown
+  gdown have been deprecated in favor of previous
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  [3] changea
+  $ echo 'a' > a
+  $ hg amend
+  1 new orphan changesets
+  $ hg evolve
+  move:[4] newer a
+  atop:[5] changea
+  merging a
+  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
+  fix conflicts and see `hg help evolve.interrupted`
+  [1]
+  $ hg revert -r "orphan()" a
+  $ hg diff
+  diff -r 66719795a494 a
+  --- a/a	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +1,3 @@
+   a
+  +a
+  +newer a
+  $ hg evolve --continue
+  abort: unresolved merge conflicts (see 'hg help resolve')
+  [255]
+  $ hg resolve -m a
+  (no more unresolved files)
+  continue: hg evolve --continue
+  $ hg evolve --continue
+  evolving 4:3655f0f50885 "newer a"
+  working directory is now at 1cf0aacfd363
+
+Stabilize phase-divergent changesets with a different parent
+============================================================
+
+(the same-parent case is handled in test-evolve.t)
+
+  $ glog
+  @  6:1cf0aacfd363@default(draft) bk:[] newer a
+  |
+  o  5:66719795a494@default(draft) bk:[changea] changea
+  |
+  o  0:07f494440405@default(draft) bk:[] adda
+  
+
+Add another commit
+
+  $ hg gdown
+  gdown have been deprecated in favor of previous
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  [5] changea
+  $ echo 'c' > c
+  $ hg add c
+  $ hg commit -m 'add c'
+  created new head
+
+Get a successors of 8 on it
+
+  $ hg pick 1cf0aacfd363
+  picking 6:1cf0aacfd363 "newer a"
+
+Add real change to the successors
+
+  $ echo 'babar' >> a
+  $ hg amend
+
+Make precursors public
+
+  $ hg phase --hidden --public 1cf0aacfd363
+  1 new phase-divergent changesets
+  $ glog
+  @  9:99c21c89bcef@default(draft) bk:[] newer a
+  |
+  o  7:7bc2f5967f5e@default(draft) bk:[] add c
+  |
+  | o  6:1cf0aacfd363@default(public) bk:[] newer a
+  |/
+  o  5:66719795a494@default(public) bk:[changea] changea
+  |
+  o  0:07f494440405@default(public) bk:[] adda
+  
+
+Stabilize!
+
+  $ hg evolve --any --dry-run --phase-divergent
+  recreate:[9] newer a
+  atop:[6] newer a
+  hg rebase --rev 99c21c89bcef --dest 66719795a494;
+  hg update 1cf0aacfd363;
+  hg revert --all --rev 99c21c89bcef;
+  hg commit --msg "phase-divergent update to 99c21c89bcef"
+  $ hg evolve --any --confirm --phase-divergent
+  recreate:[9] newer a
+  atop:[6] newer a
+  perform evolve? [Ny] n
+  abort: evolve aborted by user
+  [255]
+  $ echo y | hg evolve --any --confirm --config ui.interactive=True --phase-divergent
+  recreate:[9] newer a
+  atop:[6] newer a
+  perform evolve? [Ny] y
+  rebasing to destination parent: 66719795a494
+  committed as 8fc63fe1f297
+  working directory is now at 8fc63fe1f297
+  $ glog
+  @  11:8fc63fe1f297@default(draft) bk:[] phase-divergent update to 1cf0aacfd363:
+  |
+  | o  7:7bc2f5967f5e@default(draft) bk:[] add c
+  | |
+  o |  6:1cf0aacfd363@default(public) bk:[] newer a
+  |/
+  o  5:66719795a494@default(public) bk:[changea] changea
+  |
+  o  0:07f494440405@default(public) bk:[] adda
+  
+  $ hg exp
+  # HG changeset patch
+  # User test
+  # Date 0 0
+  #      Thu Jan 01 00:00:00 1970 +0000
+  # Node ID 8fc63fe1f297f356d1156bbbbe865b9911efad74
+  # Parent  1cf0aacfd36310b18e403e1594871187e0364a82
+  phase-divergent update to 1cf0aacfd363:
+  
+  newer a
+  
+  diff -r 1cf0aacfd363 -r 8fc63fe1f297 a
+  --- a/a	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,3 +1,4 @@
+   a
+   a
+   newer a
+  +babar
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-unstable-orphan.t	Thu Apr 11 22:13:55 2019 +0200
@@ -0,0 +1,131 @@
+==================================
+Test for "orphan" type instability
+==================================
+
+This file gather test case around the "orphan" changeset instability. This
+instability happens when a changesets has obsolete ancestors.
+
+  $ cat >> $HGRCPATH <<EOF
+  > [defaults]
+  > amend=-d "0 0"
+  > fold=-d "0 0"
+  > [web]
+  > push_ssl = false
+  > allow_push = *
+  > [phases]
+  > publish = False
+  > [diff]
+  > git = 1
+  > unified = 0
+  > [ui]
+  > logtemplate = {rev}:{node|short}@{branch}({phase}) {desc|firstline}\n
+  > [extensions]
+  > EOF
+  $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
+  $ mkcommit() {
+  >    echo "$1" > "$1"
+  >    hg add "$1"
+  >    hg ci -m "add $1"
+  > }
+
+  $ mkstack() {
+  >    # Creates a stack of commit based on $1 with messages from $2, $3 ..
+  >    hg update "$1" -C
+  >    shift
+  >    mkcommits $*
+  > }
+
+  $ mkcommits() {
+  >   for i in $@; do mkcommit $i ; done
+  > }
+
+orphan parent is obsolete with a single successor
+=================================================
+
+Test orphan resolution for a changeset orphan because its parent is obsolete
+with one successor.
+
+  $ hg init test1
+  $ cd test1
+  $ mkcommits _a _b _c
+  $ hg up "desc(_b)"
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg amend -m "bprime"
+  1 new orphan changesets
+  $ hg log -G
+  @  3:36050226a9b9@default(draft) bprime
+  |
+  | *  2:102002290587@default(draft) add _c
+  | |
+  | x  1:37445b16603b@default(draft) add _b
+  |/
+  o  0:135f39f4bd78@default(draft) add _a
+  
+
+  $ hg evo --all --any --orphan
+  move:[2] add _c
+  atop:[3] bprime
+  working directory is now at fdcf3523a74d
+  $ hg log -G
+  @  4:fdcf3523a74d@default(draft) add _c
+  |
+  o  3:36050226a9b9@default(draft) bprime
+  |
+  o  0:135f39f4bd78@default(draft) add _a
+  
+
+  $ cd ..
+
+
+orphan parent is obsolete with a multiple successors (reversed order)
+=====================================================================
+
+Test orphan resolution for a changeset orphan because its parent is obsolete
+with multiple successors on the same branch but in reverse order (cross-split).
+
+  $ hg init test5
+  $ cd test5
+  $ mkcommits _a _b _c
+  $ hg up "desc(_a)"
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ mkcommits bprimesplit1 bprimesplit2
+  created new head
+  $ hg prune "desc(_b)" -s "desc(bprimesplit1) + desc(bprimesplit2)" --split
+  1 changesets pruned
+  1 new orphan changesets
+  $ hg up "desc(_a)"
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ mkcommits bsecondsplit1 bsecondsplit2
+  created new head
+  $ hg prune "desc(bprimesplit1)" -s "desc(bsecondsplit2)"
+  1 changesets pruned
+  1 new orphan changesets
+  $ hg prune "desc(bprimesplit2)" -s "desc(bsecondsplit1)"
+  1 changesets pruned
+  $ hg log -G
+  @  6:59b942dbda14@default(draft) add bsecondsplit2
+  |
+  o  5:8ffdae67d696@default(draft) add bsecondsplit1
+  |
+  | *  2:102002290587@default(draft) add _c
+  | |
+  | x  1:37445b16603b@default(draft) add _b
+  |/
+  o  0:135f39f4bd78@default(draft) add _a
+  
+
+  $ hg evo --all --any --orphan
+  move:[2] add _c
+  atop:[6] add bsecondsplit2
+  working directory is now at 98e3f21461ff
+  $ hg log -G
+  @  7:98e3f21461ff@default(draft) add _c
+  |
+  o  6:59b942dbda14@default(draft) add bsecondsplit2
+  |
+  o  5:8ffdae67d696@default(draft) add bsecondsplit1
+  |
+  o  0:135f39f4bd78@default(draft) add _a
+  
+
+  $ cd ..
--- a/tests/test-unstable.t	Wed Apr 10 16:11:59 2019 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +0,0 @@
-  $ cat >> $HGRCPATH <<EOF
-  > [defaults]
-  > amend=-d "0 0"
-  > fold=-d "0 0"
-  > [web]
-  > push_ssl = false
-  > allow_push = *
-  > [phases]
-  > publish = False
-  > [diff]
-  > git = 1
-  > unified = 0
-  > [ui]
-  > logtemplate = {rev}:{node|short}@{branch}({phase}) {desc|firstline}\n
-  > [extensions]
-  > EOF
-  $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
-  $ mkcommit() {
-  >    echo "$1" > "$1"
-  >    hg add "$1"
-  >    hg ci -m "add $1"
-  > }
-
-  $ mkstack() {
-  >    # Creates a stack of commit based on $1 with messages from $2, $3 ..
-  >    hg update "$1" -C
-  >    shift
-  >    mkcommits $*
-  > }
-
-  $ mkcommits() {
-  >   for i in $@; do mkcommit $i ; done
-  > }
-
-==============================================================================
-Test instability resolution for a changeset unstable because its parent
-is obsolete with one successor
-==============================================================================
-  $ hg init test1
-  $ cd test1
-  $ mkcommits _a _b _c
-  $ hg up "desc(_b)"
-  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  $ hg amend -m "bprime"
-  1 new orphan changesets
-  $ hg log -G
-  @  3:36050226a9b9@default(draft) bprime
-  |
-  | *  2:102002290587@default(draft) add _c
-  | |
-  | x  1:37445b16603b@default(draft) add _b
-  |/
-  o  0:135f39f4bd78@default(draft) add _a
-  
-
-  $ hg evo --all --any --orphan
-  move:[2] add _c
-  atop:[3] bprime
-  working directory is now at fdcf3523a74d
-  $ hg log -G
-  @  4:fdcf3523a74d@default(draft) add _c
-  |
-  o  3:36050226a9b9@default(draft) bprime
-  |
-  o  0:135f39f4bd78@default(draft) add _a
-  
-
-  $ cd ..
-
-===============================================================================
-Test instability resolution for a changeset unstable because its parent
-is obsolete with multiple successors on one branches but in reverse
-order (cross-split).
-==============================================================================
-
-  $ hg init test5
-  $ cd test5
-  $ mkcommits _a _b _c
-  $ hg up "desc(_a)"
-  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
-  $ mkcommits bprimesplit1 bprimesplit2
-  created new head
-  $ hg prune "desc(_b)" -s "desc(bprimesplit1) + desc(bprimesplit2)" --split
-  1 changesets pruned
-  1 new orphan changesets
-  $ hg up "desc(_a)"
-  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
-  $ mkcommits bsecondsplit1 bsecondsplit2
-  created new head
-  $ hg prune "desc(bprimesplit1)" -s "desc(bsecondsplit2)"
-  1 changesets pruned
-  1 new orphan changesets
-  $ hg prune "desc(bprimesplit2)" -s "desc(bsecondsplit1)"
-  1 changesets pruned
-  $ hg log -G
-  @  6:59b942dbda14@default(draft) add bsecondsplit2
-  |
-  o  5:8ffdae67d696@default(draft) add bsecondsplit1
-  |
-  | *  2:102002290587@default(draft) add _c
-  | |
-  | x  1:37445b16603b@default(draft) add _b
-  |/
-  o  0:135f39f4bd78@default(draft) add _a
-  
-
-  $ hg evo --all --any --orphan
-  move:[2] add _c
-  atop:[6] add bsecondsplit2
-  working directory is now at 98e3f21461ff
-  $ hg log -G
-  @  7:98e3f21461ff@default(draft) add _c
-  |
-  o  6:59b942dbda14@default(draft) add bsecondsplit2
-  |
-  o  5:8ffdae67d696@default(draft) add bsecondsplit1
-  |
-  o  0:135f39f4bd78@default(draft) add _a
-  
-
-  $ cd ..