[PATCH] util.hgexecutable: if $HG isnt set and 'hg' isnt in local path, use sys.argv[0]

Martin Geisler mg at lazybytes.net
Thu Oct 22 20:03:15 UTC 2009


Nicolas Dumazet <nicdumz at gmail.com> writes:

> # HG changeset patch
> # User Nicolas Dumazet <nicdumz.commits at gmail.com>
> # Date 1253553692 -7200
> # Node ID e813087ec5ee252be123ca87dd75bdbe9378bb7c
> # Parent  bccf780f78ed7cab3fac47bfac68fdd56a059ba7
> util.hgexecutable: if $HG isnt set and 'hg' isnt in local path, use sys.argv[0]
>
> Useful 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'
>
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -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

I just took a look at this again together with this changeset:

  http://selenic.com/hg/rev/3d35c8cb5eb4

which solved this issue:

  http://mercurial.selenic.com/bts/issue644

After reading those pages, I think the change is good since they're
mostly concerned about the two first cases of the if-statement. The
patch has a good effect on my system: I renamed 'hg' to 'hgx' and could
only run 'hgx view' after applying your patch.

So it's in crew as revision 16698d87ad20.

-- 
Martin Geisler

VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-devel/attachments/20091022/b88516c0/attachment.asc>


More information about the Mercurial-devel mailing list