changeset 15819:33ca11b010e2

phases: implements simple revset symbol This changeset adds ``public()``, ``draft()`` and ``secret`` symbol for revset.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Fri, 06 Jan 2012 10:04:20 +0100
parents 57241845a4bb
children 2673006f7989
files mercurial/revset.py tests/test-phases.t
diffstat 2 files changed, 38 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Fri Jan 06 09:51:35 2012 +0100
+++ b/mercurial/revset.py	Fri Jan 06 10:04:20 2012 +0100
@@ -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 @@
     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 @@
     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 @@
     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 @@
     "date": date,
     "desc": desc,
     "descendants": descendants,
+    "draft": draft,
     "file": hasfile,
     "filelog": filelog,
     "first": first,
@@ -881,11 +900,13 @@
     "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,
--- a/tests/test-phases.t	Fri Jan 06 09:51:35 2012 +0100
+++ b/tests/test-phases.t	Fri Jan 06 10:04:20 2012 +0100
@@ -134,3 +134,19 @@
   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