# HG changeset patch # User Matt Harbison # Date 2015-02-08 02:47:28 # 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 --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2783,14 +2783,14 @@ def revert(ui, repo, ctx, parents, *pats _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 --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -884,7 +884,8 @@ class hgsubrepo(abstractsubrepo): 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 @@ class gitsubrepo(abstractsubrepo): 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 --git a/tests/test-subrepo.t b/tests/test-subrepo.t --- a/tests/test-subrepo.t +++ b/tests/test-subrepo.t @@ -50,9 +50,16 @@ test handling .hgsubstate "added" explic 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