[PATCH 11 of 23 v3] rebase: introduce validateoptions method to the RRS class

Kostia Balytskyi ikostia at fb.com
Thu Jun 2 10:13:52 EDT 2016


# HG changeset patch
# User Kostia Balytskyi <ikostia at fb.com>
# Date 1464869417 -3600
#      Thu Jun 02 13:10:17 2016 +0100
# Node ID af65a1c2290b483eb643576ab1b7835fa1b3bc5b
# Parent  882dbd7618d2ff2d535a8863b44e1e69bc4c720d
rebase: introduce validateoptions method to the RRS class

This commit adds a method to perform command line options validation to the
RebaseRuntimeState class and moves the logic to suggest 'histedit' when user
wants an interactive rebase operation to that method.

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -164,6 +164,18 @@
         # other extensions
         self.keepopen = opts.get('keepopen', False)
 
+    def validateoptions(self):
+        if self.opts.get('interactive'):
+            try:
+                if extensions.find('histedit'):
+                    enablehistedit = ''
+            except KeyError:
+                enablehistedit = " --config extensions.histedit="
+            help = "hg%s help -e histedit" % enablehistedit
+            msg = _("interactive history editing is supported by the "
+                    "'histedit' extension (see \"%s\")") % help
+            raise error.Abort(msg)
+
 @command('rebase',
     [('s', 'source', '',
      _('rebase the specified changeset and descendants'), _('REV')),
@@ -275,23 +287,13 @@
 
     """
     rtstate = RebaseRuntimeState(repo, ui, opts)
+    rtstate.validateoptions()
 
     lock = wlock = None
     try:
         wlock = repo.wlock()
         lock = repo.lock()
 
-        if opts.get('interactive'):
-            try:
-                if extensions.find('histedit'):
-                    enablehistedit = ''
-            except KeyError:
-                enablehistedit = " --config extensions.histedit="
-            help = "hg%s help -e histedit" % enablehistedit
-            msg = _("interactive history editing is supported by the "
-                    "'histedit' extension (see \"%s\")") % help
-            raise error.Abort(msg)
-
         if rtstate.collapsemsg and not rtstate.collapsef:
             raise error.Abort(
                 _('message can only be specified with collapse'))


More information about the Mercurial-devel mailing list