Patchwork [5,of,5] phase: use `_phase` revset instead of string interpolation

login
register
mail settings
Submitter Boris Feld
Date Aug. 24, 2018, 10:35 p.m.
Message ID <4a975a8b96b56b9892ea.1535150141@FB-lair>
Download mbox | patch
Permalink /patch/34040/
State Accepted
Headers show

Comments

Boris Feld - Aug. 24, 2018, 10:35 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1534981719 -7200
#      Thu Aug 23 01:48:39 2018 +0200
# Node ID 4a975a8b96b56b9892ea6bc5ac7efeaf7d7d1a2f
# Parent  57160a3b6795cfde325662406d128d730c10e043
# EXP-Topic internal-phase.prepare
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 4a975a8b96b5
phase: use `_phase` revset instead of string interpolation

The previous code was hackyer and assume all phases had an associated revset.
The later might no longer be true once we introduce more internal phase.
Yuya Nishihara - Aug. 25, 2018, 8:35 a.m.
On Sat, 25 Aug 2018 00:35:41 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1534981719 -7200
> #      Thu Aug 23 01:48:39 2018 +0200
> # Node ID 4a975a8b96b56b9892ea6bc5ac7efeaf7d7d1a2f
> # Parent  57160a3b6795cfde325662406d128d730c10e043
> # EXP-Topic internal-phase.prepare
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 4a975a8b96b5
> phase: use `_phase` revset instead of string interpolation

Queued the series, thanks.

>      for phase in allphases[:-1]:
> -        revset = '%%ln - %s()' % phasenames[phase]
> +        revset = '%%ln - _phase(%d)' % phase
>          heads = [c.node() for c in repo.set(revset, headsbyphase[phase])]

This can be written as repo.set('%ln - _phase(%s)', headsbyphase[phase], phase).

Patch

diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -599,7 +599,7 @@  def updatephases(repo, trgetter, headsby
     # to update. This avoid creating empty transaction during no-op operation.
 
     for phase in allphases[:-1]:
-        revset = '%%ln - %s()' % phasenames[phase]
+        revset = '%%ln - _phase(%d)' % phase
         heads = [c.node() for c in repo.set(revset, headsbyphase[phase])]
         if heads:
             advanceboundary(repo, trgetter(), phase, heads)