diff -r 7e9a15fa6c8f -r 5751631246de mercurial/util.py --- a/mercurial/util.py Tue Nov 18 15:35:34 2008 -0600 +++ b/mercurial/util.py Tue Nov 18 16:02:14 2008 -0600 @@ -13,7 +13,7 @@ """ from i18n import _ -import cStringIO, errno, getpass, re, shutil, sys, tempfile +import cStringIO, errno, getpass, re, shutil, sys, tempfile, traceback import os, stat, threading, time, calendar, ConfigParser, locale, glob, osutil import imp @@ -671,6 +671,21 @@ if cwd is not None and oldcwd != cwd: os.chdir(oldcwd) +class SignatureError: + pass + +def checksignature(func): + '''wrap a function with code to check for calling errors''' + def check(*args, **kwargs): + try: + return func(*args, **kwargs) + except TypeError: + if len(traceback.extract_tb(sys.exc_info()[2])) == 1: + raise SignatureError + raise + + return check + # os.path.lexists is not available on python2.3 def lexists(filename): "test whether a file with this name exists. does not follow symlinks"