changeset 30127:1ee65f1a11a5

bisect: factor commonly update sequence For now, This remains a closure in the module to avoid circular import with used module.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Wed, 24 Aug 2016 05:04:46 +0200
parents 755730fc1e48
children e37ee8367ab4
files mercurial/commands.py
diffstat 1 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Aug 24 04:25:20 2016 +0200
+++ b/mercurial/commands.py	Wed Aug 24 05:04:46 2016 +0200
@@ -872,6 +872,13 @@
         if not (state['good'] and state['bad']):
             return
 
+    def mayupdate(repo, node, show_stats=True):
+        """common used update sequence"""
+        if noupdate:
+            return
+        cmdutil.bailifchanged(repo)
+        return hg.clean(repo, node, show_stats=show_stats)
+
     if command:
         changesets = 1
         if noupdate:
@@ -910,9 +917,7 @@
                 nodes, changesets, bgood = hbisect.bisect(repo.changelog, state)
                 # update to next check
                 node = nodes[0]
-                if not noupdate:
-                    cmdutil.bailifchanged(repo)
-                    hg.clean(repo, node, show_stats=False)
+                mayupdate(repo, node, show_stats=False)
         finally:
             state['current'] = [node]
             hbisect.save_state(repo, state)
@@ -932,10 +937,7 @@
                          % (extendnode.rev(), extendnode))
                 state['current'] = [extendnode.node()]
                 hbisect.save_state(repo, state)
-                if noupdate:
-                    return
-                cmdutil.bailifchanged(repo)
-                return hg.clean(repo, extendnode.node())
+                return mayupdate(repo, extendnode.node())
         raise error.Abort(_("nothing to extend"))
 
     if changesets == 0:
@@ -954,9 +956,7 @@
                  % (rev, short(node), changesets, tests))
         state['current'] = [node]
         hbisect.save_state(repo, state)
-        if not noupdate:
-            cmdutil.bailifchanged(repo)
-            return hg.clean(repo, node)
+        return mayupdate(repo, node)
 
 @command('bookmarks|bookmark',
     [('f', 'force', False, _('force')),