[PATCH RFC] util: set $HG var correctly for shell aliases (issue2867)
Idan Kamara
idankk86 at gmail.com
Wed Jun 29 09:42:42 CDT 2011
# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1309358034 -10800
# Branch stable
# Node ID c64c8a0911544a924df2419882c39d447a2b630b
# Parent 6ac6a32ac1605176befb7c4fdbe90ba952c59207
util: set $HG var correctly for shell aliases (issue2867)
The old version took the first 'hg' it found in $PATH, or simply the basename
of sys.argv[0]. This is a problem if the 'hg' being used is not the first in
$PATH. Also the use of basename on sys.argv[0] is inappropriate, because that
effectively strips it to 'hg'.
Instead we're always setting it to sys.argv[0].
diff -r 6ac6a32ac160 -r c64c8a091154 mercurial/util.py
--- a/mercurial/util.py Wed Jun 29 15:49:35 2011 +0300
+++ b/mercurial/util.py Wed Jun 29 17:33:54 2011 +0300
@@ -319,8 +319,7 @@
elif mainfrozen():
_sethgexecutable(sys.executable)
else:
- exe = findexe('hg') or os.path.basename(sys.argv[0])
- _sethgexecutable(exe)
+ _sethgexecutable(sys.argv[0])
return _hgexecutable
def _sethgexecutable(path):
diff -r 6ac6a32ac160 -r c64c8a091154 tests/test-alias.t
--- a/tests/test-alias.t Wed Jun 29 15:49:35 2011 +0300
+++ b/tests/test-alias.t Wed Jun 29 17:33:54 2011 +0300
@@ -40,6 +40,7 @@
> escaped2 = !echo "HGFOO is \$\$HGFOO"
> escaped3 = !echo "\$1 is \$\$\$1"
> escaped4 = !echo '\$\$0' '\$\$@'
+ > echohg = !echo \$HG
>
> [defaults]
> mylog = -q
@@ -47,6 +48,13 @@
> log = -v
> EOF
+test $HG correctness
+
+ $ touch hg
+ $ realhg=`which hg`
+ $ envhg=`PATH=.:$PATH $realhg echohg`
+ $ test $envhg = $realhg
+ $ rm hg
basic
More information about the Mercurial-devel
mailing list