<div dir="ltr">I'll try to fix things up as soon as I have some time. I'll probably have to write a custom find_executable function.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jan 6, 2014 at 3:37 AM, Matt Mackall <span dir="ltr"><<a href="mailto:mpm@selenic.com" target="_blank">mpm@selenic.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sun, 2014-01-05 at 16:47 +0530, Prasoon Shukla wrote:<br>
> This is a patch for issue 4141 <<a href="http://bz.selenic.com/show_bug.cgi?id=4141" target="_blank">http://bz.selenic.com/show_bug.cgi?id=4141</a>>.<br>
> *I couldn't add appropriate tests* because the tests require matching<br>
<div class="im">> multiple lines with a regex, which isn't supported. I tried Chris' idea (<br>
> <a href="http://mercurial.808500.n3.nabble.com/Problem-writing-test-td4006240.html" target="_blank">http://mercurial.808500.n3.nabble.com/Problem-writing-test-td4006240.html</a>)<br>
> of temporarily changing path for the command like so:<br>
> $ PATH=`which hg | xargs -n1 dirname`:`which hg | xargs -n1 dirname` hg<br>
> debuginstall<br>
> but that didn't work either. If someone has any idea for adding tests,<br>
> please do so.<br>
><br>
> # HG changeset patch<br>
> # User Prasoon Shukla <<a href="mailto:prasoon92.iitr@gmail.com">prasoon92.iitr@gmail.com</a>><br>
> # Date 1388919253 -19800<br>
> #      Sun Jan 05 16:24:13 2014 +0530<br>
> # Node ID 43b34adb25531fe26daa54bc53dbca63780953ef<br>
> # Parent  082b2930fe2ca9a003b08439524384e097acaa0a<br>
> debuginstall: display warning when multiple installs are present (issue4141)<br>
><br>
> If multiple installations of hg are present, a warning is displayed along<br>
> with all the installs.<br>
><br>
> diff -r 082b2930fe2c -r 43b34adb2553 mercurial/commands.py<br>
> --- a/mercurial/commands.py     Thu Jan 02 16:32:51 2014 -0600<br>
> +++ b/mercurial/commands.py     Sun Jan 05 16:24:13 2014 +0530<br>
> @@ -20,6 +20,7 @@<br>
>  import random<br>
>  import setdiscovery, treediscovery, dagutil, pvec, localrepo<br>
>  import phases, obsolete<br>
> +from distutils.spawn import find_executable<br>
<br>
</div>Please don't use this form of import. Not only does it pollute the<br>
namespace, it's messier for our demandimport system and thus slows<br>
down.. everything.<br>
<br>
Use the style the rest of the imports use.<br>
<div class="im"><br>
>  table = {}<br>
><br>
> @@ -2047,6 +2048,18 @@<br>
><br>
>      problems = 0<br>
><br>
> +    # installations<br>
> +    installs = []<br>
> +    pathlist = os.environ['PATH'].split(os.pathsep)<br>
> +    for path in pathlist:<br>
> +        exe = find_executable('hg', path)<br>
<br>
</div>What if the current executable is named something other than hg?<br>
<br>
I personally have about 80 copies of hg in my path.. one for each<br>
released version, with names like hg282.<br>
<div class="im"><br>
> +        if exe:<br>
> +            installs.append(exe)<br>
> +    ui.status(_("checking hg path (%s)...\n" % installs[0]))<br>
<br>
</div>What if the current running hg is NOT the first one in the path?<br>
<br>
What if there's nothing named 'hg' in the path?<br>
<div class="im"><br>
> +    if len(installs) > 1:<br>
> +        ui.warn(_("warning! multiple installs of hg detected:\n  %s...\n"<br>
> +                  % '\n  '.join(installs)))<br>
> +<br>
>      # encoding<br>
>      ui.status(_("checking encoding (%s)...\n") % encoding.encoding)<br>
>      try:<br>
</div>> _______________________________________________<br>
> Mercurial-devel mailing list<br>
> <a href="mailto:Mercurial-devel@selenic.com">Mercurial-devel@selenic.com</a><br>
> <a href="http://selenic.com/mailman/listinfo/mercurial-devel" target="_blank">http://selenic.com/mailman/listinfo/mercurial-devel</a><br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Mathematics is the supreme nostalgia of our time.<br>
<br>
<br>
</font></span></blockquote></div><br></div>