[PATCH] export: make -o foo overwrite, not append

Kevin Bullock kbullock+mercurial at ringworld.org
Thu Oct 4 16:10:44 CDT 2012


On Oct 4, 2012, at 1:54 PM, Jordi Gutiérrez Hermoso wrote:

> On 4 October 2012 14:08, Kevin Bullock <kbullock+mercurial at ringworld.org> wrote:
>> On Oct 4, 2012, at 12:41 PM, Jordi Gutiérrez Hermoso wrote:
>> 
>>> # HG changeset patch
>>> # User Jordi Gutiérrez Hermoso <jordigh at octave.org>
>>> # Date 1349372425 14400
>>> # Node ID 80eea80279e6804128b828da97ff57c1da89a07c
>>> # Parent  fa714f3ed2989aff64c267c9935251d9fc4f31ee
>>> export: make -o foo overwrite, not append
>>> 
>>> Currently, "hg export -r foo -o bar" appends the results to bar, which
>>> is mentioned nowhere in the documentation. This confuses users who
>>> expect to get only one change in there, not several. This cset just
>>> makes the -o option overwrite, not append.
>> 
>> I agree that that's surprising behavior, especially when exporting
>> multiple changes with a parameterized file name spec. But it appears
>> to go back to this:
>> 
>> changeset:   7319:eae1767cc6a8
>> user:        Ronny Pfannschmidt <Ronny.Pfannschmidt at gmx.de>
>> date:        Thu Nov 06 11:17:38 2008 +0100
>> files:       mercurial/cmdutil.py mercurial/patch.py tests/test-export tests/test-export.out
>> description:
>> export: fixed silent output file overwriting
>> 
>> hg export -o outfile 1 2 3 4 had the same effect as hg -o outfile 4
>> 
>> This was caused by opening with 'w' instead of 'a'. This only occurs when
>> the filename pattern resulted in ambiguous patch filenames.
> 
> So, should the current behaviour stay? Then it should be documented.
> Should I do that?

I suspect that we actually want to do something more nuanced here. If we only have a single output file, we may want to keep the current append behavior (or might not, in which case we still want to preserve the ability to export multiple changesets to a single file). But for multiple files (i.e., multiple changes being exported AND a parameterized OUTFILESPEC), we probably want to either abort or overwrite.

Am I correct in that assessment?

pacem in terris / мир / शान्ति / ‎‫سَلاَم‬ / 平和
Kevin R. Bullock

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20121004/28074255/attachment.html>


More information about the Mercurial-devel mailing list