Show More
@@ -7,7 +7,7 b'' | |||||
7 |
|
7 | |||
8 | from i18n import _ |
|
8 | from i18n import _ | |
9 | from repo import RepoError |
|
9 | from repo import RepoError | |
10 |
import os, sys, atexit, signal, pdb, |
|
10 | import os, sys, atexit, signal, pdb, socket, errno, shlex, time | |
11 | import util, commands, hg, lock, fancyopts, revlog, version, extensions, hook |
|
11 | import util, commands, hg, lock, fancyopts, revlog, version, extensions, hook | |
12 | import cmdutil |
|
12 | import cmdutil | |
13 | import ui as _ui |
|
13 | import ui as _ui | |
@@ -356,9 +356,9 b' def _dispatch(ui, args):' | |||||
356 | raise RepoError(_("There is no Mercurial repository here" |
|
356 | raise RepoError(_("There is no Mercurial repository here" | |
357 | " (.hg not found)")) |
|
357 | " (.hg not found)")) | |
358 | raise |
|
358 | raise | |
359 | d = lambda: func(ui, repo, *args, **cmdoptions) |
|
359 | args.insert(0, repo) | |
360 | else: |
|
360 | ||
361 |
|
|
361 | d = lambda: util.checksignature(func)(ui, *args, **cmdoptions) | |
362 |
|
362 | |||
363 | # run pre-hook, and abort if it fails |
|
363 | # run pre-hook, and abort if it fails | |
364 | ret = hook.hook(lui, repo, "pre-%s" % cmd, False, args=" ".join(fullargs)) |
|
364 | ret = hook.hook(lui, repo, "pre-%s" % cmd, False, args=" ".join(fullargs)) | |
@@ -374,11 +374,7 b' def _runcommand(ui, options, cmd, cmdfun' | |||||
374 | def checkargs(): |
|
374 | def checkargs(): | |
375 | try: |
|
375 | try: | |
376 | return cmdfunc() |
|
376 | return cmdfunc() | |
377 |
except |
|
377 | except util.SignatureError: | |
378 | # was this an argument error? |
|
|||
379 | tb = traceback.extract_tb(sys.exc_info()[2]) |
|
|||
380 | if len(tb) != 2: # no |
|
|||
381 | raise |
|
|||
382 | raise ParseError(cmd, _("invalid arguments")) |
|
378 | raise ParseError(cmd, _("invalid arguments")) | |
383 |
|
379 | |||
384 | if options['profile']: |
|
380 | if options['profile']: |
@@ -96,7 +96,8 b' def wrapcommand(table, command, wrapper)' | |||||
96 |
|
96 | |||
97 | origfn = entry[0] |
|
97 | origfn = entry[0] | |
98 | def wrap(*args, **kwargs): |
|
98 | def wrap(*args, **kwargs): | |
99 | return wrapper(origfn, *args, **kwargs) |
|
99 | return util.checksignature(wrapper)( | |
|
100 | util.checksignature(origfn), *args, **kwargs) | |||
100 |
|
101 | |||
101 | wrap.__doc__ = getattr(origfn, '__doc__') |
|
102 | wrap.__doc__ = getattr(origfn, '__doc__') | |
102 | wrap.__module__ = getattr(origfn, '__module__') |
|
103 | wrap.__module__ = getattr(origfn, '__module__') |
@@ -13,7 +13,7 b' platform-specific details from the core.' | |||||
13 | """ |
|
13 | """ | |
14 |
|
14 | |||
15 | from i18n import _ |
|
15 | from i18n import _ | |
16 | import cStringIO, errno, getpass, re, shutil, sys, tempfile |
|
16 | import cStringIO, errno, getpass, re, shutil, sys, tempfile, traceback | |
17 | import os, stat, threading, time, calendar, ConfigParser, locale, glob, osutil |
|
17 | import os, stat, threading, time, calendar, ConfigParser, locale, glob, osutil | |
18 | import imp |
|
18 | import imp | |
19 |
|
19 | |||
@@ -671,6 +671,21 b' def system(cmd, environ={}, cwd=None, on' | |||||
671 | if cwd is not None and oldcwd != cwd: |
|
671 | if cwd is not None and oldcwd != cwd: | |
672 | os.chdir(oldcwd) |
|
672 | os.chdir(oldcwd) | |
673 |
|
673 | |||
|
674 | class SignatureError: | |||
|
675 | pass | |||
|
676 | ||||
|
677 | def checksignature(func): | |||
|
678 | '''wrap a function with code to check for calling errors''' | |||
|
679 | def check(*args, **kwargs): | |||
|
680 | try: | |||
|
681 | return func(*args, **kwargs) | |||
|
682 | except TypeError: | |||
|
683 | if len(traceback.extract_tb(sys.exc_info()[2])) == 1: | |||
|
684 | raise SignatureError | |||
|
685 | raise | |||
|
686 | ||||
|
687 | return check | |||
|
688 | ||||
674 | # os.path.lexists is not available on python2.3 |
|
689 | # os.path.lexists is not available on python2.3 | |
675 | def lexists(filename): |
|
690 | def lexists(filename): | |
676 | "test whether a file with this name exists. does not follow symlinks" |
|
691 | "test whether a file with this name exists. does not follow symlinks" |
General Comments 0
You need to be logged in to leave comments.
Login now