[PATCH] add xargs support to status

TK Soh teekaysoh at yahoo.com
Sat Aug 27 03:25:52 CDT 2005


# HG changeset patch
# User TK Soh <teekaysoh at yahoo.com>
# Node ID 194a18b7e904c83c8ef3ba6a0a7d262beff1ae7c
# Parent  05dc7aba22ebfc3d9b7dbc4002396f06203f9444
status: added option -p and -0 to assist xargs

The -p option strips the status prefix of each file, while
-0 ends each file with a NUL character, instead of a newline.
Together, selected group of files can be passed to 'xargs -0'
for further processing.

diff -r 05dc7aba22eb -r 194a18b7e904 mercurial/commands.py
--- a/mercurial/commands.py	Fri Aug 26 23:49:23 2005
+++ b/mercurial/commands.py	Sat Aug 27 08:21:14 2005
@@ -1347,10 +1347,17 @@
                    ('removed', 'R', d),
                    ('unknown', '?', u)]
 
+    end = opts['print0'] and '\0' or '\n'
+    
     for opt, char, changes in ([ct for ct in changetypes if opts[ct[0]]]
                                or changetypes):
+        if opts['strip']:
+            format = "%%s%s" % end
+        else:
+            format = "%s %%s%s" % (char, end);
+            
         for f in changes:
-            ui.write("%s %s\n" % (char, f))
+            ui.write(format % f)
 
 def tag(ui, repo, name, rev=None, **opts):
     """add a tag for the current tip or a given revision"""
@@ -1628,6 +1635,8 @@
           ('a', 'added', None, 'show only added files'),
           ('r', 'removed', None, 'show only removed files'),
           ('u', 'unknown', None, 'show only unknown (not tracked) files'),
+          ('p', 'strip', None, 'strip status prefix'),
+          ('0', 'print0', None, 'end records with NUL'),
           ('I', 'include', [], 'include path in search'),
           ('X', 'exclude', [], 'exclude path from search')],
          "hg status [OPTION]... [FILE]..."),




		
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 


More information about the Mercurial mailing list