[PATCH] patch to add --print0 option to hg resolve (issue2532)

Haszlakiewicz, Eric EHASZLA at transunion.com
Thu Dec 2 09:34:18 CST 2010


I noticed that "hg resolve" doesn't have a --print0 option.  The following patch adds that so you can do things like:

  hg resolve --list --no-status --print0 | xargs -0 foo

--- commands.py.orig	2010-12-01 14:34:36.000000000 -0500
+++ commands.py	2010-12-01 14:37:31.000000000 -0500
@@ -3017,13 +3017,17 @@
     m = cmdutil.match(repo, pats, opts)
     ret = 0
 
+    sep = '\n'
+    if opts.get('print0'):
+        sep = '\0'
+
     for f in ms:
         if m(f):
             if show:
                 if nostatus:
-                    ui.write("%s\n" % f)
+                    ui.write("%s%c" % (f, sep))
                 else:
-                    ui.write("%s %s\n" % (ms[f].upper(), f),
+                    ui.write("%s %s%c" % (ms[f].upper(), f, sep),
                              label='resolve.' +
                              {'u': 'unresolved', 'r': 'resolved'}[ms[f]])
             elif mark:
@@ -4397,8 +4401,10 @@
           ('m', 'mark', None, _('mark files as resolved')),
           ('u', 'unmark', None, _('mark files as unresolved')),
           ('t', 'tool', '', _('specify merge tool')),
-          ('n', 'no-status', None, _('hide status prefix'))]
-          + walkopts,
+          ('n', 'no-status', None, _('hide status prefix')),
+          ('0', 'print0', None,
+           _('end filenames with NUL, for use with xargs')),
+         ] + walkopts,
           _('[OPTION]... [FILE]...')),
     "revert":
         (revert,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 474 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20101202/2eb1c75f/attachment.pgp>


More information about the Mercurial-devel mailing list