diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -3049,14 +3049,14 @@ def revert(ui, repo, ctx, parents, *pats _performrevert(repo, parents, ctx, actions, interactive) # get the list of subrepos that must be reverted - subrepomatch = scmutil.match(ctx, pats, opts) - targetsubs = sorted(s for s in ctx.substate if subrepomatch(s)) + subrepomatch = scmutil.match(wctx, pats, opts) + targetsubs = sorted(s for s in wctx.substate if subrepomatch(s)) if targetsubs: # Revert the subrepos on the revert list for sub in targetsubs: try: - ctx.sub(sub).revert(ctx.substate[sub], *pats, **opts) + wctx.sub(sub).revert(ctx.substate[sub], *pats, **opts) except KeyError: raise util.Abort("subrepository '%s' does not exist in %s!" % (sub, short(ctx.node()))) diff --git a/tests/test-subrepo-recursion.t b/tests/test-subrepo-recursion.t --- a/tests/test-subrepo-recursion.t +++ b/tests/test-subrepo-recursion.t @@ -528,9 +528,19 @@ The subrepo must sorts after the explici $ hg init test $ cd test $ hg init x + $ echo abc > abc.txt + $ hg ci -Am "abc" + adding abc.txt $ echo "x = x" >> .hgsub $ hg add .hgsub $ touch a x/a $ hg add a x/a + $ hg ci -Sm "added x" + committing subrepository x + $ echo abc > x/a + $ hg revert --rev '.^' "set:subrepo('glob:x*')" + abort: subrepository 'x' does not exist in 25ac2c9b3180! + [255] + $ cd ..