comparison mercurial/subrepo.py @ 11961:f3075ffa6b30

subrepos: handle backslashes in subpaths
author Martin Geisler <mg@lazybytes.net>
date Thu, 19 Aug 2010 13:25:46 +0200
parents a8614c5a5e9a
children 63eab3b74ba6
comparison
equal deleted inserted replaced
11959:be33381882ad 11961:f3075ffa6b30
48 raise util.Abort(_('missing ] in subrepo source')) 48 raise util.Abort(_('missing ] in subrepo source'))
49 kind, src = src.split(']', 1) 49 kind, src = src.split(']', 1)
50 kind = kind[1:] 50 kind = kind[1:]
51 51
52 for pattern, repl in p.items('subpaths'): 52 for pattern, repl in p.items('subpaths'):
53 # Turn r'C:\foo\bar' into r'C:\\foo\\bar' since re.sub
54 # does a string decode.
55 repl = repl.encode('string-escape')
56 # However, we still want to allow back references to go
57 # through unharmed, so we turn r'\\1' into r'\1'. Again,
58 # extra escapes are needed because re.sub string decodes.
59 repl = re.sub(r'\\\\([0-9]+)', r'\\\1', repl)
53 try: 60 try:
54 src = re.sub(pattern, repl, src, 1) 61 src = re.sub(pattern, repl, src, 1)
55 except re.error, e: 62 except re.error, e:
56 raise util.Abort(_("bad subrepository pattern in %s: %s") 63 raise util.Abort(_("bad subrepository pattern in %s: %s")
57 % (p.source('subpaths', pattern), e)) 64 % (p.source('subpaths', pattern), e))