Changeset 381fe7fc79fc…
Parent 5f2a747353a3…
by Andrew Pritchard <andrewp@fogcreek.com>
Changes to one file · Browse files at 381fe7fc79fc Showing diff from parent 5f2a747353a3 Diff from another changeset...
|
@@ -29,12 +29,7 @@ def installnormalfilesmatchfn(manifest):
'''overrides scmutil.match so that the matcher it returns will ignore all
largefiles'''
- try:
- # Mercurial >= 1.9
- oldmatch = scmutil.match
- except ImportError:
- # Mercurial <= 1.8
- oldmatch = cmdutil.match
+ oldmatch = None # for the closure
def override_match(repo, pats=[], opts={}, globbed=False,
default='relpath'):
match = oldmatch(repo, pats, opts, globbed, default)
@@ -46,13 +41,23 @@ orig_matchfn = m.matchfn
m.matchfn = lambda f: notlfile(f) and orig_matchfn(f) or None
return m
- setattr(override_match, 'oldmatch', oldmatch)
+ oldmatch = installmatchfn(override_match)
+
+def installmatchfn(f):
try:
# Mercurial >= 1.9
- scmutil.match = override_match
+ oldmatch = scmutil.match
except ImportError:
# Mercurial <= 1.8
- cmdutil.match = override_match
+ oldmatch = cmdutil.match
+ setattr(f, 'oldmatch', oldmatch)
+ try:
+ # Mercurial >= 1.9
+ scmutil.match = f
+ except ImportError:
+ # Mercurial <= 1.8
+ cmdutil.match = f
+ return oldmatch
def restorematchfn():
'''restores scmutil.match to what it was before installnormalfilesmatchfn
@@ -371,17 +376,12 @@ return result
try:
- # Mercurial >= 1.9
- oldmatch = scmutil.match
- except ImportError:
- # Mercurial <= 1.8
- oldmatch = cmdutil.match
- try:
# When we call orig below it creates the standins but we don't add them
# to the dir state until later so lock during that time.
wlock = repo.wlock()
manifest = repo[None].manifest()
+ oldmatch = None # for the closure
def override_match(repo, pats=[], opts={}, globbed=False,
default='relpath'):
newpats = []
@@ -402,12 +402,7 @@ lfile(lfutil.splitstandin(f)) and \
orig_matchfn(lfutil.splitstandin(f)) or None
return m
- try:
- # Mercurial >= 1.9
- scmutil.match = override_match
- except ImportError:
- # Mercurial <= 1.9
- cmdutil.match = override_match
+ oldmatch = installmatchfn(override_match)
listpats = []
for pat in pats:
if match_.patkind(pat) is not None:
@@ -455,12 +450,7 @@ else:
nolfiles = True
finally:
- try:
- # Mercurial >= 1.9
- scmutil.match = oldmatch
- except ImportError:
- # Mercurial <= 1.8
- cmdutil.match = oldmatch
+ restorematchfn()
wlock.release()
if nolfiles and nonormalfiles:
@@ -489,13 +479,8 @@ lfutil.updatestandin(repo, lfutil.standin(lfile))
try:
- # Mercurial >= 1.9
- oldmatch = scmutil.match
- except ImportError:
- # Mercurial <= 1.8
- oldmatch = cmdutil.match
- try:
ctx = repo[opts.get('rev')]
+ oldmatch = None # for the closure
def override_match(ctxorrepo, pats=[], opts={}, globbed=False,
default='relpath'):
if hasattr(ctxorrepo, 'match'):
@@ -533,22 +518,17 @@ return orig_matchfn(f)
m.matchfn = matchfn
return m
+ oldmatch = installmatchfn(override_match)
try:
# Mercurial >= 1.9
- scmutil.match = override_match
+ scmutil.match
matches = override_match(repo[None], pats, opts)
except ImportError:
# Mercurial <= 1.8
- cmdutil.match = override_match
matches = override_match(repo, pats, opts)
orig(ui, repo, *pats, **opts)
finally:
- try:
- # Mercurial >= 1.9
- scmutil.match = oldmatch
- except ImportError:
- # Mercurial <= 1.8
- cmdutil.match = oldmatch
+ restorematchfn()
lfileslist = getattr(repo, '_lfilestoupdate', [])
lfcommands.updatelfiles(ui, repo, filelist=lfileslist, printmessage=False)
# Empty out the lfiles list so we start fresh next time
|
Loading...