fileset: add resolved and unresolved predicates
authorMatt Mackall <mpm@selenic.com>
Sat, 18 Jun 2011 16:53:49 -0500
changeset 14679 e141e1cee0cc
parent 14678 5ef7b87530f6
child 14680 49af5fa3809b
fileset: add resolved and unresolved predicates
mercurial/fileset.py
--- a/mercurial/fileset.py	Sat Jun 18 16:53:49 2011 -0500
+++ b/mercurial/fileset.py	Sat Jun 18 16:53:49 2011 -0500
@@ -5,7 +5,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-import parser, error, util
+import parser, error, util, merge
 from i18n import _
 
 elements = {
@@ -175,6 +175,20 @@
     getargs(x, 0, 0, _("symlink takes no arguments"))
     return [f for f in mctx.subset if mctx.ctx.flags(f) == 'l']
 
+def resolved(mctx, x):
+    getargs(x, 0, 0, _("resolved takes no arguments"))
+    if mctx.ctx.rev() is not None:
+        return []
+    ms = merge.mergestate(mctx.ctx._repo)
+    return [f for f in mctx.subset if f in ms and ms[f] == 'r']
+
+def unresolved(mctx, x):
+    getargs(x, 0, 0, _("unresolved takes no arguments"))
+    if mctx.ctx.rev() is not None:
+        return []
+    ms = merge.mergestate(mctx.ctx._repo)
+    return [f for f in mctx.subset if f in ms and ms[f] == 'u']
+
 symbols = {
     'added': added,
     'binary': binary,
@@ -184,8 +198,10 @@
     'ignored': ignored,
     'modified': modified,
     'removed': removed,
+    'resolved': resolved,
     'symlink': symlink,
     'unknown': unknown,
+    'unresolved': unresolved,
 }
 
 methods = {