##// END OF EJS Templates
rebase: avoid clobbering wdir() with --dry-run or --confirm (issue6291)...
Matt Harbison -
r45458:1f114c79 stable
parent child Browse files
Show More
@@ -367,7 +367,9 b' class rebaseruntime(object):'
367 skippedset.update(obsoleteextinctsuccessors)
367 skippedset.update(obsoleteextinctsuccessors)
368 _checkobsrebase(self.repo, self.ui, obsoleteset, skippedset)
368 _checkobsrebase(self.repo, self.ui, obsoleteset, skippedset)
369
369
370 def _prepareabortorcontinue(self, isabort, backup=True, suppwarns=False):
370 def _prepareabortorcontinue(
371 self, isabort, backup=True, suppwarns=False, dryrun=False, confirm=False
372 ):
371 self.resume = True
373 self.resume = True
372 try:
374 try:
373 self.restorestatus()
375 self.restorestatus()
@@ -390,7 +392,12 b' class rebaseruntime(object):'
390
392
391 if isabort:
393 if isabort:
392 backup = backup and self.backupf
394 backup = backup and self.backupf
393 return self._abort(backup=backup, suppwarns=suppwarns)
395 return self._abort(
396 backup=backup,
397 suppwarns=suppwarns,
398 dryrun=dryrun,
399 confirm=confirm,
400 )
394
401
395 def _preparenewrebase(self, destmap):
402 def _preparenewrebase(self, destmap):
396 if not destmap:
403 if not destmap:
@@ -749,7 +756,7 b' class rebaseruntime(object):'
749 ):
756 ):
750 bookmarks.activate(repo, self.activebookmark)
757 bookmarks.activate(repo, self.activebookmark)
751
758
752 def _abort(self, backup=True, suppwarns=False):
759 def _abort(self, backup=True, suppwarns=False, dryrun=False, confirm=False):
753 '''Restore the repository to its original state.'''
760 '''Restore the repository to its original state.'''
754
761
755 repo = self.repo
762 repo = self.repo
@@ -793,7 +800,10 b' class rebaseruntime(object):'
793
800
794 updateifonnodes = set(rebased)
801 updateifonnodes = set(rebased)
795 updateifonnodes.update(self.destmap.values())
802 updateifonnodes.update(self.destmap.values())
796 updateifonnodes.add(self.originalwd)
803
804 if not dryrun and not confirm:
805 updateifonnodes.add(self.originalwd)
806
797 shouldupdate = repo[b'.'].rev() in updateifonnodes
807 shouldupdate = repo[b'.'].rev() in updateifonnodes
798
808
799 # Update away from the rebase if necessary
809 # Update away from the rebase if necessary
@@ -1119,7 +1129,10 b' def _dryrunrebase(ui, repo, action, opts'
1119 rbsrt._finishrebase()
1129 rbsrt._finishrebase()
1120 else:
1130 else:
1121 rbsrt._prepareabortorcontinue(
1131 rbsrt._prepareabortorcontinue(
1122 isabort=True, backup=False, suppwarns=True
1132 isabort=True,
1133 backup=False,
1134 suppwarns=True,
1135 confirm=confirm,
1123 )
1136 )
1124 needsabort = False
1137 needsabort = False
1125 else:
1138 else:
@@ -1134,7 +1147,10 b' def _dryrunrebase(ui, repo, action, opts'
1134 if needsabort:
1147 if needsabort:
1135 # no need to store backup in case of dryrun
1148 # no need to store backup in case of dryrun
1136 rbsrt._prepareabortorcontinue(
1149 rbsrt._prepareabortorcontinue(
1137 isabort=True, backup=False, suppwarns=True
1150 isabort=True,
1151 backup=False,
1152 suppwarns=True,
1153 dryrun=opts.get(b'dry_run'),
1138 )
1154 )
1139
1155
1140
1156
@@ -339,15 +339,23 b' Reopen branch by rebase'
339 -A
339 -A
340 +A-mod
340 +A-mod
341
341
342 BUG: This shouldn't affect wdir
342 --dry-run doesn't affect a dirty working directory that is unrelated to the
343 source or destination.
343
344
344 $ hg rebase -s tip -d 4 --dry-run
345 $ hg rebase -s tip -d 4 --dry-run
345 starting dry-run rebase; repository will not be changed
346 starting dry-run rebase; repository will not be changed
346 rebasing 11:be1dea60f2a6 "D" (tip)
347 rebasing 11:be1dea60f2a6 "D" (tip)
347 dry-run rebase completed successfully; run without -n/--dry-run to perform this rebase
348 dry-run rebase completed successfully; run without -n/--dry-run to perform this rebase
348 $ hg diff
349 $ hg diff
350 diff -r 2b586e70108d A
351 --- a/A Thu Jan 01 00:00:00 1970 +0000
352 +++ b/A Thu Jan 01 00:00:00 1970 +0000
353 @@ -1,1 +1,1 @@
354 -A
355 +A-mod
349
356
350 BUG: This shouldn't affect wdir
357 Bailing out on --confirm doesn't affect a dirty working directory that is
358 unrelated to the source or destination.
351
359
352 $ echo A-mod > A
360 $ echo A-mod > A
353 $ echo n | hg rebase -s tip -d 4 --confirm --config ui.interactive=True
361 $ echo n | hg rebase -s tip -d 4 --confirm --config ui.interactive=True
@@ -356,6 +364,12 b" BUG: This shouldn't affect wdir"
356 rebase completed successfully
364 rebase completed successfully
357 apply changes (yn)? n
365 apply changes (yn)? n
358 $ hg diff
366 $ hg diff
367 diff -r 2b586e70108d A
368 --- a/A Thu Jan 01 00:00:00 1970 +0000
369 +++ b/A Thu Jan 01 00:00:00 1970 +0000
370 @@ -1,1 +1,1 @@
371 -A
372 +A-mod
359
373
360 $ echo A-mod > A
374 $ echo A-mod > A
361 $ hg rebase -s tip -d 4 --confirm
375 $ hg rebase -s tip -d 4 --confirm
General Comments 0
You need to be logged in to leave comments. Login now