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

Boris Feld boris.feld at octobus.net
Fri Aug 24 18:35:40 EDT 2018


# HG changeset patch
# User Boris Feld <boris.feld at 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.

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)
 
+ at 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."""


More information about the Mercurial-devel mailing list