Patchwork [7,of,8] bisect: build a displayer only once

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 9, 2016, 8:57 a.m.
Message ID <e5012181a722d5cb544c.1476003461@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/16979/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Pierre-Yves David - Oct. 9, 2016, 8:57 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1472007981 -7200
#      Wed Aug 24 05:06:21 2016 +0200
# Node ID e5012181a722d5cb544c935400c676fce2d7b0a8
# Parent  eb7d02debaf5ed831f12b509f4175ebb0cd40143
# EXP-Topic bisect
bisect: build a displayer only once

There is multiple spot using this, building it early will help to extract more
of the logic into the bisect module.
timeless - Oct. 21, 2016, 1:18 p.m.
Pierre-Yves David wrote:
> There is multiple spot using this, building it early will help to extract more


fwiw this should be `there are multiple places` -- [are (plural verb),
multiple (plural hint), plural-noun] should all agree; `places` is a
better noun than `spots`.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -879,6 +879,8 @@  def bisect(ui, repo, rev=None, extra=Non
         cmdutil.bailifchanged(repo)
         return hg.clean(repo, node, show_stats=show_stats)
 
+    displayer = cmdutil.show_changeset(ui, repo, {})
+
     if command:
         changesets = 1
         if noupdate:
@@ -921,7 +923,6 @@  def bisect(ui, repo, rev=None, extra=Non
         finally:
             state['current'] = [node]
             hbisect.save_state(repo, state)
-        displayer = cmdutil.show_changeset(ui, repo, {})
         hbisect.printresult(ui, repo, state, displayer, nodes, bgood)
         return
 
@@ -941,7 +942,6 @@  def bisect(ui, repo, rev=None, extra=Non
         raise error.Abort(_("nothing to extend"))
 
     if changesets == 0:
-        displayer = cmdutil.show_changeset(ui, repo, {})
         hbisect.printresult(ui, repo, state, displayer, nodes, good)
     else:
         assert len(nodes) == 1 # only a single node can be tested next