diff mercurial/hbisect.py @ 30067:6e88cd060ba2

bisect: move 'printresult' in the 'hbisect' module The logic is already extracted into a closure. We move it into the module dedicated to bisect. A minor change is applied: the creation of the 'displayer' is kept in the main command function, it remove the needs to import 'cmdutil' in 'hbisect'. This would create an import circle otherwise.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Wed, 24 Aug 2016 04:19:11 +0200
parents 5f93737d0ba8
children 755730fc1e48
line wrap: on
line diff
--- a/mercurial/hbisect.py	Wed Aug 24 04:16:07 2016 +0200
+++ b/mercurial/hbisect.py	Wed Aug 24 04:19:11 2016 +0200
@@ -279,3 +279,29 @@
         return label[0].upper()
 
     return None
+
+def printresult(ui, repo, state, displayer, nodes, good):
+    if len(nodes) == 1:
+        # narrowed it down to a single revision
+        if good:
+            ui.write(_("The first good revision is:\n"))
+        else:
+            ui.write(_("The first bad revision is:\n"))
+        displayer.show(repo[nodes[0]])
+        extendnode = extendrange(repo, state, nodes, good)
+        if extendnode is not None:
+            ui.write(_('Not all ancestors of this changeset have been'
+                       ' checked.\nUse bisect --extend to continue the '
+                       'bisection from\nthe common ancestor, %s.\n')
+                     % extendnode)
+    else:
+        # multiple possible revisions
+        if good:
+            ui.write(_("Due to skipped revisions, the first "
+                    "good revision could be any of:\n"))
+        else:
+            ui.write(_("Due to skipped revisions, the first "
+                    "bad revision could be any of:\n"))
+        for n in nodes:
+            displayer.show(repo[n])
+    displayer.close()