comparison mercurial/subrepo.py @ 15150:91dc8878f888

subrepo: try remapping subpaths using the "final" path Before, the right-hand side of a .hgsub entry was used, as is, to match the left-hand side of a subpaths entry. This turned out to be less useful than expected since a .hgsub file with src/foo = src/foo has little context to do remapping on. The new idea is therefore to prefix the parent repo path *before* the remapping takes place. If the parent repository path (as defined by _abssource) is http://example.net/parent then the remapping for the above .hgsub entry will be done on the expanded path: http://example.net/parent/src/foo If this expanded path is not changed by the remapping, then we remap src/foo alone. This is the old behavior where the right-hand side is remapped without context.
author Martin Geisler <mg@aragost.com>
date Thu, 22 Sep 2011 15:15:18 +0200
parents eaec9cf91aea
children 6dc67dced8c1
comparison
equal deleted inserted replaced
15149:eaec9cf91aea 15150:91dc8878f888
72 if src.startswith('['): 72 if src.startswith('['):
73 if ']' not in src: 73 if ']' not in src:
74 raise util.Abort(_('missing ] in subrepo source')) 74 raise util.Abort(_('missing ] in subrepo source'))
75 kind, src = src.split(']', 1) 75 kind, src = src.split(']', 1)
76 kind = kind[1:] 76 kind = kind[1:]
77 src = src.lstrip() # strip any extra whitespace after ']'
78
79 if not util.url(src).isabs():
80 parent = _abssource(ctx._repo, abort=False)
81 if parent:
82 parent = util.url(parent)
83 parent.path = posixpath.join(parent.path or '', src)
84 parent.path = posixpath.normpath(parent.path)
85 joined = str(parent)
86 # Remap the full joined path and use it if it changes,
87 # else remap the original source.
88 remapped = remap(joined)
89 if remapped == joined:
90 src = remap(src)
91 else:
92 src = remapped
93
77 src = remap(src) 94 src = remap(src)
78 state[path] = (src.strip(), rev.get(path, ''), kind) 95 state[path] = (src.strip(), rev.get(path, ''), kind)
79 96
80 return state 97 return state
81 98