Mercurial > hg
comparison mercurial/store.py @ 7515:ee5aba886108
store: encode trailing period and space on directory names (issue1417)
Windows won't create directories with names ending in period or space, so
we encode the last period/space character in directory names of non-hashed
paths in the store using reversible ~xx encoding (' ' -> '~20', '.' -> '~2e').
With this change it is possible to remove a directory ending in period or space
that was inadvertantly checked in on a linux system while still being able
to clone such a repository with its full history to Windows (see also issue793).
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Sat, 13 Dec 2008 18:32:29 +0100 |
parents | e54cf540c6ca |
children | e710f0f592b2 |
comparison
equal
deleted
inserted
replaced
7514:e54cf540c6ca | 7515:ee5aba886108 |
---|---|
59 base = n.split('.')[0] | 59 base = n.split('.')[0] |
60 if base and (base in _windows_reserved_filenames): | 60 if base and (base in _windows_reserved_filenames): |
61 # encode third letter ('aux' -> 'au~78') | 61 # encode third letter ('aux' -> 'au~78') |
62 ec = "~%02x" % ord(n[2]) | 62 ec = "~%02x" % ord(n[2]) |
63 n = n[0:2] + ec + n[3:] | 63 n = n[0:2] + ec + n[3:] |
64 if n[-1] in '. ': | |
65 # encode last period or space ('foo...' -> 'foo..~2e') | |
66 n = n[:-1] + "~%02x" % ord(n[-1]) | |
64 res.append(n) | 67 res.append(n) |
65 return '/'.join(res) | 68 return '/'.join(res) |
66 | 69 |
67 MAX_PATH_LEN_IN_HGSTORE = 120 | 70 MAX_PATH_LEN_IN_HGSTORE = 120 |
68 DIR_PREFIX_LEN = 8 | 71 DIR_PREFIX_LEN = 8 |