util: improve finding of hgexecutable
authorSimon Heimberg <simohe@besonet.ch>
Sat, 23 Jul 2011 06:18:18 +0200
changeset 15076 89d9f92f6fdd
parent 15072 91d2efecb245
child 15078 193e7018dc8c
util: improve finding of hgexecutable check the module __main__ before looking on the default path
mercurial/util.py
--- a/mercurial/util.py	Thu Sep 08 18:30:44 2011 -0500
+++ b/mercurial/util.py	Sat Jul 23 06:18:18 2011 +0200
@@ -374,6 +374,8 @@
             _sethgexecutable(hg)
         elif mainfrozen():
             _sethgexecutable(sys.executable)
+        elif getattr(sys.modules['__main__'], '__file__', '').endswith('hg'):
+            _sethgexecutable(sys.modules['__main__'].__file__)
         else:
             exe = findexe('hg') or os.path.basename(sys.argv[0])
             _sethgexecutable(exe)