error: move ParseError
authorMatt Mackall <mpm@selenic.com>
Sun, 11 Jan 2009 23:04:24 -0600
changeset 7636 e3f8c6d6b72e
parent 7635 d22c43724745
child 7637 1d54e2f6c0b7
error: move ParseError
hgext/rebase.py
mercurial/dispatch.py
mercurial/error.py
--- a/hgext/rebase.py	Sun Jan 11 23:00:09 2009 -0600
+++ b/hgext/rebase.py	Sun Jan 11 23:04:24 2009 -0600
@@ -13,7 +13,7 @@
 http://www.selenic.com/mercurial/wiki/index.cgi/RebaseProject
 '''
 
-from mercurial import util, repair, merge, cmdutil, dispatch, commands
+from mercurial import util, repair, merge, cmdutil, commands, error
 from mercurial import extensions, ancestor
 from mercurial.commands import templateopts
 from mercurial.node import nullrev
@@ -67,21 +67,21 @@
         extrafn = opts.get('extrafn')
         if opts.get('keepbranches', None):
             if extrafn:
-                raise dispatch.ParseError('rebase',
-                        _('cannot use both keepbranches and extrafn'))
+                raise error.ParseError(
+                    'rebase', _('cannot use both keepbranches and extrafn'))
             def extrafn(ctx, extra):
                 extra['branch'] = ctx.branch()
 
         if contf or abortf:
             if contf and abortf:
-                raise dispatch.ParseError('rebase',
-                                    _('cannot use both abort and continue'))
+                raise error.ParseError('rebase',
+                                       _('cannot use both abort and continue'))
             if collapsef:
-                raise dispatch.ParseError('rebase',
-                        _('cannot use collapse with continue or abort'))
+                raise error.ParseError(
+                    'rebase', _('cannot use collapse with continue or abort'))
 
             if (srcf or basef or destf):
-                raise dispatch.ParseError('rebase',
+                raise error.ParseError('rebase',
                     _('abort and continue do not allow specifying revisions'))
 
             originalwd, target, state, collapsef, external = restorestatus(repo)
@@ -90,8 +90,8 @@
                 return
         else:
             if srcf and basef:
-                raise dispatch.ParseError('rebase', _('cannot specify both a '
-                                                        'revision and a base'))
+                raise error.ParseError('rebase', _('cannot specify both a '
+                                                   'revision and a base'))
             cmdutil.bail_if_changed(repo)
             result = buildstate(repo, destf, srcf, basef, collapsef)
             if result:
--- a/mercurial/dispatch.py	Sun Jan 11 23:00:09 2009 -0600
+++ b/mercurial/dispatch.py	Sun Jan 11 23:04:24 2009 -0600
@@ -12,9 +12,6 @@
 import cmdutil
 import ui as _ui
 
-class ParseError(Exception):
-    """Exception raised on errors in parsing the command line."""
-
 def run():
     "run the command in sys.argv"
     sys.exit(dispatch(sys.argv[1:]))
@@ -52,7 +49,7 @@
             ui.print_exc()
             raise
 
-    except ParseError, inst:
+    except error.ParseError, inst:
         if inst.args[0]:
             ui.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1]))
             commands.help_(ui, inst.args[0])
@@ -167,7 +164,7 @@
     try:
         args = fancyopts.fancyopts(args, commands.globalopts, options)
     except fancyopts.getopt.GetoptError, inst:
-        raise ParseError(None, inst)
+        raise error.ParseError(None, inst)
 
     if args:
         cmd, args = args[0], args[1:]
@@ -189,7 +186,7 @@
     try:
         args = fancyopts.fancyopts(args, c, cmdoptions)
     except fancyopts.getopt.GetoptError, inst:
-        raise ParseError(cmd, inst)
+        raise error.ParseError(cmd, inst)
 
     # separate global options back out
     for o in commands.globalopts:
@@ -375,7 +372,7 @@
         try:
             return cmdfunc()
         except util.SignatureError:
-            raise ParseError(cmd, _("invalid arguments"))
+            raise error.ParseError(cmd, _("invalid arguments"))
 
     if options['profile']:
         import hotshot, hotshot.stats
--- a/mercurial/error.py	Sun Jan 11 23:00:09 2009 -0600
+++ b/mercurial/error.py	Sun Jan 11 23:04:24 2009 -0600
@@ -24,3 +24,6 @@
 
     def __str__(self):
         return RevlogError.__str__(self)
+
+class ParseError(Exception):
+    """Exception raised on errors in parsing the command line."""