Patchwork [2,of,4] phases: avoid changectx creation while checking command result

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 2, 2013, 1:35 a.m.
Message ID <582c14e67f556532de28.1357090558@yamac.lan>
Download mbox | patch
Permalink /patch/363/
State Accepted
Commit 6a91cbb6790749a7c309de35931578e559e02962
Headers show

Comments

Pierre-Yves David - Jan. 2, 2013, 1:35 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1356346668 -3600
# Node ID 582c14e67f556532de2822fd3850e697406b1b6e
# Parent  b8f90b582ea1dd0e3d4a456cea824add48fb8b13
phases: avoid changectx creation while checking command result

This minor changesets saves the creation of a `changectx` ctx object only used to
fetch the revision number.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4628,13 +4628,14 @@  def phase(ui, repo, *revs, **opts):
             if opts['force']:
                 phases.retractboundary(repo, targetphase, nodes)
         finally:
             lock.release()
         newdata = repo._phasecache.getphaserevs(repo)
+        cl = repo.changelog
         changes = sum(o != newdata[i] for i, o in enumerate(olddata))
         rejected = [n for n in nodes
-                    if newdata[repo[n].rev()] < targetphase]
+                    if newdata[cl.rev(n)] < targetphase]
         if rejected:
             ui.warn(_('cannot move %i changesets to a more permissive '
                       'phase, use --force\n') % len(rejected))
             ret = 1
         if changes: