changeset 840:141744605b51

hg status: added options to select files by status. Added options -m, -a, -r and u to select files corresponding to status M, A, R and ? respectively. If none of these options are specified, files of all status will be shown.
author tksoh@users.sourceforge.net
date Sat, 06 Aug 2005 07:09:10 +0100
parents 9c918287d10b
children 03cc2ba291d1
files doc/hg.1.txt mercurial/commands.py
diffstat 2 files changed, 24 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/doc/hg.1.txt	Thu Aug 04 13:31:25 2005 -0800
+++ b/doc/hg.1.txt	Sat Aug 06 07:09:10 2005 +0100
@@ -346,6 +346,10 @@
 
     options:
 
+    -m, --modified       show only modified files
+    -a, --added          show only added files
+    -r, --removed        show only removed files
+    -u, --unknown        show only unknown (not tracked) files
     -I, --include <pat>  include names matching the given patterns
     -X, --exclude <pat>  exclude names matching the given patterns
 
--- a/mercurial/commands.py	Thu Aug 04 13:31:25 2005 -0800
+++ b/mercurial/commands.py	Sat Aug 06 07:09:10 2005 +0100
@@ -1040,14 +1040,17 @@
     (c, a, d, u) = [[pathto(cwd, x) for x in n]
                     for n in repo.changes(files=files, match=matchfn)]
 
-    for f in c:
-        ui.write("M ", f, "\n")
-    for f in a:
-        ui.write("A ", f, "\n")
-    for f in d:
-        ui.write("R ", f, "\n")
-    for f in u:
-        ui.write("? ", f, "\n")
+    filetype = "";
+    if opts['modified']: filetype += "M";
+    if opts[   'added']: filetype += "A";
+    if opts[ 'removed']: filetype += "R";
+    if opts[ 'unknown']: filetype += "?";
+    if filetype == "" : filetype = "MAR?"
+    
+    for key, value in zip(["M", "A", "R", "?"], (c, a, d, u)):
+        if value and filetype.find(key) >= 0:
+            for f in value:
+                ui.write("%s " % key, f, "\n")
 
 def tag(ui, repo, name, rev=None, **opts):
     """add a tag for the current tip or a given revision"""
@@ -1261,10 +1264,15 @@
           ('t', 'templates', "", 'template map'),
           ('6', 'ipv6', None, 'use IPv6 in addition to IPv4')],
          "hg serve [OPTION]..."),
-    "^status": (status,
-                [('I', 'include', [], 'include path in search'),
-                 ('X', 'exclude', [], 'exclude path from search')],
-                'hg status [FILE]...'),
+    "^status":
+        (status,
+         [('m', 'modified', None, 'show only modified files'),
+          ('a', 'added', None, 'show only added files'),
+          ('r', 'removed', None, 'show only removed files'),
+          ('u', 'unknown', None, 'show only unknown (not tracked) files'),
+          ('I', 'include', [], 'include path in search'),
+          ('X', 'exclude', [], 'exclude path from search')],
+         "hg status [FILE]..."),
     "tag":
         (tag,
          [('l', 'local', None, 'make the tag local'),