# HG changeset patch # User Matt Harbison # Date 1423363648 18000 # Node ID afed5d2e79854419516e915309556ff84eec0652 # Parent 79c2c29c71aea5d19d5fdb98017f1f4d72a167b1 revert: display full subrepo output with --dry-run Since the point of --dry-run is to show what will happen, the output with and without it should agree. And since revert wasn't being called on subrepos with --dry-run before, revert in the subrepo had to be defanged in this case. diff -r 79c2c29c71ae -r afed5d2e7985 mercurial/cmdutil.py --- a/mercurial/cmdutil.py Sat Feb 07 19:40:02 2015 -0500 +++ b/mercurial/cmdutil.py Sat Feb 07 21:47:28 2015 -0500 @@ -2783,14 +2783,14 @@ _performrevert(repo, parents, ctx, actions) - # 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)) - - if targetsubs: - # Revert the subrepos on the revert list - for sub in targetsubs: - ctx.sub(sub).revert(ctx.substate[sub], *pats, **opts) + # 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)) + + if targetsubs: + # Revert the subrepos on the revert list + for sub in targetsubs: + ctx.sub(sub).revert(ctx.substate[sub], *pats, **opts) finally: wlock.release() diff -r 79c2c29c71ae -r afed5d2e7985 mercurial/subrepo.py --- a/mercurial/subrepo.py Sat Feb 07 19:40:02 2015 -0500 +++ b/mercurial/subrepo.py Sat Feb 07 21:47:28 2015 -0500 @@ -884,7 +884,8 @@ self.filerevert(*pats, **opts) # Update the repo to the revision specified in the given substate - self.get(substate, overwrite=True) + if not opts.get('dry_run'): + self.get(substate, overwrite=True) def filerevert(self, *pats, **opts): ctx = self._repo[opts['rev']] @@ -1693,7 +1694,8 @@ util.rename(os.path.join(self._abspath, name), os.path.join(self._abspath, bakname)) - self.get(substate, overwrite=True) + if not opts.get('dry_run'): + self.get(substate, overwrite=True) return [] def shortid(self, revid): diff -r 79c2c29c71ae -r afed5d2e7985 tests/test-subrepo.t --- a/tests/test-subrepo.t Sat Feb 07 19:40:02 2015 -0500 +++ b/tests/test-subrepo.t Sat Feb 07 21:47:28 2015 -0500 @@ -50,9 +50,16 @@ Revert subrepo and test subrepo fileset keyword: $ echo b > s/a + $ hg revert --dry-run "set:subrepo('glob:s*')" + reverting subrepo s + reverting s/a (glob) + $ cat s/a + b $ hg revert "set:subrepo('glob:s*')" reverting subrepo s reverting s/a (glob) + $ cat s/a + a $ rm s/a.orig Revert subrepo with no backup. The "reverting s/a" line is gone since