Changeset 5f2a747353a3…
Parent dd4a727edd72…
by Andrew Pritchard <andrewp@fogcreek.com>
Changes to one file · Browse files at 5f2a747353a3 Showing diff from parent dd4a727edd72 Diff from another changeset...
|
|
@@ -26,6 +26,47 @@ import lfcommands
import proto
+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
+ def override_match(repo, pats=[], opts={}, globbed=False,
+ default='relpath'):
+ match = oldmatch(repo, pats, opts, globbed, default)
+ m = copy.copy(match)
+ notlfile = lambda f: not (lfutil.isstandin(f) or lfutil.standin(f) in
+ manifest)
+ m._files = filter(notlfile, m._files)
+ m._fmap = set(m._files)
+ orig_matchfn = m.matchfn
+ m.matchfn = lambda f: notlfile(f) and orig_matchfn(f) or None
+ return m
+ setattr(override_match, 'oldmatch', oldmatch)
+ try:
+ # Mercurial >= 1.9
+ scmutil.match = override_match
+ except ImportError:
+ # Mercurial <= 1.8
+ cmdutil.match = override_match
+
+def restorematchfn():
+ '''restores scmutil.match to what it was before installnormalfilesmatchfn
+ was called. no-op if scmutil.match is its original function.
+
+ Note that n calls to installnormalfilesmatchfn will require n calls to
+ restore matchfn to reverse'''
+ try:
+ # Mercurial >= 1.9
+ scmutil.match = getattr(scmutil.match, 'oldmatch', scmutil.match)
+ except ImportError:
+ # Mercurial <= 1.8
+ cmdutil.match = getattr(cmdutil.match, 'oldmatch', cmdutil.match)
+
# -- Wrappers: modify existing commands --------------------------------
# Add works by going through the files that the user wanted to add
@@ -103,66 +144,17 @@ finally:
wlock.release()
- try:
- # Mercurial >= 1.9
- oldmatch = scmutil.match
- except ImportError:
- # Mercurial <= 1.8
- oldmatch = cmdutil.match
- manifest = repo[None].manifest()
- def override_match(repo, pats=[], opts={}, globbed=False,
- default='relpath'):
- match = oldmatch(repo, pats, opts, globbed, default)
- m = copy.copy(match)
- notlfile = lambda f: not lfutil.isstandin(f) and lfutil.standin(f) not\
- in manifest
- m._files = [f for f in m._files if notlfile(f)]
- m._fmap = set(m._files)
- orig_matchfn = m.matchfn
- m.matchfn = lambda f: notlfile(f) and orig_matchfn(f) or None
- return m
- try:
- # Mercurial >= 1.9
- scmutil.match = override_match
- result = orig(ui, repo, *pats, **opts)
- scmutil.match = oldmatch
- except ImportError:
- # Mercurial <= 1.8
- cmdutil.match = override_match
- result = orig(ui, repo, *pats, **opts)
- cmdutil.match = oldmatch
+ installnormalfilesmatchfn(repo[None].manifest())
+ result = orig(ui, repo, *pats, **opts)
+ restorematchfn()
return (result == 1 or bad) and 1 or 0
def override_remove(orig, ui, repo, *pats, **opts):
- wctx = repo[None].manifest()
- try:
- # Mercurial >= 1.9
- oldmatch = scmutil.match
- except ImportError:
- # Mercurial <= 1.8
- oldmatch = cmdutil.match
- def override_match(repo, pats=[], opts={}, globbed=False,
- default='relpath'):
- match = oldmatch(repo, pats, opts, globbed, default)
- m = copy.copy(match)
- notlfile = lambda f: not lfutil.isstandin(f) and lfutil.standin(f) not\
- in wctx
- m._files = [f for f in m._files if notlfile(f)]
- m._fmap = set(m._files)
- orig_matchfn = m.matchfn
- m.matchfn = lambda f: orig_matchfn(f) and notlfile(f)
- return m
- try:
- # Mercurial >= 1.9
- scmutil.match = override_match
- orig(ui, repo, *pats, **opts)
- scmutil.match = oldmatch
- except ImportError:
- # Mercurial <= 1.8
- cmdutil.match = override_match
- orig(ui, repo, *pats, **opts)
- cmdutil.match = oldmatch
+ manifest = repo[None].manifest()
+ installnormalfilesmatchfn(manifest)
+ orig(ui, repo, *pats, **opts)
+ restorematchfn()
after, force = opts.get('after'), opts.get('force')
if not pats and not after:
@@ -179,7 +171,7 @@ finally:
repo.lfstatus = False
modified, added, deleted, clean = [[f for f in list if lfutil.standin(f) \
- in wctx] for list in [s[0], s[1], s[3], s[6]]]
+ in manifest] for list in [s[0], s[1], s[3], s[6]]]
def warn(files, reason):
for f in files:
@@ -360,30 +352,7 @@ nonormalfiles = False
nolfiles = False
try:
- # Mercurial >= 1.9
- oldmatch = scmutil.match
- except ImportError:
- # Mercurial <= 1.8
- oldmatch = cmdutil.match
- try:
- manifest = repo[None].manifest()
- def override_match(repo, pats=[], opts={}, globbed=False,
- default='relpath'):
- match = oldmatch(repo, pats, opts, globbed, default)
- m = copy.copy(match)
- notlfile = lambda f: not lfutil.isstandin(f) and lfutil.standin(f)\
- not in manifest
- m._files = [f for f in m._files if notlfile(f)]
- m._fmap = set(m._files)
- orig_matchfn = m.matchfn
- m.matchfn = lambda f: notlfile(f) and orig_matchfn(f) or None
- return m
- try:
- # Mercurial >= 1.9
- scmutil.match = override_match
- except ImportError:
- # Mercurial <= 1.8
- cmdutil.match = override_match
+ installnormalfilesmatchfn(repo[None].manifest())
result = orig(ui, repo, pats, opts, rename)
except util.Abort, e:
if str(e) != 'no files to copy':
@@ -392,12 +361,7 @@ nonormalfiles = True
result = 0
finally:
- try:
- # Mercurial >= 1.9
- scmutil.match = oldmatch
- except ImportError:
- # Mercurial <= 1.8
- cmdutil.match = oldmatch
+ restorematchfn()
# The first rename can cause our current working directory to be removed.
# In that case there is nothing left to copy/rename so just quit.
@@ -407,6 +371,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()
@@ -786,35 +756,14 @@ return orig(ui, repo, *pats, **opts)
def override_forget(orig, ui, repo, *pats, **opts):
- wctx = repo[None].manifest()
+ installnormalfilesmatchfn(repo[None].manifest())
+ orig(ui, repo, *pats, **opts)
+ restorematchfn()
try:
# Mercurial >= 1.9
- oldmatch = scmutil.match
- except ImportError:
- # Mercurial <= 1.8
- oldmatch = cmdutil.match
- def override_match(repo, pats=[], opts={}, globbed=False,
- default='relpath'):
- match = oldmatch(repo, pats, opts, globbed, default)
- m = copy.copy(match)
- notlfile = lambda f: not lfutil.isstandin(f) and lfutil.standin(f) not\
- in wctx
- m._files = [f for f in m._files if notlfile(f)]
- m._fmap = set(m._files)
- orig_matchfn = m.matchfn
- m.matchfn = lambda f: orig_matchfn(f) and notlfile(f)
- return m
- try:
- # Mercurial >= 1.9
- scmutil.match = override_match
- orig(ui, repo, *pats, **opts)
- scmutil.match = oldmatch
m = scmutil.match(repo[None], pats, opts)
except ImportError:
# Mercurial <= 1.8
- cmdutil.match = override_match
- orig(ui, repo, *pats, **opts)
- cmdutil.match = oldmatch
m = cmdutil.match(repo, pats, opts)
try:
@@ -823,7 +772,7 @@ finally:
repo.lfstatus = False
forget = sorted(s[0] + s[1] + s[3] + s[6])
- forget = [f for f in forget if lfutil.standin(f) in wctx]
+ forget = [f for f in forget if lfutil.standin(f) in repo[None].manifest()]
for f in forget:
if lfutil.standin(f) not in repo.dirstate and not \
|
Loading...