# HG changeset patch # User Martin von Zweigbergk # Date 2019-02-05 22:29:37 # Node ID 028bb170e74dd0a0da4ef1bba39ab996b3912a7b # Parent 8d1dc380b02613605ca1e0fac12f474a01900918 largefiles: use wrappedfunction() for util.copyfile() override Differential Revision: https://phab.mercurial-scm.org/D5866 diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py +++ b/hgext/largefiles/overrides.py @@ -686,23 +686,18 @@ def overridecopy(orig, ui, repo, pats, o else: listpats.append(makestandin(pat)) - try: - origcopyfile = util.copyfile - copiedfiles = [] - def overridecopyfile(src, dest, *args, **kwargs): - if (lfutil.shortname in src and - dest.startswith(repo.wjoin(lfutil.shortname))): - destlfile = dest.replace(lfutil.shortname, '') - if not opts['force'] and os.path.exists(destlfile): - raise IOError('', - _('destination largefile already exists')) - copiedfiles.append((src, dest)) - origcopyfile(src, dest, *args, **kwargs) - - util.copyfile = overridecopyfile + copiedfiles = [] + def overridecopyfile(orig, src, dest, *args, **kwargs): + if (lfutil.shortname in src and + dest.startswith(repo.wjoin(lfutil.shortname))): + destlfile = dest.replace(lfutil.shortname, '') + if not opts['force'] and os.path.exists(destlfile): + raise IOError('', + _('destination largefile already exists')) + copiedfiles.append((src, dest)) + orig(src, dest, *args, **kwargs) + with extensions.wrappedfunction(util, 'copyfile', overridecopyfile): result += orig(ui, repo, listpats, opts, rename) - finally: - util.copyfile = origcopyfile lfdirstate = lfutil.openlfdirstate(ui, repo) for (src, dest) in copiedfiles: