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

Haszlakiewicz, Eric EHASZLA at transunion.com
Thu Dec 2 13:03:27 CST 2010

>-----Original Message-----
>From: Mads Kiilerich [mailto:mads at kiilerich.com]
>On 12/02/2010 04:34 PM, Haszlakiewicz, Eric wrote:
>> 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
>Some random thoughts:
>Why do you want it for exactly this command? What is the use case?

I'm writing a wrapper that handles pulling/transplanting/merging changesets from one repository to another, and I need to know when a merge requires manual intervention, and which files are affected.

>It might be a bit inefficient to add --print0 to all commands one by
>one. Could it be added to all relevant commands at once? For example
>manifest looks like an obvious candidate.
>But do we want to add --print0 everywhere? Wouldn't it be better to add
>--template and --style everywhere and implement a zero separation
>filter? And perhaps add --print0 as some kind of shortcut?

I would love to have a --style option everywhere, and a json template that can reliably output all the information from every command, but that would be a considerably more involved change.

If you just want to use a template map file with NUL separators, there's no need to add a custom filter, just put '\0' in the template map file. e.g.:
file_add  = '{file_add}\0'

but, what keyword applies to the output of resolve, or manifest, or any other command?  Perhaps we'd need a per-command keyword (or keywords).  That would go a long way towards making the behaviour more obvious.  e.g. the log command would end up with something like:
  command_log = '{header}{changesets}{footer}'
rather than having that hard coded into cmdutil.py.
So, resolve would end up with (ugh, the permutations of various options make this annoying, as well as the implicit behaviours of resolve_files and resolved_status):
  command_resolve--list = '{resolve_files}'
  resolve_file= '{resolved_statusX}{file}\n'
  resolve_file--print0 = '{resolved_statusX}{file}\0'
  resolved_statusX = '{resolved_status}'
  resolved_statusX--nostatus= ''

However, this is also a considerably more involved change.  I was hoping just for a simple addition of a --print0 option to resolve, as it exists in other commands.

>More important:
>A test could be nice. The other --print0 options are also not tested,
>but that is a bad excuse. See WritingTests. run-tests.py should
>automagically escape the output and show the zeros.

I don't think I have the time to put together a test right now.  Sorry.

-------------- 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/f78af1d1/attachment.pgp>

More information about the Mercurial-devel mailing list