mercurial/util.py
changeset 7646 e62a456b8dc5
parent 7644 182b7114d35a
child 7695 deec6628e62b
equal deleted inserted replaced
7645:020a896a5292 7646:e62a456b8dc5
    11 This contains helper routines that are independent of the SCM core and hide
    11 This contains helper routines that are independent of the SCM core and hide
    12 platform-specific details from the core.
    12 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, traceback
    16 import cStringIO, errno, getpass, re, shutil, sys, tempfile, traceback, error
    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 
    20 # Python compatibility
    20 # Python compatibility
    21 
    21 
   705             else:
   705             else:
   706                 os.environ[k] = v
   706                 os.environ[k] = v
   707         if cwd is not None and oldcwd != cwd:
   707         if cwd is not None and oldcwd != cwd:
   708             os.chdir(oldcwd)
   708             os.chdir(oldcwd)
   709 
   709 
   710 class SignatureError(Exception):
       
   711     pass
       
   712 
       
   713 def checksignature(func):
   710 def checksignature(func):
   714     '''wrap a function with code to check for calling errors'''
   711     '''wrap a function with code to check for calling errors'''
   715     def check(*args, **kwargs):
   712     def check(*args, **kwargs):
   716         try:
   713         try:
   717             return func(*args, **kwargs)
   714             return func(*args, **kwargs)
   718         except TypeError:
   715         except TypeError:
   719             if len(traceback.extract_tb(sys.exc_info()[2])) == 1:
   716             if len(traceback.extract_tb(sys.exc_info()[2])) == 1:
   720                 raise SignatureError
   717                 raise error.SignatureError
   721             raise
   718             raise
   722 
   719 
   723     return check
   720     return check
   724 
   721 
   725 # os.path.lexists is not available on python2.3
   722 # os.path.lexists is not available on python2.3