bisect: factor commonly update sequence
For now, This remains a closure in the module to avoid circular import with used
module.
--- 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')),