[Request] [+- ] D8489: rebase: avoid clobbering wdir() with --dry-run or --confirm (issue6291)

mharbison72 (Matt Harbison) phabricator at mercurial-scm.org
Thu Apr 30 05:22:10 UTC 2020


mharbison72 created this revision.
Herald added a reviewer: martinvonz.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  See 56d3e0b499df <https://phab.mercurial-scm.org/rHG56d3e0b499dff1d4155aff66b3dca63a60252a4f> 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.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D8489

AFFECTED FILES
  hgext/rebase.py
  tests/test-rebase-named-branches.t

CHANGE DETAILS

diff --git a/tests/test-rebase-named-branches.t b/tests/test-rebase-named-branches.t
--- a/tests/test-rebase-named-branches.t
+++ b/tests/test-rebase-named-branches.t
@@ -339,15 +339,23 @@
   -A
   +A-mod
 
-BUG: This shouldn't affect wdir
+--dry-run doesn't affect a dirty working directory that is unrelated to the
+source or destination.
 
   $ hg rebase -s tip -d 4 --dry-run
   starting dry-run rebase; repository will not be changed
   rebasing 11:be1dea60f2a6 "D" (tip)
   dry-run rebase completed successfully; run without -n/--dry-run to perform this rebase
   $ hg diff
+  diff -r 2b586e70108d A
+  --- a/A	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/A	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +1,1 @@
+  -A
+  +A-mod
 
-BUG: This shouldn't affect wdir
+Bailing out on --confirm doesn't affect a dirty working directory that is
+unrelated to the source or destination.
 
   $ echo A-mod > A
   $ echo n | hg rebase -s tip -d 4 --confirm --config ui.interactive=True
@@ -356,6 +364,12 @@
   rebase completed successfully
   apply changes (yn)? n
   $ hg diff
+  diff -r 2b586e70108d A
+  --- a/A	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/A	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +1,1 @@
+  -A
+  +A-mod
 
   $ echo A-mod > A
   $ hg rebase -s tip -d 4 --confirm
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -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'),
                 )
 
 



To: mharbison72, martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20200430/48212e61/attachment-0001.html>


More information about the Mercurial-patches mailing list