# HG changeset patch # User Matt Harbison # Date 2015-03-26 01:54:47 # Node ID 06d199e66bbcc4ce62da1d20e740746a753a362d # Parent 40b05303ac321fc245058e092e442f26562ae6a3 revert: handle subrepos missing in the given --rev The list of subrepos to revert is currently based on the given --rev, so there is currently no way for this to fail. Using the --rev context is wrong though, because if the subrepo doesn't exist in --rev, it is skipped, so it won't be changed. This change makes it so that the revert aborts, which is what happens if a plain file is reverted to -1. Finding matches based on --rev is also inconsistent with evaluating files against the working directory (5b85a5bc5bbb). This change is made now, so as to not cause breakage when the context is switched in an upcoming patch. diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -3055,7 +3055,11 @@ def revert(ui, repo, ctx, parents, *pats if targetsubs: # Revert the subrepos on the revert list for sub in targetsubs: - ctx.sub(sub).revert(ctx.substate[sub], *pats, **opts) + try: + ctx.sub(sub).revert(ctx.substate[sub], *pats, **opts) + except KeyError: + raise util.Abort("subrepository '%s' does not exist in %s!" + % (sub, short(ctx.node()))) finally: wlock.release()