changeset 2939:7759d040d48d

topic: provide more information when behind count cannot be computed The behind count has been confusing for various user and the associated error message is even worth. We try to clarify it to see if that helps.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 17 Sep 2017 19:59:25 +0200
parents 9872526fc39f
children 89b205e5271e
files hgext3rd/topic/__init__.py hgext3rd/topic/stack.py tests/test-topic-stack-data.t tests/test-topic-stack.t
diffstat 4 files changed, 17 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Fri Sep 15 23:25:38 2017 +0530
+++ b/hgext3rd/topic/__init__.py	Sun Sep 17 19:59:25 2017 +0200
@@ -719,7 +719,7 @@
             elif -1 == data['behindcount']:
                 fm.plain(', ')
                 fm.write('behinderror', '%s',
-                         _('ambiguous destination'),
+                         _('ambiguous destination: %s') % data['behinderror'],
                          label='topic.list.behinderror')
             fm.plain(')')
         fm.plain('\n')
--- a/hgext3rd/topic/stack.py	Fri Sep 15 23:25:38 2017 +0530
+++ b/hgext3rd/topic/stack.py	Sun Sep 17 19:59:25 2017 +0200
@@ -30,6 +30,7 @@
         self._repo = repo
         self.branch = branch
         self.topic = topic
+        self.behinderror = None
         if topic is not None and branch is not None:
             raise error.ProgrammingError('both branch and topic specified (not defined yet)')
         elif topic is not None:
@@ -166,7 +167,9 @@
                 return len(self._repo.revs("only(%d, %ld)", dest, minroot))
             except error.NoMergeDestAbort:
                 return 0
-            except error.ManyMergeDestAbort:
+            except error.ManyMergeDestAbort as exc:
+                # XXX we should make it easier for upstream to provide the information
+                self.behinderror = str(exc).split('-', 1)[0].rstrip()
                 return -1
         return 0
 
@@ -236,7 +239,8 @@
     else:
         if data['behindcount'] == -1:
             fm.plain(', ')
-            fm.plain('ambigious rebase destination', label='topic.stack.summary.behinderror')
+            fm.plain('ambigious rebase destination - %s' % data['behinderror'],
+                     label='topic.stack.summary.behinderror')
         elif data['behindcount']:
             fm.plain(', ')
             fm.plain('%d behind' % data['behindcount'], label='topic.stack.summary.behindcount')
@@ -331,5 +335,6 @@
     data['troubledcount'] = current.troubledcount
     data['headcount'] = len(current.heads)
     data['behindcount'] = current.behindcount
+    data['behinderror'] = current.behinderror
     data['branches'] = current.branches
     return data
--- a/tests/test-topic-stack-data.t	Fri Sep 15 23:25:38 2017 +0530
+++ b/tests/test-topic-stack-data.t	Sun Sep 17 19:59:25 2017 +0200
@@ -175,7 +175,7 @@
   $ hg topic --verbose
      bar (on branch: default, 5 changesets, 1 troubled, 2 heads)
      baz (on branch: default, 2 changesets, 2 behind)
-   * foo (on branch: lake, 2 changesets, ambiguous destination)
+   * foo (on branch: lake, 2 changesets, ambiguous destination: branch 'lake' has 2 heads)
      fuz (on branch: default, 3 changesets, 2 troubled, 1 behind)
 
 json
@@ -221,7 +221,7 @@
    },
    {
     "active": true,
-    "behinderror": "ambiguous destination",
+    "behinderror": "ambiguous destination: branch 'lake' has 2 heads",
     "branches+": "lake",
     "changesetcount": 2,
     "topic": "foo"
@@ -267,7 +267,7 @@
   t0^ add base_c (base)
   $ hg stack foo
   ### topic: foo
-  ### branch: lake, ambigious rebase destination
+  ### branch: lake, ambigious rebase destination - branch 'lake' has 2 heads
   t2@ add foo_b (current)
   t1: add foo_a
   t0^ add lake_a (base)
--- a/tests/test-topic-stack.t	Fri Sep 15 23:25:38 2017 +0530
+++ b/tests/test-topic-stack.t	Sun Sep 17 19:59:25 2017 +0200
@@ -548,7 +548,7 @@
 
   $ hg stack foo
   ### topic: foo
-  ### branch: default, ambigious rebase destination
+  ### branch: default, ambigious rebase destination - topic 'foo' has 3 heads
   t4: c_f
     ^ c_e
   t3: c_h
@@ -637,7 +637,7 @@
   t0^ c_A (base)
   $ hg stack blue
   ### topic: blue
-  ### branch: default, ambigious rebase destination
+  ### branch: default, ambigious rebase destination - topic 'blue' has 3 heads
   t3@ c_I (current)
     ^ c_H
   t2: c_D
@@ -690,7 +690,7 @@
 
   $ hg stack red
   ### topic: red
-  ### branch: default, ambigious rebase destination
+  ### branch: default, ambigious rebase destination - topic 'red' has 3 heads
   t5$ c_H (unstable)
     ^ c_G
     ^ c_D
@@ -702,7 +702,7 @@
   t0^ c_A (base)
   $ hg stack blue
   ### topic: blue
-  ### branch: default, ambigious rebase destination
+  ### branch: default, ambigious rebase destination - topic 'blue' has 3 heads
   t3$ c_I (unstable)
     ^ c_H
   t2$ c_G (unstable)
@@ -764,7 +764,7 @@
 
   $ hg stack red
   ### topic: red
-  ### branch: default, ambigious rebase destination
+  ### branch: default, ambigious rebase destination - topic 'red' has 3 heads
   t5$ c_H (unstable)
     ^ c_G
     ^ c_D
@@ -776,7 +776,7 @@
   t0^ c_A (base)
   $ hg stack blue
   ### topic: blue
-  ### branch: default, ambigious rebase destination
+  ### branch: default, ambigious rebase destination - topic 'blue' has 3 heads
   t3$ c_I (unstable)
     ^ c_H
   t2$ c_G (unstable)