hgext/rebase.py
branchstable
changeset 44801 1f114c797961
parent 44668 e7af56a0733e
child 44995 78cafd48b9b2
equal deleted inserted replaced
44800:9f3aa0d3de41 44801:1f114c797961
   365         skippedset = set(self.obsoletenotrebased)
   365         skippedset = set(self.obsoletenotrebased)
   366         skippedset.update(self.obsoletewithoutsuccessorindestination)
   366         skippedset.update(self.obsoletewithoutsuccessorindestination)
   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()
   374             self.collapsemsg = restorecollapsemsg(self.repo, isabort)
   376             self.collapsemsg = restorecollapsemsg(self.repo, isabort)
   375         except error.RepoLookupError:
   377         except error.RepoLookupError:
   388                 hint = _(b'use "hg rebase --abort" to clear broken state')
   390                 hint = _(b'use "hg rebase --abort" to clear broken state')
   389                 raise error.Abort(msg, hint=hint)
   391                 raise error.Abort(msg, hint=hint)
   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:
   397             return _nothingtorebase()
   404             return _nothingtorebase()
   398 
   405 
   747             and self.activebookmark in repo._bookmarks
   754             and self.activebookmark in repo._bookmarks
   748             and repo[b'.'].node() == repo._bookmarks[self.activebookmark]
   755             and repo[b'.'].node() == repo._bookmarks[self.activebookmark]
   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
   756         try:
   763         try:
   757             # If the first commits in the rebased set get skipped during the
   764             # If the first commits in the rebased set get skipped during the
   791                         c.node() for c in repo.set(b'roots(%ld)', rebased)
   798                         c.node() for c in repo.set(b'roots(%ld)', rebased)
   792                     ]
   799                     ]
   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
   800                 if shouldupdate:
   810                 if shouldupdate:
   801                     mergemod.clean_update(repo[self.originalwd])
   811                     mergemod.clean_update(repo[self.originalwd])
  1117                 if not ui.promptchoice(_(b'apply changes (yn)?$$ &Yes $$ &No')):
  1127                 if not ui.promptchoice(_(b'apply changes (yn)?$$ &Yes $$ &No')):
  1118                     # finish unfinished rebase
  1128                     # finish unfinished rebase
  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:
  1126                 ui.status(
  1139                 ui.status(
  1127                     _(
  1140                     _(
  1132             return 0
  1145             return 0
  1133         finally:
  1146         finally:
  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 
  1141 def _dorebase(ui, repo, action, opts, inmemory=False):
  1157 def _dorebase(ui, repo, action, opts, inmemory=False):
  1142     rbsrt = rebaseruntime(repo, ui, inmemory, opts)
  1158     rbsrt = rebaseruntime(repo, ui, inmemory, opts)