diff mercurial/util.py @ 15076:89d9f92f6fdd

util: improve finding of hgexecutable check the module __main__ before looking on the default path
author Simon Heimberg <simohe@besonet.ch>
date Sat, 23 Jul 2011 06:18:18 +0200
parents cc16323e748d
children d30ec2d16c5a
line wrap: on
line diff
--- 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)