changeset 4447:5205e3dedafc

branching: merge with stable
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 26 Mar 2019 11:23:09 +0100
parents ea336a6592cc (diff) 8232bddf543a (current diff)
children ab5bc57ba897
files CHANGELOG hgext3rd/evolve/cmdrewrite.py
diffstat 30 files changed, 2380 insertions(+), 387 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGELOG	Mon Mar 25 15:45:11 2019 -0700
+++ b/CHANGELOG	Tue Mar 26 11:23:09 2019 +0100
@@ -1,6 +1,15 @@
 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.
+
 8.4.1 - in progress
 -------------------
 
--- a/hgext3rd/evolve/__init__.py	Mon Mar 25 15:45:11 2019 -0700
+++ b/hgext3rd/evolve/__init__.py	Tue Mar 26 11:23:09 2019 +0100
@@ -257,14 +257,6 @@
 import struct
 
 try:
-    import StringIO as io
-    StringIO = io.StringIO
-except ImportError:
-    import io
-    StringIO = io.StringIO
-
-
-try:
     from mercurial import registrar
     registrar.templatekeyword # new in hg-3.8
 except ImportError:
--- a/hgext3rd/evolve/cmdrewrite.py	Mon Mar 25 15:45:11 2019 -0700
+++ b/hgext3rd/evolve/cmdrewrite.py	Tue Mar 26 11:23:09 2019 +0100
@@ -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
@@ -169,18 +168,18 @@
         for chunk, label in patch.diffui(repo, p1.node(), old.node(),
                                          match=matcher,
                                          opts=diffopts):
-                fp.write(chunk)
+            fp.write(chunk)
         newnode = _editandapply(ui, repo, pats, old, p1, fp, diffopts)
         if newnode == old.node():
             raise error.Abort(_("nothing changed"))
         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:
@@ -205,7 +204,7 @@
             for chunk, label in patch.diffui(repo, p1.node(), old.node(),
                                              match=restmatcher,
                                              opts=diffopts):
-                    afp.write(chunk)
+                afp.write(chunk)
 
         user_patch = afp.getvalue()
         if not user_patch:
@@ -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"))
@@ -582,7 +580,7 @@
     fp = stringio()
     for chunk, label in patch.diffui(repo, tempnode, old.node(), None,
                                      opts=diffopts):
-            fp.write(chunk)
+        fp.write(chunk)
 
     fp.seek(0)
     newnode = _patchtocommit(ui, repo, old, fp)
@@ -613,7 +611,7 @@
         raise error.Abort(_("nothing selected to uncommit"))
     fp = stringio()
     for c in chunks:
-            c.write(fp)
+        c.write(fp)
 
     fp.seek(0)
     oldnode = node.hex(old.node())[:12]
@@ -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['.']
 
@@ -1480,7 +1471,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	Mon Mar 25 15:45:11 2019 -0700
+++ b/hgext3rd/evolve/compat.py	Tue Mar 26 11:23:09 2019 +0100
@@ -16,7 +16,6 @@
     obsolete,
     obsutil,
     repair,
-    revset,
     scmutil,
     util,
     ui as uimod,
@@ -54,43 +53,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 +70,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,21 +78,17 @@
 
     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
-    ctxmandatory = varnames[2] == "changectx"
 
-    if ctxmandatory:
+    if "copysource" in varnames:
+        mctx = context.memfilectx(repo, ctx, fctx.path(), fctx.data(),
+                                  islink='l' in flags,
+                                  isexec='x' in flags,
+                                  copysource=copied.get(path))
+    # compat with hg <- 4.9
+    elif varnames[2] == "changectx":
         mctx = context.memfilectx(repo, ctx, fctx.path(), fctx.data(),
                                   islink='l' in flags,
                                   isexec='x' in flags,
@@ -482,7 +425,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/evolvecmd.py	Mon Mar 25 15:45:11 2019 -0700
+++ b/hgext3rd/evolve/evolvecmd.py	Tue Mar 26 11:23:09 2019 +0100
@@ -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):
@@ -172,7 +165,7 @@
             repo.ui.write(_('atop:'))
             displayer.show(target)
     if confirm and ui.prompt('perform evolve? [Ny]', 'n') != 'y':
-            raise error.Abort(_('evolve aborted by user'))
+        raise error.Abort(_('evolve aborted by user'))
     if progresscb:
         progresscb()
     todo = 'hg rebase -r %s -d %s\n' % (orig, target)
@@ -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,20 @@
     evolvestate['other-divergent'] = other.node()
     evolvestate['base'] = base.node()
 
+    # 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 = other, divergent
+            evolvestate['divergent'] = divergent.node()
+            evolvestate['other-divergent'] = other.node()
+        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 +419,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 +447,48 @@
     # 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 = other, divergent
+                    evolvestate['divergent'] = divergent.node()
+                    evolvestate['other-divergent'] = other.node()
+                    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 = other, divergent
+            evolvestate['divergent'] = divergent.node()
+            evolvestate['other-divergent'] = other.node()
+            resolutionparent = divergent.p1().node()
     else:
         msg = _("skipping %s: have a different parent than %s "
                 "(not handled yet)\n") % (divergent, other)
@@ -499,8 +550,25 @@
 
     _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,
+                                      tmpctx=bumped)
 
 def _mergecontentdivergents(repo, progresscb, divergent, other, base,
                             evolvestate):
@@ -542,6 +610,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 +664,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 +687,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
@@ -897,7 +1041,7 @@
         # uurrgs
         # there no other topic setter yet
         if not orig.topic() and repo.vfs.exists('topic'):
-                repo.vfs.unlink('topic')
+            repo.vfs.unlink('topic')
         else:
             with repo.vfs.open('topic', 'w') as f:
                 f.write(orig.topic())
@@ -1298,10 +1442,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 +1602,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 +1700,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 +1747,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 +1772,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 +1967,26 @@
                                         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, tmpctx=bumped)
         tr.close()
+        return ret
     finally:
         tr.release()
 
--- a/hgext3rd/evolve/metadata.py	Mon Mar 25 15:45:11 2019 -0700
+++ b/hgext3rd/evolve/metadata.py	Tue Mar 26 11:23:09 2019 +0100
@@ -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/obsdiscovery.py	Mon Mar 25 15:45:11 2019 -0700
+++ b/hgext3rd/evolve/obsdiscovery.py	Tue Mar 26 11:23:09 2019 +0100
@@ -15,13 +15,6 @@
 
 from __future__ import absolute_import
 
-try:
-    import StringIO as io
-    StringIO = io.StringIO
-except ImportError:
-    import io
-    StringIO = io.StringIO
-
 import hashlib
 import heapq
 import inspect
--- a/hgext3rd/evolve/obsexchange.py	Mon Mar 25 15:45:11 2019 -0700
+++ b/hgext3rd/evolve/obsexchange.py	Tue Mar 26 11:23:09 2019 +0100
@@ -8,11 +8,9 @@
 from __future__ import absolute_import
 
 try:
-    import StringIO as io
-    StringIO = io.StringIO
+    from StringIO import StringIO
 except ImportError:
-    import io
-    StringIO = io.StringIO
+    from io import StringIO
 
 from mercurial import (
     bundle2,
--- a/hgext3rd/evolve/obshistory.py	Mon Mar 25 15:45:11 2019 -0700
+++ b/hgext3rd/evolve/obshistory.py	Tue Mar 26 11:23:09 2019 +0100
@@ -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/utility.py	Mon Mar 25 15:45:11 2019 -0700
+++ b/hgext3rd/evolve/utility.py	Tue Mar 26 11:23:09 2019 +0100
@@ -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/serverminitopic.py	Mon Mar 25 15:45:11 2019 -0700
+++ b/hgext3rd/serverminitopic.py	Tue Mar 26 11:23:09 2019 +0100
@@ -146,6 +146,10 @@
     return hasminitopic(repo) and repo.filtername not in _publiconly
 
 class _topiccache(branchmap.branchcache): # combine me with branchmap.branchcache
+    @classmethod
+    def fromfile(cls, repo):
+        orig = super(_topiccache, cls).fromfile
+        return wrapread(orig, repo)
 
     def __init__(self, *args, **kwargs):
         # super() call may fail otherwise
@@ -226,6 +230,12 @@
 
 def uisetup(ui):
     wrapclass(branchmap, 'branchcache', _topiccache)
-    extensions.wrapfunction(branchmap, 'read', wrapread)
+    try:
+        # Mercurial 4.8 and older
+        extensions.wrapfunction(branchmap, 'read', wrapread)
+    except AttributeError:
+        # Mercurial 4.9; branchcache.fromfile now takes care of this
+        # which is alredy defined on _topiccache
+        pass
     extensions.wrapfunction(wireproto, '_capabilities', wireprotocaps)
     extensions.wrapfunction(context.changectx, 'branch', topicbranch)
--- a/hgext3rd/topic/__init__.py	Mon Mar 25 15:45:11 2019 -0700
+++ b/hgext3rd/topic/__init__.py	Tue Mar 26 11:23:09 2019 +0100
@@ -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	Mon Mar 25 15:45:11 2019 -0700
+++ b/hgext3rd/topic/revset.py	Tue Mar 26 11:23:09 2019 +0100
@@ -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	Mon Mar 25 15:45:11 2019 -0700
+++ b/hgext3rd/topic/stack.py	Tue Mar 26 11:23:09 2019 +0100
@@ -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"""
@@ -228,7 +219,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 +284,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 +321,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 +352,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/hgext3rd/topic/topicmap.py	Mon Mar 25 15:45:11 2019 -0700
+++ b/hgext3rd/topic/topicmap.py	Tue Mar 26 11:23:09 2019 +0100
@@ -117,7 +117,21 @@
     class topiccache(_topiccache, branchmap.branchcache):
         pass
     branchmap.branchcache = topiccache
-    extensions.wrapfunction(branchmap, 'updatecache', _wrapupdatebmcache)
+
+    try:
+        # Mercurial 4.9
+        class remotetopiccache(_topiccache, branchmap.remotebranchcache):
+            pass
+        branchmap.remotebranchcache = remotetopiccache
+
+        def _wrapupdatebmcachemethod(orig, self, repo):
+            # pass in the bound method as the original
+            return _wrapupdatebmcache(orig.__get__(self), repo)
+        extensions.wrapfunction(branchmap.BranchMapCache, 'updatecache', _wrapupdatebmcachemethod)
+    except AttributeError:
+        # Mercurial 4.8 and before
+        extensions.wrapfunction(branchmap, 'updatecache', _wrapupdatebmcache)
+
 
 def _wrapupdatebmcache(orig, repo):
     previous = getattr(repo, '_autobranchmaptopic', False)
--- a/tests/test-evolve-content-divergence.t	Mon Mar 25 15:45:11 2019 -0700
+++ b/tests/test-evolve-content-divergence.t	Tue Mar 26 11:23:09 2019 +0100
@@ -595,7 +595,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
@@ -660,7 +660,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
@@ -928,6 +928,189 @@
   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
 
 Test to make sure that evolve don't fall into unrecoverable state (issue6053)
 ------------------------------------------------------------------------------
--- a/tests/test-evolve-continue.t	Mon Mar 25 15:45:11 2019 -0700
+++ b/tests/test-evolve-continue.t	Tue Mar 26 11:23:09 2019 +0100
@@ -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	Mon Mar 25 15:45:11 2019 -0700
+++ b/tests/test-evolve-issue5832.t	Tue Mar 26 11:23:09 2019 +0100
@@ -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-orphan-split.t	Mon Mar 25 15:45:11 2019 -0700
+++ b/tests/test-evolve-orphan-split.t	Tue Mar 26 11:23:09 2019 +0100
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-evolve-public-content-divergent.t	Tue Mar 26 11:23:09 2019 +0100
@@ -0,0 +1,1718 @@
+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
+  computing new diff
+  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
+  computing new diff
+  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
+  computing new diff
+  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 troubled 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
+  computing new diff
+  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 ..
+
+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 cfoo > c
+  $ echo e > e
+  $ hg add c e
+  $ hg ci -m "added c e"
+  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:e568fd1029bb 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: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 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'
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  computing new diff
+  committed as 06e4564a3897
+  working directory is now at 06e4564a3897
+
+  $ 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
+  computing new diff
+  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
+  computing new diff
+  committed as b9082a9e66ce
+  working directory is now at b9082a9e66ce
+
+  $ 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-topic.t	Mon Mar 25 15:45:11 2019 -0700
+++ b/tests/test-evolve-topic.t	Tue Mar 26 11:23:09 2019 +0100
@@ -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-grab.t	Mon Mar 25 15:45:11 2019 -0700
+++ b/tests/test-grab.t	Tue Mar 26 11:23:09 2019 +0100
@@ -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	Mon Mar 25 15:45:11 2019 -0700
+++ b/tests/test-prev-next.t	Tue Mar 26 11:23:09 2019 +0100
@@ -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
 
--- a/tests/test-split.t	Mon Mar 25 15:45:11 2019 -0700
+++ b/tests/test-split.t	Tue Mar 26 11:23:09 2019 +0100
@@ -19,6 +19,8 @@
   > [diff]
   > git = 1
   > unified = 0
+  > [commands]
+  > commit.interactive.unified = 0
   > [ui]
   > interactive = true
   > [extensions]
--- a/tests/test-stack-branch.t	Mon Mar 25 15:45:11 2019 -0700
+++ b/tests/test-stack-branch.t	Tue Mar 26 11:23:09 2019 +0100
@@ -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)
@@ -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	Mon Mar 25 15:45:11 2019 -0700
+++ b/tests/test-topic-stack-complex.t	Tue Mar 26 11:23:09 2019 +0100
@@ -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	Mon Mar 25 15:45:11 2019 -0700
+++ b/tests/test-topic-stack-data.t	Tue Mar 26 11:23:09 2019 +0100
@@ -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	Mon Mar 25 15:45:11 2019 -0700
+++ b/tests/test-topic-stack.t	Tue Mar 26 11:23:09 2019 +0100
@@ -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	Mon Mar 25 15:45:11 2019 -0700
+++ b/tests/test-topic-tutorial.t	Tue Mar 26 11:23:09 2019 +0100
@@ -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)
--- a/tests/test-topic.t	Mon Mar 25 15:45:11 2019 -0700
+++ b/tests/test-topic.t	Tue Mar 26 11:23:09 2019 +0100
@@ -860,6 +860,10 @@
   3: featureA
   $ tlog 'featureA#topic[0]'
   3: featureA
+  $ tlog 'featureA#topic[:]'
+  1: featureA
+  2: featureA
+  3: featureA
 
   $ tlog '2#t[-2]'
   $ tlog '2#t[-1]'
@@ -869,6 +873,10 @@
   $ tlog '2#t[1]'
   3: featureA
   $ tlog '2#t[2]'
+  $ tlog '2#t[-1:1]'
+  1: featureA
+  2: featureA
+  3: featureA
 
 stack subscript relation
 
@@ -898,6 +906,28 @@
 
   $ tlog 'featureA#s[0]'
   0: 
+  $ tlog 'featureA#s[0:0]'
+  0: 
+  $ tlog 'featureA#s[:]'
+  1: featureA
+  2: featureA
+  3: featureA
+  $ tlog 'featureA#s[2:]'
+  2: featureA
+  3: featureA
+  $ tlog 'featureA#s[:2]'
+  1: featureA
+  2: featureA
+  $ tlog 'featureA#s[0:1]'
+  0: 
+  1: featureA
+  $ tlog 'featureA#s[-1:0]'
+  0: 
+  3: featureA
+  $ tlog 'featureA#s[-3:3]'
+  1: featureA
+  2: featureA
+  3: featureA
   $ tlog 'featureA#s[1] and featureA#s[-3]'
   1: featureA
   $ tlog 'featureA#s[2] and featureA#s[-2]'