Commits

Brodie Rao  committed 9667da9

Canonicalize paths and expand paths consistently (fixes #2)

Based on a patch by Christophe Furmaniak.

  • Participants
  • Parent commits 4963c2e

Comments (0)

Files changed (1)

File reposettings.py

 import os
 import shlex
 
+from mercurial import util
+
 base = None
 repos = {}
 
 def handleconfig(ui, fn):
 
-    root = os.path.normpath(fn)
+    root = os.path.realpath(fn)
     if not root.endswith(os.path.join('.hg', 'hgrc')):
         return
     root = os.path.dirname(os.path.dirname(root))
     if base is None:
         base = ui.config('reposettings', 'base', '')
         if base:
-            base = os.path.expanduser(os.path.normpath(base))
+            base = os.path.realpath(util.expandpath(base))
             if base and not os.path.isdir(base):
                 ui.warn("reposettings.base path %r doesn't exist\n" % base)
 
                     ui.setconfig(parts[0] + ' (global)', name, value)
                 else:
                     for part in parts[1:]:
-                        part = os.path.normpath(part)
                         if base:
-                            path = os.path.join(base, part.lstrip(os.path.sep))
+                            part = os.path.expandvars(part.lstrip(os.path.sep))
+                            path = os.path.join(base, part)
                         else:
-                            path = os.path.expanduser(part)
+                            path = util.expandpath(part)
+                        path = os.path.realpath(path)
                         if path not in repos:
                             repos[path] = {}
                         if parts[0] not in repos[path]: