[PATCH DEFAULT] util: fix finding of hgexecutable

Simon Heimberg simohe at besonet.ch
Wed Sep 14 10:01:24 CDT 2011


# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1311394698 -7200
# Node ID 7a558a75eea73b63d017ba9af1f810d352a35560
# Parent  2ca855126091fb099f3534e32258e9f04e9e7169
util: fix finding of hgexecutable

The version introduced in 89d9f92f6fdd would for example return thg
(thanks to Mads Kiilerich for pointing to this)

diff -r 2ca855126091 -r 7a558a75eea7 mercurial/util.py
--- a/mercurial/util.py	Mit Sep 14 13:57:56 2011 +0200
+++ b/mercurial/util.py	Sam Jul 23 06:18:18 2011 +0200
@@ -370,12 +370,13 @@
     """
     if _hgexecutable is None:
         hg = os.environ.get('HG')
+        mainmod = sys.modules['__main__']
         if hg:
             _sethgexecutable(hg)
         elif mainfrozen():
             _sethgexecutable(sys.executable)
-        elif getattr(sys.modules['__main__'], '__file__', '').endswith('hg'):
-            _sethgexecutable(sys.modules['__main__'].__file__)
+        elif os.path.basepath(getattr(mainmod, '__file__', '')) == 'hg':
+            _sethgexecutable(mainmod.__file__)
         else:
             exe = findexe('hg') or os.path.basename(sys.argv[0])
             _sethgexecutable(exe)


More information about the Mercurial-devel mailing list