Mercurial > hg
changeset 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 | a8376f2aa3b1 |
files | mercurial/store.py tests/test-hybridencode.py tests/test-hybridencode.py.out |
diffstat | 3 files changed, 7 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/store.py Sat Dec 13 17:39:56 2008 +0100 +++ b/mercurial/store.py Sat Dec 13 18:32:29 2008 +0100 @@ -61,6 +61,9 @@ # encode third letter ('aux' -> 'au~78') ec = "~%02x" % ord(n[2]) n = n[0:2] + ec + n[3:] + if n[-1] in '. ': + # encode last period or space ('foo...' -> 'foo..~2e') + n = n[:-1] + "~%02x" % ord(n[-1]) res.append(n) return '/'.join(res)
--- a/tests/test-hybridencode.py Sat Dec 13 17:39:56 2008 +0100 +++ b/tests/test-hybridencode.py Sat Dec 13 18:32:29 2008 +0100 @@ -16,3 +16,4 @@ show('data/AUX.THE-QUICK-BROWN-FOX-JU:MPS-OVER-THE-LAZY-DOG-THE-QUICK-BROWN-FOX-JUMPS-OVER-THE-LAZY-DOG.TXT.i') show('data/Project Planning/Resources/AnotherLongDirectoryName/Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt') show('data/Project.Planning/Resources/AnotherLongDirectoryName/Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt') +show('data/foo.../foo / /a./_. /__/.x../ bla/something.i')
--- a/tests/test-hybridencode.py.out Sat Dec 13 17:39:56 2008 +0100 +++ b/tests/test-hybridencode.py.out Sat Dec 13 18:32:29 2008 +0100 @@ -16,3 +16,6 @@ A = 'data/Project.Planning/Resources/AnotherLongDirectoryName/Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt' B = 'dh/project_/resource/anotherl/followed/andanoth/andthenanextremelylongfilena0fd7c506f5c9d58204444fc67e9499006bd2d445.txt' +A = 'data/foo.../foo / /a./_. /__/.x../ bla/something.i' +B = 'data/foo..~2e/foo ~20/~20/a~2e/__.~20/____/.x.~2e/ bla/something.i' +