# HG changeset patch # User Martin von Zweigbergk # Date 2015-03-20 17:05:31 # Node ID 66a69da9cde4b100e28865492c138cf5fe554db5 # Parent 1356086a7cf3bd0a40d78271d518bcfdef6e9161 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'. diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py +++ b/hgext/largefiles/overrides.py @@ -734,7 +734,7 @@ def overridecopy(orig, ui, repo, pats, o # 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 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 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() diff --git a/hgext/largefiles/uisetup.py b/hgext/largefiles/uisetup.py --- a/hgext/largefiles/uisetup.py +++ b/hgext/largefiles/uisetup.py @@ -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)