changeset 1350:554eaa682561

Fix for externals that include '..' in the path, i.e. relative paths within svn
author Steve Barnes <StevenJohn.Barnes@ge.com>
date Tue, 16 Dec 2014 14:43:41 +0000
parents bb9b886090e8
children 9d58ca6253a3
files hgsubversion/svnexternals.py
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/svnexternals.py
+++ b/hgsubversion/svnexternals.py
@@ -120,13 +120,24 @@ def parsedefinition(line):
 class RelativeSourceError(Exception):
     pass
 
+def resolvedots(url):
+    """ Fix references that include .. entries."""
+    orig = url.split('/')
+    fixed = []
+    for item in orig:
+        if item != '..':
+            fixed.append(item)
+        else:
+            fixed.pop()
+    return '/'.join(fixed)
+
 def resolvesource(ui, svnroot, source):
     if re_scheme.search(source):
         return source
     if source.startswith('^/'):
         if svnroot is None:
             raise RelativeSourceError()
-        return svnroot + source[1:]
+        return resolvedots(svnroot + source[1:])
     ui.warn(_('ignoring unsupported non-fully qualified external: %r\n'
               % source))
     return None