largefiles: override cmdutil.revert() instead of comands.revert()

By overriding the cmdutil method we don't need to override both the
function and the command. Also, we get access to the 'ctx' and
'parents' variables, which will soon prove useful.

Rename the 'ctx' argument to overridematch() to 'mctx' rather than
letting it shadow new 'ctx'.
This commit is contained in:
Martin von Zweigbergk 2015-03-20 10:05:31 -07:00
parent c140481b78
commit 08b24c9159
2 changed files with 9 additions and 12 deletions

View File

@ -734,7 +734,7 @@ def overridecopy(orig, ui, repo, pats, opts, rename=False):
# commits. Update the standins then run the original revert, changing
# the matcher to hit standins instead of largefiles. Based on the
# resulting standins update the largefiles.
def overriderevert(orig, ui, repo, *pats, **opts):
def overriderevert(orig, ui, repo, ctx, parents, *pats, **opts):
# Because we put the standins in a bad state (by updating them)
# and then return them to a correct state we need to lock to
# prevent others from changing them in their incorrect state.
@ -751,19 +751,20 @@ def overriderevert(orig, ui, repo, *pats, **opts):
oldstandins = lfutil.getstandinsstate(repo)
def overridematch(ctx, pats=[], opts={}, globbed=False,
def overridematch(mctx, pats=[], opts={}, globbed=False,
default='relpath'):
match = oldmatch(ctx, pats, opts, globbed, default)
match = oldmatch(mctx, pats, opts, globbed, default)
m = copy.copy(match)
# revert supports recursing into subrepos, and though largefiles
# currently doesn't work correctly in that case, this match is
# called, so the lfdirstate above may not be the correct one for
# this invocation of match.
lfdirstate = lfutil.openlfdirstate(ctx.repo().ui, ctx.repo(), False)
lfdirstate = lfutil.openlfdirstate(mctx.repo().ui, mctx.repo(),
False)
def tostandin(f):
if lfutil.standin(f) in ctx:
if lfutil.standin(f) in mctx:
return lfutil.standin(f)
elif lfutil.standin(f) in repo[None] or lfdirstate[f] == 'r':
return None
@ -775,13 +776,13 @@ def overriderevert(orig, ui, repo, *pats, **opts):
def matchfn(f):
if lfutil.isstandin(f):
return (origmatchfn(lfutil.splitstandin(f)) and
(f in repo[None] or f in ctx))
(f in repo[None] or f in mctx))
return origmatchfn(f)
m.matchfn = matchfn
return m
oldmatch = installmatchfn(overridematch)
try:
orig(ui, repo, *pats, **opts)
orig(ui, repo, ctx, parents, *pats, **opts)
finally:
restorematchfn()

View File

@ -113,11 +113,7 @@ def uisetup(ui):
entry = extensions.wrapfunction(subrepo.hgsubrepo, 'dirty',
overrides.overridedirty)
# Backout calls revert so we need to override both the command and the
# function
entry = extensions.wrapcommand(commands.table, 'revert',
overrides.overriderevert)
entry = extensions.wrapfunction(commands, 'revert',
entry = extensions.wrapfunction(cmdutil, 'revert',
overrides.overriderevert)
extensions.wrapfunction(archival, 'archive', overrides.overridearchive)