revert: handle subrepos missing in the given --rev
authorMatt Harbison <matt_harbison@yahoo.com>
Wed, 25 Mar 2015 21:54:47 -0400
changeset 24463 06d199e66bbc
parent 24462 40b05303ac32
child 24464 30ddc3cf76df
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.
mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Wed Mar 25 16:21:58 2015 -0700
+++ b/mercurial/cmdutil.py	Wed Mar 25 21:54:47 2015 -0400
@@ -3055,7 +3055,11 @@
         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()