[PATCH V2 1/2] diff: add the --output option

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Jul 9 17:10:20 CDT 2013


On 1 juil. 2013, at 18:25, Ahmed S. Darwish wrote:

> # HG changeset patch
> # User Ahmed S. Darwish <a.darwish at vireton.com>
> # Date 1372695210 -7200
> # Node ID c1aa2fdfc7b7a8fff58b192259dcdf4f74f7ada7
> # Parent  648d1974b3f328947ee6cf2d00c66815a33cd208
> diff: add the --output option
> 
> For all shells which cannot save a command standard output correctly,
> this option is now introduced.
> 
> The most common example is Microsoft PowerShell, where the piped
> output gets corrupted if saved using the standard, unix-like, stdout
> rediction, '>' operator. By transforming the piped output to a
> different encoding, PowerShell saves 'hg diff' patch output to a
> format __not understandable__ by GNU patch and 'hg patch' commands.

Really, that is an impressive level of failure. From the example you pasted it seems that line ending get converted.

But why are you adding it to diff only ? Output of any Mercurial commands can get corrupted. And multiple other commands export diff (log -p, export, …) A global setting would make more sense.

However, I would be sad to see such flag added when the shell is to blame. Maybe an environment variable could do the job: `HGSTDOUT=<filename> hg diff`. That would (1) allow any commands to redirect it's output. (2) avoid adding a very visible flag for all users of a sensible shell.

(question: have you considered patch hg import so it can import patch using such line ending ?)

-- 
Pierre-Yves David



More information about the Mercurial-devel mailing list