[PATCH] export: make -o foo overwrite, not append
Kevin Bullock
kbullock+mercurial at ringworld.org
Thu Oct 4 13:08:13 CDT 2012
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.
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -552,7 +552,7 @@
> desc_lines = ctx.description().rstrip().split('\n')
> desc = desc_lines[0] #Commit always has a first line.
> fp = makefileobj(repo, template, node, desc=desc, total=total,
> - seqno=seqno, revwidth=revwidth, mode='ab')
> + seqno=seqno, revwidth=revwidth, mode='wb')
> if fp != template:
> shouldclose = True
> if fp and fp != sys.stdout and util.safehasattr(fp, 'name'):
> @@ -564,7 +564,6 @@
> def write(s, **kw):
> fp.write(s)
>
> -
Unrelated whitespace change.
pacem in terris / мир / शान्ति / سَلاَم / 平和
Kevin R. Bullock
> write("# HG changeset patch\n")
> write("# User %s\n" % ctx.user())
> write("# Date %d %d\n" % ctx.date())
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list