changeset 842:8fb488773063

Rewritten change type selection for hg status.
author Thomas Arendsen Hein <thomas@intevation.de>
date Sat, 06 Aug 2005 12:05:09 +0100
parents 03cc2ba291d1
children 859e7ea530bd
files mercurial/commands.py
diffstat 1 files changed, 11 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sat Aug 06 07:16:37 2005 +0100
+++ b/mercurial/commands.py	Sat Aug 06 12:05:09 2005 +0100
@@ -1033,24 +1033,23 @@
     M = modified
     A = added
     R = removed
-    ? = not tracked'''
+    ? = not tracked
+    '''
 
     cwd = repo.getcwd()
     files, matchfn = matchpats(cwd, pats, opts)
     (c, a, d, u) = [[pathto(cwd, x) for x in n]
                     for n in repo.changes(files=files, match=matchfn)]
 
-    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")
+    changetypes = [('modified', 'M', c),
+                   ('added', 'A', a),
+                   ('removed', 'R', d),
+                   ('unknown', '?', u)]
+
+    for opt, char, changes in ([ct for ct in changetypes if opts[ct[0]]]
+                               or changetypes):
+        for f in changes:
+            ui.write("%s %s\n" % (char, f))
 
 def tag(ui, repo, name, rev=None, **opts):
     """add a tag for the current tip or a given revision"""