util: use sys.argv[0] if $HG is unset and 'hg' is not in PATH
authorNicolas Dumazet <nicdumz.commits@gmail.com>
Mon, 21 Sep 2009 19:21:32 +0200
changeset 9632 16698d87ad20
parent 9631 1c34fca5d785
child 9633 82a4c54d51e1
child 9652 2cb0cab10d2e
child 9763 e06c940d554d
util: use sys.argv[0] if $HG is unset and 'hg' is not in PATH This is necessary when the executable name is not 'hg'. For example, if your system-wide mercurial is name 'hgs', sys.argv[0] is more accurate than 'hg'.
mercurial/util.py
--- a/mercurial/util.py	Wed Oct 21 14:16:37 2009 +0200
+++ b/mercurial/util.py	Mon Sep 21 19:21:32 2009 +0200
@@ -335,7 +335,8 @@
         elif main_is_frozen():
             set_hgexecutable(sys.executable)
         else:
-            set_hgexecutable(find_exe('hg') or 'hg')
+            exe = find_exe('hg') or os.path.basename(sys.argv[0])
+            set_hgexecutable(exe)
     return _hgexecutable
 
 def set_hgexecutable(path):