changeset 15106:76cd1964519c

util: fix finding of hgexecutable The version introduced in 89d9f92f6fdd would for example return thg (thanks to Mads Kiilerich for pointing to this)
author Simon Heimberg <simohe@besonet.ch>
date Sat, 23 Jul 2011 06:18:18 +0200
parents 6e91fba485fa
children 2433525a9e1e
files mercurial/util.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Fri Sep 16 14:37:57 2011 -0500
+++ b/mercurial/util.py	Sat 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.basename(getattr(mainmod, '__file__', '')) == 'hg':
+            _sethgexecutable(mainmod.__file__)
         else:
             exe = findexe('hg') or os.path.basename(sys.argv[0])
             _sethgexecutable(exe)