# HG changeset patch # User Steve Barnes # Date 1418741021 0 # Node ID 554eaa682561af9dc31826cfbcb0ee564d0dfc6d # Parent bb9b886090e89f26dc4312d2ebcd86a03bf14add Fix for externals that include '..' in the path, i.e. relative paths within svn diff --git a/hgsubversion/svnexternals.py b/hgsubversion/svnexternals.py --- 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