Merge with crew
authorBrendan Cully <brendan@kublai.com>
Sat, 04 Aug 2007 18:04:35 -0700
changeset 5115 5023af9fcba4
parent 5114 35f67dd712d0 (current diff)
parent 5113 d5126a0172ba (diff)
child 5116 35d47b06d4e3
Merge with crew
--- a/hgext/convert/common.py	Sat Aug 04 18:02:37 2007 -0700
+++ b/hgext/convert/common.py	Sat Aug 04 18:04:35 2007 -0700
@@ -5,8 +5,6 @@
 class commit(object):
     def __init__(self, author, date, desc, parents, branch=None, rev=None,
                  copies={}):
-        self.rev = None
-        self.branch = None
         self.author = author
         self.date = date
         self.desc = desc
--- a/mercurial/cmdutil.py	Sat Aug 04 18:02:37 2007 -0700
+++ b/mercurial/cmdutil.py	Sat Aug 04 18:04:35 2007 -0700
@@ -21,7 +21,7 @@
 class ParseError(Exception):
     """Exception raised on errors in parsing the command line."""
 
-def runcatch(ui, args, argv0=None):
+def runcatch(ui, args):
     def catchterm(*args):
         raise util.SignalInterrupt
 
@@ -35,7 +35,7 @@
             if '--debugger' in args:
                 pdb.set_trace()
             try:
-                return dispatch(ui, args, argv0=argv0)
+                return dispatch(ui, args)
             finally:
                 ui.flush()
         except:
@@ -277,10 +277,7 @@
             pos += 1
     return values
 
-def dispatch(ui, args, argv0=None):
-    # remember how to call 'hg' before changing the working dir
-    util.set_hgexecutable(argv0)
-
+def dispatch(ui, args):
     # read --config before doing anything else
     # (e.g. to change trust settings for reading .hg/hgrc)
     config = earlygetopt(['--config'], args)
--- a/mercurial/commands.py	Sat Aug 04 18:02:37 2007 -0700
+++ b/mercurial/commands.py	Sat Aug 04 18:04:35 2007 -0700
@@ -3129,13 +3129,13 @@
           " debugindex debugindexdot debugdate debuginstall")
 optionalrepo = ("paths serve showconfig")
 
-def dispatch(args, argv0=None):
+def dispatch(args):
     try:
         u = ui.ui(traceback='--traceback' in args)
     except util.Abort, inst:
         sys.stderr.write(_("abort: %s\n") % inst)
         return -1
-    return cmdutil.runcatch(u, args, argv0=argv0)
+    return cmdutil.runcatch(u, args)
 
 def run():
-    sys.exit(dispatch(sys.argv[1:], argv0=sys.argv[0]))
+    sys.exit(dispatch(sys.argv[1:]))
--- a/mercurial/help.py	Sat Aug 04 18:02:37 2007 -0700
+++ b/mercurial/help.py	Sat Aug 04 18:04:35 2007 -0700
@@ -38,9 +38,9 @@
     'environment|env|Environment Variables':
     r'''
 HG::
-    Path to the 'hg' executable, automatically passed when running hooks
-    or external tools. Falls back to 'hg' if unset and the value can't be
-    autodetected, e.g. when Mercurial is run as a Python module.
+    Path to the 'hg' executable, automatically passed when running hooks,
+    extensions or external tools. If unset or empty, an executable named
+    'hg' (with com/exe/bat/cmd extension on Windows) is searched.
 
 HGEDITOR::
     This is the name of the editor to use when committing. Defaults to the
--- a/mercurial/util.py	Sat Aug 04 18:02:37 2007 -0700
+++ b/mercurial/util.py	Sat Aug 04 18:04:35 2007 -0700
@@ -540,17 +540,21 @@
 
     return (roots, match, (inc or exc or anypats) and True)
 
-_hgexecutable = 'hg'
+_hgexecutable = None
+
+def hgexecutable():
+    """return location of the 'hg' executable.
+
+    Defaults to $HG or 'hg' in the search path.
+    """
+    if _hgexecutable is None:
+        set_hgexecutable(os.environ.get('HG') or find_exe('hg', 'hg'))
+    return _hgexecutable
 
 def set_hgexecutable(path):
-    """remember location of the 'hg' executable if easily possible
-
-    path might be None or empty if hg was loaded as a module,
-    fall back to 'hg' in this case.
-    """
+    """set location of the 'hg' executable"""
     global _hgexecutable
-    if path:
-        _hgexecutable = os.path.abspath(path)
+    _hgexecutable = path
 
 def system(cmd, environ={}, cwd=None, onerr=None, errprefix=None):
     '''enhanced shell command execution.
@@ -577,8 +581,7 @@
     try:
         for k, v in environ.iteritems():
             os.environ[k] = py2shell(v)
-        if 'HG' not in os.environ:
-            os.environ['HG'] = _hgexecutable
+        os.environ['HG'] = hgexecutable()
         if cwd is not None and oldcwd != cwd:
             os.chdir(cwd)
         rc = os.system(cmd)