next: prompt user to choose a children in case of ambiguity
authorPulkit Goyal <7895pulkit@gmail.com>
Fri, 16 Mar 2018 11:46:47 +0530
changeset 3547 78abffad8626
parent 3546 d197e6f0d0e3
child 3548 79d995cb8152
next: prompt user to choose a children in case of ambiguity This patch adds functionality to prompt user and ask the children to which next should move to incase of multiple childrens. This is a very nice UI because otherwise user has to lookup changeset hash, and then manually do `hg update` to that. In this case we show hash and description so user can choose which one to update easily. It is using the interactive revision choosing functionality added in a previous patch.
hgext3rd/evolve/__init__.py
tests/test-prev-next.t
--- a/hgext3rd/evolve/__init__.py	Fri Mar 16 11:31:13 2018 +0530
+++ b/hgext3rd/evolve/__init__.py	Fri Mar 16 11:46:47 2018 +0530
@@ -1109,11 +1109,17 @@
             c = children[0]
             result = _updatetonext(ui, repo, c, displayer, opts)
         elif children:
-            ui.warn(_("ambiguous next changeset:\n"))
-            for c in children:
-                displayer.show(c)
-            ui.warn(_('explicitly update to one of them\n'))
-            result = 1
+            cheader = _("ambiguous next changeset, choose one to update:")
+            crevs = [c.rev() for c in children]
+            choosedrev = utility.revselectionprompt(ui, repo, crevs, cheader)
+            if choosedrev is None:
+                ui.warn(_("ambiguous next changeset:\n"))
+                for c in children:
+                    displayer.show(c)
+                ui.warn(_("explicitly update to one of them\n"))
+                result = 1
+            else:
+                result = _updatetonext(ui, repo, repo[choosedrev], displayer, opts)
         else:
             aspchildren = evolvecmd._aspiringchildren(repo, [repo['.'].rev()])
             if topic:
--- a/tests/test-prev-next.t	Fri Mar 16 11:31:13 2018 +0530
+++ b/tests/test-prev-next.t	Fri Mar 16 11:46:47 2018 +0530
@@ -1,4 +1,6 @@
   $ cat >> $HGRCPATH <<EOF
+  > [ui]
+  > interactive = True
   > [extensions]
   > EOF
   $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
@@ -210,12 +212,20 @@
   $ hg prev
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   [3] added b (2)
-  $ hg next
-  ambiguous next changeset:
-  [4] added c
+  $ hg next <<EOF
+  > 1
+  > EOF
+  ambiguous next changeset, choose one to update:
+  0: [e3b6d5df389b] added c
+  1: [9df671ccd2c7] added d
+  q: quit the prompt
+  enter the index of the revision you want to select: 1
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   [5] added d
-  explicitly update to one of them
-  [1]
+
+  $ hg prev
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  [3] added b (2)
 
 next with ambiguity in aspiring children