Patchwork [4,of,5] phase: expose a `_phase(idx)` revset

login
register
mail settings
Submitter Boris Feld
Date Aug. 24, 2018, 10:35 p.m.
Message ID <57160a3b6795cfde3256.1535150140@FB-lair>
Download mbox | patch
Permalink /patch/34039/
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 1534981706 -7200
#      Thu Aug 23 01:48:26 2018 +0200
# Node ID 57160a3b6795cfde325662406d128d730c10e043
# Parent  93824739fc0d33ce7853ccfd57818df694f5593f
# EXP-Topic internal-phase.prepare
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 57160a3b6795
phase: expose a `_phase(idx)` revset

Internally phase related revset are calling the `_phase` function. We expose
it as an internal revset. This is useful to refer to phase in revset doing
debatable things around the phase name.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1566,6 +1566,12 @@  def _phase(repo, subset, *targets):
     """helper to select all rev in <targets> phases"""
     return repo._phasecache.getrevset(repo, targets, subset)
 
+@predicate('_phase(idx)', safe=True)
+def phase(repo, subset, x):
+    l = getargs(x, 1, 1, ("_phase requires one argument"))
+    target = getinteger(l[0], ("_phase expects a number"))
+    return _phase(repo, subset, target)
+
 @predicate('draft()', safe=True)
 def draft(repo, subset, x):
     """Changeset in draft phase."""