hgext/rebase.py
changeset 29472 f585ce6878e3
parent 29404 591a8069b60e
child 29473 e25da98052a4
--- a/hgext/rebase.py	Thu Jun 30 18:59:53 2016 -0700
+++ b/hgext/rebase.py	Fri Jul 01 14:09:53 2016 +0200
@@ -227,6 +227,37 @@
         self.external = external
         self.activebookmark = activebookmark
 
+    def _prepareabortorcontinue(self, isabort):
+        try:
+            self.restorestatus()
+            self.collapsemsg = restorecollapsemsg(self.repo)
+        except error.RepoLookupError:
+            if isabort:
+                clearstatus(self.repo)
+                clearcollapsemsg(self.repo)
+                self.repo.ui.warn(_('rebase aborted (no revision is removed,'
+                                    ' only broken state is cleared)\n'))
+                return 0
+            else:
+                msg = _('cannot continue inconsistent rebase')
+                hint = _('use "hg rebase --abort" to clear broken state')
+                raise error.Abort(msg, hint=hint)
+        if isabort:
+            return abort(self.repo, self.originalwd, self.target,
+                         self.state, activebookmark=self.activebookmark)
+
+        self.obsoletenotrebased = {}
+        if self.ui.configbool('experimental', 'rebaseskipobsolete',
+                              default=True):
+            rebaseobsrevs = set([r for r, st in self.state.items()
+                                    if st == revprecursor])
+            rebasesetrevs = set(self.state.keys())
+            self.obsoletenotrebased = _computeobsoletenotrebased(self.repo,
+                                            rebaseobsrevs, self.target)
+            rebaseobsskipped = set(self.obsoletenotrebased)
+            _checkobsrebase(self.repo, self.ui, rebaseobsrevs, rebasesetrevs,
+                            rebaseobsskipped)
+
 @command('rebase',
     [('s', 'source', '',
      _('rebase the specified changeset and descendants'), _('REV')),
@@ -381,36 +412,9 @@
             if abortf and opts.get('tool', False):
                 ui.warn(_('tool option will be ignored\n'))
 
-            try:
-                rbsrt.restorestatus()
-                rbsrt.collapsemsg = restorecollapsemsg(repo)
-            except error.RepoLookupError:
-                if abortf:
-                    clearstatus(repo)
-                    clearcollapsemsg(repo)
-                    repo.ui.warn(_('rebase aborted (no revision is removed,'
-                                   ' only broken state is cleared)\n'))
-                    return 0
-                else:
-                    msg = _('cannot continue inconsistent rebase')
-                    hint = _('use "hg rebase --abort" to clear broken state')
-                    raise error.Abort(msg, hint=hint)
-            if abortf:
-                return abort(repo, rbsrt.originalwd, rbsrt.target,
-                             rbsrt.state,
-                             activebookmark=rbsrt.activebookmark)
-
-            rbsrt.obsoletenotrebased = {}
-            if ui.configbool('experimental', 'rebaseskipobsolete',
-                             default=True):
-                rebaseobsrevs = set([r for r, st in rbsrt.state.items()
-                                     if st == revprecursor])
-                rebasesetrevs = set(rbsrt.state.keys())
-                rbsrt.obsoletenotrebased = _computeobsoletenotrebased(repo,
-                                                rebaseobsrevs, rbsrt.target)
-                rebaseobsskipped = set(rbsrt.obsoletenotrebased)
-                _checkobsrebase(repo, ui, rebaseobsrevs, rebasesetrevs,
-                                rebaseobsskipped)
+            retcode = rbsrt._prepareabortorcontinue(abortf)
+            if retcode is not None:
+                return retcode
         else:
             dest, rebaseset = _definesets(ui, repo, destf, srcf, basef, revf,
                                           destspace=destspace)