Patchwork D5866: largefiles: use wrappedfunction() for util.copyfile() override

login
register
mail settings
Submitter phabricator
Date Feb. 6, 2019, 11:56 a.m.
Message ID <8642c8daf8a0d235b9db28638d646d7b@localhost.localdomain>
Download mbox | patch
Permalink /patch/38476/
State Not Applicable
Headers show

Comments

phabricator - Feb. 6, 2019, 11:56 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG028bb170e74d: largefiles: use wrappedfunction() for util.copyfile() override (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5866?vs=13841&id=13846

REVISION DETAIL
  https://phab.mercurial-scm.org/D5866

AFFECTED FILES
  hgext/largefiles/overrides.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers, pulkit
Cc: mercurial-devel

Patch

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 @@ 
             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: