# HG changeset patch # User Ronny Pfannschmidt # Date 1225966658 -3600 # Node ID eae1767cc6a8002a1d75b3af40e11782efc288ba # Parent 95e1260b8134c7977298b52f53c60a1b69951a79 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 -r 95e1260b8134 -r eae1767cc6a8 mercurial/cmdutil.py --- a/mercurial/cmdutil.py Thu Nov 06 10:39:52 2008 +0100 +++ b/mercurial/cmdutil.py Thu Nov 06 11:17:38 2008 +0100 @@ -214,9 +214,12 @@ def make_file(repo, pat, node=None, total=None, seqno=None, revwidth=None, mode='wb', pathname=None): + + writable = 'w' in mode or 'a' in mode + if not pat or pat == '-': - return 'w' in mode and sys.stdout or sys.stdin - if hasattr(pat, 'write') and 'w' in mode: + return writable and sys.stdout or sys.stdin + if hasattr(pat, 'write') and writable: return pat if hasattr(pat, 'read') and 'r' in mode: return pat diff -r 95e1260b8134 -r eae1767cc6a8 mercurial/patch.py --- a/mercurial/patch.py Thu Nov 06 10:39:52 2008 +0100 +++ b/mercurial/patch.py Thu Nov 06 11:17:38 2008 +0100 @@ -1294,7 +1294,8 @@ if not fp: fp = cmdutil.make_file(repo, template, node, total=total, - seqno=seqno, revwidth=revwidth) + seqno=seqno, revwidth=revwidth, + mode='ab') if fp != sys.stdout and hasattr(fp, 'name'): repo.ui.note("%s\n" % fp.name) diff -r 95e1260b8134 -r eae1767cc6a8 tests/test-export --- a/tests/test-export Thu Nov 06 10:39:52 2008 +0100 +++ b/tests/test-export Thu Nov 06 11:17:38 2008 +0100 @@ -13,3 +13,9 @@ echo "# foo-$out.patch" hg export -v -o "foo-$out.patch" 2:tip done + +echo "# exporting 4 changesets to a file" +hg export -o export_internal 1 2 3 4 +grep HG export_internal | wc -l +echo "# exporting 4 changesets to a file" +hg export 1 2 3 4 | grep HG | wc -l diff -r 95e1260b8134 -r eae1767cc6a8 tests/test-export.out --- a/tests/test-export.out Thu Nov 06 10:39:52 2008 +0100 +++ b/tests/test-export.out Thu Nov 06 11:17:38 2008 +0100 @@ -58,3 +58,7 @@ foo-09.patch foo-10.patch foo-11.patch +# exporting 4 changesets to a file +4 +# exporting 4 changesets to a file +4