Mercurial > hg
diff hgext/convert/p4.py @ 25788:a36fd0993522
convert: unescape Perforce-escaped special characters in filenames
author | Eugene Baranov <eug.baranov@gmail.com> |
---|---|
date | Tue, 14 Jul 2015 16:23:57 +0100 |
parents | 809c3e4a9e31 |
children | 584044e5ad57 |
line wrap: on
line diff
--- a/hgext/convert/p4.py Mon Jul 13 21:37:46 2015 -0700 +++ b/hgext/convert/p4.py Tue Jul 14 16:23:57 2015 +0100 @@ -23,6 +23,20 @@ except EOFError: pass +def decodefilename(filename): + """Perforce escapes special characters @, #, *, or % + with %40, %23, %2A, or %25 respectively + + >>> decodefilename('portable-net45%252Bnetcore45%252Bwp8%252BMonoAndroid') + 'portable-net45%2Bnetcore45%2Bwp8%2BMonoAndroid' + >>> decodefilename('//Depot/Directory/%2525/%2523/%23%40.%2A') + '//Depot/Directory/%25/%23/#@.*' + """ + replacements = [('%2A', '*'), ('%23', '#'), ('%40', '@'), ('%25', '%')] + for k, v in replacements: + filename = filename.replace(k, v) + return filename + class p4_source(converter_source): def __init__(self, ui, path, revs=None): super(p4_source, self).__init__(ui, path, revs=revs) @@ -138,7 +152,7 @@ filename = None for v in vieworder: if oldname.lower().startswith(v.lower()): - filename = views[v] + oldname[len(v):] + filename = decodefilename(views[v] + oldname[len(v):]) break if filename: files.append((filename, d["rev%d" % i]))