diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1056,7 +1056,7 @@ def export(repo, revs, template='hg-%h.p modemap=filemode) if fp != template: shouldclose = True - if fp and fp != sys.stdout and util.safehasattr(fp, 'name'): + if fp and not getattr(fp, 'name', '').startswith('<'): repo.ui.note("%s\n" % fp.name) if not fp: diff --git a/tests/test-export.t b/tests/test-export.t --- a/tests/test-export.t +++ b/tests/test-export.t @@ -137,6 +137,25 @@ Exporting revision -2 to a file: foo-9 +foo-10 +No filename should be printed if stdout is specified explicitly: + + $ hg export -v 1 -o - + # HG changeset patch + # User test + # Date 0 0 + # Thu Jan 01 00:00:00 1970 +0000 + # Node ID d1c9656e973cfb5aebd5499bbd2cb350e3b12266 + # Parent 871558de6af2e8c244222f8eea69b782c94ce3df + foo-1 + + diff -r 871558de6af2 -r d1c9656e973c foo + --- a/foo Thu Jan 01 00:00:00 1970 +0000 + +++ b/foo Thu Jan 01 00:00:00 1970 +0000 + @@ -1,1 +1,2 @@ + foo-0 + +foo-1 + exporting patch: + Checking if only alphanumeric characters are used in the file name (%m option): $ echo "line" >> foo