Patchwork [V2] bisect: extra a small initialisation outside of a loop

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 10, 2016, 11:17 p.m.
Message ID <1488cf3cd4fa38c03b89.1476141460@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/17026/
State Accepted
Headers show

Comments

Pierre-Yves David - Oct. 10, 2016, 11:17 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1472008186 -7200
#      Wed Aug 24 05:09:46 2016 +0200
# Node ID 1488cf3cd4fa38c03b895c7be70a8c05a568a18b
# Parent  8d079c0594b35dfbf57baf8d83fde686a946920a
# EXP-Topic bisect
bisect: extra a small initialisation outside of a loop

Having initialisation done during the first iteration is cute, but can be
avoided.
Yuya Nishihara - Oct. 11, 2016, 3:27 p.m.
On Tue, 11 Oct 2016 01:17:40 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> # Date 1472008186 -7200
> #      Wed Aug 24 05:09:46 2016 +0200
> # Node ID 1488cf3cd4fa38c03b895c7be70a8c05a568a18b
> # Parent  8d079c0594b35dfbf57baf8d83fde686a946920a
> # EXP-Topic bisect
> bisect: extra a small initialisation outside of a loop

Queued this, thanks.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -893,6 +893,8 @@  def bisect(ui, repo, rev=None, extra=Non
             node, p2 = repo.dirstate.parents()
             if p2 != nullid:
                 raise error.Abort(_('current bisect revision is a merge'))
+        if rev:
+            node = repo[scmutil.revsingle(repo, rev, node)].node()
         try:
             while changesets:
                 # update state
@@ -910,9 +912,8 @@  def bisect(ui, repo, rev=None, extra=Non
                     raise error.Abort(_("%s killed") % command)
                 else:
                     transition = "bad"
-                ctx = scmutil.revsingle(repo, rev, node)
-                rev = None # clear for future iterations
-                state[transition].append(ctx.node())
+                state[transition].append(node)
+                ctx = repo[node]
                 ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition))
                 hbisect.checkstate(state)
                 # bisect