[PATCH] Ensure that absolutized paths from hgrc do not contain ../ segments

Jesse Glick Jesse.Glick at Sun.COM
Tue Jan 8 21:42:25 CST 2008


# HG changeset patch
# User Jesse Glick <jesse.glick at sun.com>
# Date 1199850051 18000
# Node ID 55b27a8ac16b2b568f541f397bb8423229fa92b9
# Parent  5379497af641f87170c1eff2d0bb2a7df2189908
Ensure that absolutized paths from hgrc do not contain ../ segments.

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -204,7 +204,8 @@ class ui(object):
                     pathsitems = items
                 for n, path in pathsitems:
                     if path and "://" not in path and not os.path.isabs(path):
-                        cdata.set("paths", n, os.path.join(root, path))
+                        cdata.set("paths", n,
+                                  os.path.normpath(os.path.join(root, path)))
 
         # update verbosity/interactive/report_untrusted settings
         if section is None or section == 'ui':
diff --git a/tests/test-keyword.out b/tests/test-keyword.out
--- a/tests/test-keyword.out
+++ b/tests/test-keyword.out
@@ -252,7 +252,7 @@ added 1 changesets with 3 changes to 3 f
 added 1 changesets with 3 changes to 3 files
 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
 % incoming
-comparing with test-keyword/Test-a/../Test
+comparing with test-keyword/Test
 searching for changes
 changeset:   1:0729690beff6
 tag:         tip
diff --git a/tests/test-paths b/tests/test-paths
new file mode 100755
--- /dev/null
+++ b/tests/test-paths
@@ -0,0 +1,11 @@
+#!/bin/sh
+base=`pwd`
+hg init a
+hg clone a b
+cd a
+echo '[paths]' >> .hg/hgrc
+echo 'dupe = ../b' >> .hg/hgrc
+hg in dupe | sed "s!$base!<base>!g"
+cd ..
+hg -R a in dupe | sed "s!$base!<base>!g"
+true
diff --git a/tests/test-paths.out b/tests/test-paths.out
new file mode 100644
--- /dev/null
+++ b/tests/test-paths.out
@@ -0,0 +1,5 @@
+0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+comparing with <base>/b
+no changes found
+comparing with <base>/b
+no changes found


More information about the Mercurial-devel mailing list