[PATCH RFC] windows: expand environment variables in executable paths

Steve Borho steve at borho.org
Fri Dec 25 23:09:08 CST 2009


On Fri, Dec 25, 2009 at 10:54 PM, Steve Borho <steve at borho.org> wrote:
> # HG changeset patch
> # User Steve Borho <steve at borho.org>
> # Date 1261803168 21600
> # Node ID 722494135628f58e19407d92c0d57ba96ce4341e
> # Parent  27457d31ae3f3b466edb784fe0ea0a14a917f812
> windows: expand environment variables in executable paths
>
> This is mainly intended for use in filemerge when searching for merge tools.
> The problem is that on Windows the "Program Files" directory is localized and
> thus we cannot ship robust mergetools.hgrc configurations for any apps that
> install themselves under "Program Files" and do not set helpful registry keys.
> This patch allows us to use ${ProgramFiles} in the tool.executable setting.
>
> diff --git a/mercurial/windows.py b/mercurial/windows.py
> --- a/mercurial/windows.py
> +++ b/mercurial/windows.py
> @@ -203,6 +203,10 @@
>         executable = findexisting(os.path.join(path, command))
>         if executable is not None:
>             return executable
> +    # Try expanding environment variables, eg: ${ProgramFiles}
> +    executable = findexisting(util.expandpath(command))
> +    if executable is not None:
> +        return executable
>     return None
>
>  def set_signal_handler():
>

Looking at this again, the last three lines are redundant.  It could
just return the results of the last findexisting().  But I'm mainly
interested in feedback about whether there is a better way to resolve
this problem.

--
Steve Borho


More information about the Mercurial-devel mailing list