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

Steve Borho steve at borho.org
Fri Dec 25 22:54:33 CST 2009


# 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():


More information about the Mercurial-devel mailing list