[PATCH 3 of 4 evolve-ext] evolve: change the implementation of evolve with no argument

Laurent Charignon lcharignon at fb.com
Mon Jun 22 17:42:02 CDT 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1435010493 25200
#      Mon Jun 22 15:01:33 2015 -0700
# Node ID c64696fe12b20a96db8fccf94b18d62bddca20b3
# Parent  34f4e918c71d29989e08a053bf3a4bac7ee371f5
evolve: change the implementation of evolve with no argument

Before this patch, evolve with no argument was using _stabilizableunstable.
With this patch, we reuse the logic built to compute the dependencies to make
evolve with no argument more robust. It now warns the user when there is several
possibilities to consider the same way the next command does.

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -499,8 +499,9 @@ def _nextcandidates(repo):
             pass
         elif len(successors[n]) > 1:
             # ambiguity
-            msg = _("several successors for %d %s\n") % n
-            hint = _("select one with --rev\n") % successors[n]
+            msg = _("several successors for %s") % repo[n]
+            hint = _("select one of %s with --rev") \
+                     % ', '.join([str(repo[k]) for k in successors[n]])
             raise error.Abort(msg, hint=hint)
         else:
             successor = successors[n][0]
@@ -1462,9 +1463,11 @@ def _selectrevs(repo, allopt, revopt, an
     elif anyopt:
         revs = repo.revs('first(%s())' % (targetcat))
     elif targetcat == 'unstable':
-        tro = _stabilizableunstable(repo, repo['.'])
-        if tro is not None:
-            revs = set([tro])
+        revs = set(repo.revs("_nextcandidate()"))
+        if 1 < len(revs):
+            hint = _("pick one of %s using --rev") % (", ".join(revs))
+            raise error.Abort(_("multiple evolve candidates"),
+                              hint=hint);
     elif targetcat in repo['.'].troubles():
         revs = set([repo['.'].rev()])
     return revs
diff --git a/tests/test-stabilize-order.t b/tests/test-stabilize-order.t
--- a/tests/test-stabilize-order.t
+++ b/tests/test-stabilize-order.t
@@ -188,3 +188,27 @@ Test behaviour with --any
   $ hg evolve --any -v
   no unstable changesets to evolve
   [1]
+
+Ambiguous evolution
+  $ echo a > k
+  $ hg ci -Am firstambiguous
+  adding k
+  adding successors.new
+  adding successors.old
+  $ hg up .^
+  0 files updated, 0 files merged, 3 files removed, 0 files unresolved
+  $ echo a > l
+  $ hg ci -Am secondambiguous
+  adding l
+  created new head
+  $ hg up .^
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg commit --amend -m "newmessage"
+  2 new unstable changesets
+  $ hg evolve
+  abort: several successors for 49773ccde390
+  (select one of *, * with --rev) (glob)
+  [255]
+
+
+


More information about the Mercurial-devel mailing list