Skip to content
Snippets Groups Projects
Commit 7b2580e0 authored by Martin von Zweigbergk's avatar Martin von Zweigbergk
Browse files

largefiles: use wrappedfunction() in overriderevert()

Differential Revision: https://phab.mercurial-scm.org/D5869
parent d9fd2f74
No related branches found
No related tags found
No related merge requests found
......@@ -78,22 +78,6 @@
m.matchfn = lambda f: notlfile(f) and origmatchfn(f)
return m
def installmatchfn(f):
'''monkey patch the scmutil module with a custom match function.
Warning: it is monkey patching the _module_ on runtime! Not thread safe!'''
oldmatch = scmutil.match
setattr(f, 'oldmatch', oldmatch)
scmutil.match = f
return oldmatch
def restorematchfn():
'''restores scmutil.match to what it was before installmatchfn
was called. no-op if scmutil.match is its original function.
Note that n calls to installmatchfn will require n calls to
restore the original matchfn.'''
scmutil.match = getattr(scmutil.match, 'oldmatch')
def addlargefiles(ui, repo, isaddremove, matcher, **opts):
large = opts.get(r'large')
lfsize = lfutil.getminsize(
......@@ -756,7 +740,7 @@
oldstandins = lfutil.getstandinsstate(repo)
def overridematch(mctx, pats=(), opts=None, globbed=False,
def overridematch(orig, mctx, pats=(), opts=None, globbed=False,
default='relpath', badfn=None):
if opts is None:
opts = {}
......@@ -760,7 +744,7 @@
default='relpath', badfn=None):
if opts is None:
opts = {}
match = oldmatch(mctx, pats, opts, globbed, default, badfn=badfn)
match = orig(mctx, pats, opts, globbed, default, badfn=badfn)
m = copy.copy(match)
# revert supports recursing into subrepos, and though largefiles
......@@ -791,6 +775,5 @@
return origmatchfn(f)
m.matchfn = matchfn
return m
oldmatch = installmatchfn(overridematch)
try:
with extensions.wrappedfunction(scmutil, 'match', overridematch):
orig(ui, repo, ctx, parents, *pats, **opts)
......@@ -796,6 +779,4 @@
orig(ui, repo, ctx, parents, *pats, **opts)
finally:
restorematchfn()
newstandins = lfutil.getstandinsstate(repo)
filelist = lfutil.getlfilestoupdate(oldstandins, newstandins)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment