# HG changeset patch # User Benoit Boissinot # Date 1257008533 -3600 # Node ID 5c8651e2f5e07044c6ac943ab67961bffaeaf5c1 # Parent bd70f645cfb042e39d2a0c29e679408c5be74f06 patch: don't use mutable object as default argument diff -r bd70f645cfb0 -r 5c8651e2f5e0 mercurial/patch.py --- a/mercurial/patch.py Sat Oct 31 18:01:08 2009 +0100 +++ b/mercurial/patch.py Sat Oct 31 18:02:13 2009 +0100 @@ -1005,12 +1005,12 @@ return -1 return err -def diffopts(ui, opts={}, untrusted=False): +def diffopts(ui, opts=None, untrusted=False): def get(key, name=None, getter=ui.configbool): - return (opts.get(key) or + return ((opts and opts.get(key)) or getter('diff', name or key, None, untrusted=untrusted)) return mdiff.diffopts( - text=opts.get('text'), + text=opts and opts.get('text'), git=get('git'), nodates=get('nodates'), showfunc=get('show_function', 'showfunc'), @@ -1096,10 +1096,12 @@ util.explain_exit(code)[0]) return fuzz -def internalpatch(patchobj, ui, strip, cwd, files={}, eolmode='strict'): +def internalpatch(patchobj, ui, strip, cwd, files=None, eolmode='strict'): """use builtin patch to apply to the working directory. returns whether patch was applied with fuzz factor.""" + if files is None: + files = {} if eolmode is None: eolmode = ui.config('patch', 'eol', 'strict') try: @@ -1123,7 +1125,7 @@ raise PatchError return ret > 0 -def patch(patchname, ui, strip=1, cwd=None, files={}, eolmode='strict'): +def patch(patchname, ui, strip=1, cwd=None, files=None, eolmode='strict'): """Apply to the working directory. 'eolmode' specifies how end of lines should be handled. It can be: @@ -1137,6 +1139,8 @@ """ patcher = ui.config('ui', 'patch') args = [] + if files is None: + files = {} try: if patcher: return externalpatch(patcher, args, patchname, ui, strip, cwd,