[PATCH STABLE] setup/hg: handle hg being a symlink when appending relative libdir to sys.path

L. David Baron dbaron at dbaron.org
Thu Oct 21 12:00:56 CDT 2010


# HG changeset patch
# User L. David Baron <dbaron at dbaron.org>
# Date 1287680302 25200
# Node ID 172c5e2d8baff6b65d09c779d64ae199b23eb886
# Parent  6bf8d48bec8e1ab2e0462ce14a914d06e64f7117
setup/hg: handle hg being a symlink when appending relative libdir to sys.path

Resolve symbolic links in the path to hg so that an hg that works when
invoked directly will also work when invoked via a symlink to it.

diff --git a/hg b/hg
--- a/hg
+++ b/hg
@@ -9,17 +9,18 @@
 
 import os
 import sys
 
 libdir = '@LIBDIR@'
 
 if libdir != '@' 'LIBDIR' '@':
     if not os.path.isabs(libdir):
-        libdir = os.path.join(os.path.dirname(__file__), libdir)
+        libdir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
+                              libdir)
         libdir = os.path.abspath(libdir)
     sys.path.insert(0, libdir)
 
 # enable importing on demand to reduce startup time
 try:
     from mercurial import demandimport; demandimport.enable()
 except ImportError:
     import sys


More information about the Mercurial-devel mailing list