Mercurial > hg
changeset 19944:b7f76db06dc0 stable
cmdutil: fix makefileobj not to clobber default modemap dict
Problem occurs if "hg cat -o" is invoked more than once in the same process.
The output of "hg cat" will be appended because of modemap[fn] = 'ab'.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Tue, 22 Oct 2013 23:38:58 +0900 |
parents | 4de116871044 |
children | 3d42a85f6922 |
files | mercurial/cmdutil.py |
diffstat | 1 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Tue Oct 22 12:41:05 2013 +0900 +++ b/mercurial/cmdutil.py Tue Oct 22 23:38:58 2013 +0900 @@ -170,7 +170,7 @@ inst.args[0]) def makefileobj(repo, pat, node=None, desc=None, total=None, - seqno=None, revwidth=None, mode='wb', modemap={}, + seqno=None, revwidth=None, mode='wb', modemap=None, pathname=None): writable = mode not in ('r', 'rb') @@ -198,9 +198,10 @@ if util.safehasattr(pat, 'read') and 'r' in mode: return pat fn = makefilename(repo, pat, node, desc, total, seqno, revwidth, pathname) - mode = modemap.get(fn, mode) - if mode == 'wb': - modemap[fn] = 'ab' + if modemap is not None: + mode = modemap.get(fn, mode) + if mode == 'wb': + modemap[fn] = 'ab' return open(fn, mode) def openrevlog(repo, cmd, file_, opts):