Mercurial > public > mercurial-scm > hg
diff hgext/rebase.py @ 44923:1f114c797961 stable
rebase: avoid clobbering wdir() with --dry-run or --confirm (issue6291)
See 56d3e0b499df for the source of adding originalwd to the list of things that
cause wdir to be updated. That change didn't come with tests, and attempts to
recreate the scenario described have thus far failed.
Differential Revision: https://phab.mercurial-scm.org/D8489
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 30 Apr 2020 00:33:00 -0400 |
parents | e7af56a0733e |
children | 78cafd48b9b2 |
line wrap: on
line diff
--- a/hgext/rebase.py Thu Apr 30 00:12:11 2020 -0400 +++ b/hgext/rebase.py Thu Apr 30 00:33:00 2020 -0400 @@ -367,7 +367,9 @@ skippedset.update(obsoleteextinctsuccessors) _checkobsrebase(self.repo, self.ui, obsoleteset, skippedset) - def _prepareabortorcontinue(self, isabort, backup=True, suppwarns=False): + def _prepareabortorcontinue( + self, isabort, backup=True, suppwarns=False, dryrun=False, confirm=False + ): self.resume = True try: self.restorestatus() @@ -390,7 +392,12 @@ if isabort: backup = backup and self.backupf - return self._abort(backup=backup, suppwarns=suppwarns) + return self._abort( + backup=backup, + suppwarns=suppwarns, + dryrun=dryrun, + confirm=confirm, + ) def _preparenewrebase(self, destmap): if not destmap: @@ -749,7 +756,7 @@ ): bookmarks.activate(repo, self.activebookmark) - def _abort(self, backup=True, suppwarns=False): + def _abort(self, backup=True, suppwarns=False, dryrun=False, confirm=False): '''Restore the repository to its original state.''' repo = self.repo @@ -793,7 +800,10 @@ updateifonnodes = set(rebased) updateifonnodes.update(self.destmap.values()) - updateifonnodes.add(self.originalwd) + + if not dryrun and not confirm: + updateifonnodes.add(self.originalwd) + shouldupdate = repo[b'.'].rev() in updateifonnodes # Update away from the rebase if necessary @@ -1119,7 +1129,10 @@ rbsrt._finishrebase() else: rbsrt._prepareabortorcontinue( - isabort=True, backup=False, suppwarns=True + isabort=True, + backup=False, + suppwarns=True, + confirm=confirm, ) needsabort = False else: @@ -1134,7 +1147,10 @@ if needsabort: # no need to store backup in case of dryrun rbsrt._prepareabortorcontinue( - isabort=True, backup=False, suppwarns=True + isabort=True, + backup=False, + suppwarns=True, + dryrun=opts.get(b'dry_run'), )