branching: merge with stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 17 Jul 2019 18:06:14 +0200
changeset 4729 076b6813a7ea
parent 4725 f162cafc5000 (current diff)
parent 4728 ef8907df73fc (diff)
child 4730 a95c6f578f70
branching: merge with stable
CHANGELOG
hgext3rd/evolve/cmdrewrite.py
hgext3rd/evolve/evolvecmd.py
tests/test-touch.t
--- a/CHANGELOG	Mon Jul 15 16:53:07 2019 -0700
+++ b/CHANGELOG	Wed Jul 17 18:06:14 2019 +0200
@@ -20,6 +20,7 @@
   * pick: properly report and cleanup "unfinished state"
   * prune: don't update wcp if pruned revision are unrelated (issue6137)
   * evolve: properly prune changeset with no change in case of conflict (issue5967)
+  * touch: detect resulting divergence in more cases (issue6107)
 
 9.0.0 -- 2019-06-06
 -------------------
--- a/hgext3rd/evolve/cmdrewrite.py	Mon Jul 15 16:53:07 2019 -0700
+++ b/hgext3rd/evolve/cmdrewrite.py	Wed Jul 17 18:06:14 2019 +0200
@@ -1381,8 +1381,12 @@
         p2 = newmapping.get(p2, p2)
 
         if not (duplicate or allowdivergence):
-            # The user hasn't yet decided what to do with the revived
-            # cset, let's ask
+            # If reviving this cset creates divergence, let's ask user
+            # what to do: create divergence or duplicate
+
+            # We need to check two cases that can cause divergence:
+            # case 1: the rev being revived has a non-obsolete successor (easily
+            #     detected by successorssets)
             sset = obsutil.successorssets(repo, ctx.node())
             nodivergencerisk = (len(sset) == 0
                                 or (len(sset) == 1
@@ -1390,6 +1394,12 @@
                                     and repo[sset[0][0]].rev() == ctx.rev()
                                 ))
             if nodivergencerisk:
+                # case 2: one of the precursors of the rev being revived has a
+                #     non-obsolete successor (we need divergentsets for this)
+                from . import evolvecmd
+                if evolvecmd.divergentsets(repo, ctx):
+                    nodivergencerisk = False
+            if nodivergencerisk:
                 duplicate = False
             else:
                 displayer.show(ctx)
--- a/hgext3rd/evolve/evolvecmd.py	Mon Jul 15 16:53:07 2019 -0700
+++ b/hgext3rd/evolve/evolvecmd.py	Wed Jul 17 18:06:14 2019 +0200
@@ -1536,9 +1536,8 @@
     If so, evolve rebases that changeset. If not, evolve refuses to guess your
     intention, and gives a hint about what you might want to do next.
 
-    Any time evolve creates a changeset, it updates the working copy to the new
-    changeset. Using ``--update`` will make evolve perform an update after any
-    successful evolve operation.
+    When ``--update`` is used, successful evolve operations update the
+    working directory to the newly created changesets.
 
     Automatic mode only handles common use cases. For example, it avoids taking
     action in the case of ambiguity, and it ignores orphan changesets that are
--- a/tests/test-touch.t	Mon Jul 15 16:53:07 2019 -0700
+++ b/tests/test-touch.t	Wed Jul 17 18:06:14 2019 +0200
@@ -200,3 +200,25 @@
   $ hg st --change 17
   A a
   A b
+
+  $ cd ..
+
+Make sure touch doesn't fail to warn about divergence (issue6107)
+
+  $ hg init touchdiv
+  $ cd touchdiv
+  $ echo c > c
+  $ hg add c
+  $ hg ci -m "added c"
+
+  $ hg amend -m "modified c"
+  $ hg prune . -q
+
+  $ hg touch -r "desc('added c')" --hidden
+  $ hg touch -r "desc('modified c')" --hidden
+  [1] modified c
+  reviving this changeset will create divergence unless you make a duplicate.
+  (a)llow divergence or (d)uplicate the changeset?  a
+  2 new content-divergent changesets
+
+  $ cd ..