# HG changeset patch # User Pierre-Yves David # Date 2012-01-06 09:04:20 # Node ID 33ca11b010e25448a329fd2ff39927c776099d8a # Parent 57241845a4bb4dc72e9f7ed1c669ed3b448bebff phases: implements simple revset symbol This changeset adds ``public()``, ``draft()`` and ``secret`` symbol for revset. diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -6,7 +6,7 @@ # GNU General Public License version 2 or any later version. import re -import parser, util, error, discovery, hbisect +import parser, util, error, discovery, hbisect, phases import node as nodemod import bookmarks as bookmarksmod import match as matchmod @@ -395,6 +395,12 @@ def descendants(repo, subset, x): s = set(repo.changelog.descendants(*args)) | set(args) return [r for r in subset if r in s] +def draft(repo, subset, x): + """``draft()`` + Changeset in draft phase.""" + getargs(x, 0, 0, _("draft takes no arguments")) + return [r for r in subset if repo._phaserev[r] == phases.draft] + def filelog(repo, subset, x): """``filelog(pattern)`` Changesets connected to the specified filelog. @@ -725,6 +731,12 @@ def present(repo, subset, x): except error.RepoLookupError: return [] +def public(repo, subset, x): + """``public()`` + Changeset in public phase.""" + getargs(x, 0, 0, _("public takes no arguments")) + return [r for r in subset if repo._phaserev[r] == phases.public] + def removes(repo, subset, x): """``removes(pattern)`` Changesets which remove files matching pattern. @@ -763,6 +775,12 @@ def roots(repo, subset, x): cs = set(children(repo, subset, x)) return [r for r in s if r not in cs] +def secret(repo, subset, x): + """``secret()`` + Changeset in secret phase.""" + getargs(x, 0, 0, _("secret takes no arguments")) + return [r for r in subset if repo._phaserev[r] == phases.secret] + def sort(repo, subset, x): """``sort(set[, [-]key...])`` Sort set by keys. The default sort order is ascending, specify a key @@ -861,6 +879,7 @@ symbols = { "date": date, "desc": desc, "descendants": descendants, + "draft": draft, "file": hasfile, "filelog": filelog, "first": first, @@ -881,11 +900,13 @@ symbols = { "p2": p2, "parents": parents, "present": present, + "public": public, "removes": removes, "rev": rev, "reverse": reverse, "roots": roots, "sort": sort, + "secret": secret, "tag": tag, "tagged": tagged, "user": user, diff --git a/tests/test-phases.t b/tests/test-phases.t --- a/tests/test-phases.t +++ b/tests/test-phases.t @@ -134,3 +134,19 @@ Test secret changeset are not pull 2 0 C 1 0 B 0 0 A + $ cd .. + +Test revset + + $ cd initialrepo + $ hglog -r 'public()' + 0 0 A + 1 0 B + 2 0 C + 3 0 D + 6 0 B' + $ hglog -r 'draft()' + $ hglog -r 'secret()' + 4 2 E + 5 2 H + 7 2 merge B' and E