diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2811,6 +2811,10 @@ def revert(ui, repo, ctx, parents, *pats interactive = opts.get('interactive', False) wctx = repo[None] m = scmutil.match(wctx, pats, opts) + + # we'll need this later + targetsubs = sorted(s for s in wctx.substate if m(s)) + if not m.always(): m.bad = lambda x, y: False for abs in repo.walk(m): @@ -3048,10 +3052,6 @@ def revert(ui, repo, ctx, parents, *pats _revertprefetch(repo, ctx, *[actions[name][0] for name in needdata]) _performrevert(repo, parents, ctx, actions, interactive) - # get the list of subrepos that must be reverted - 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: diff --git a/tests/test-subrepo-missing.t b/tests/test-subrepo-missing.t --- a/tests/test-subrepo-missing.t +++ b/tests/test-subrepo-missing.t @@ -34,6 +34,7 @@ delete .hgsub and revert it $ hg revert .hgsub warning: subrepo spec file .hgsub not found warning: subrepo spec file .hgsub not found + warning: subrepo spec file .hgsub not found delete .hgsubstate and revert it