Mercurial > hg-stable
changeset 20000:0849d280663e stable
util: warn when adding paths ending with \
Paths ending with \ will fail the verification introduced in 684a977c2ae0 when
checking out on Windows ... and if it didn't fail it would probably not do what
the user expected.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Fri, 08 Nov 2013 12:35:50 +0100 |
parents | 169cb9e47f8e |
children | a1f99a7f2d72 |
files | mercurial/util.py |
diffstat | 1 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/util.py Tue Nov 05 09:00:31 2013 +0100 +++ b/mercurial/util.py Fri Nov 08 12:35:50 2013 +0100 @@ -563,7 +563,7 @@ lpt1 lpt2 lpt3 lpt4 lpt5 lpt6 lpt7 lpt8 lpt9'''.split() _winreservedchars = ':*?"<>|' def checkwinfilename(path): - '''Check that the base-relative path is a valid filename on Windows. + r'''Check that the base-relative path is a valid filename on Windows. Returns None if the path is ok, or a UI string describing the problem. >>> checkwinfilename("just/a/normal/path") @@ -577,11 +577,19 @@ >>> checkwinfilename("foo/bar/bla:.txt") "filename contains ':', which is reserved on Windows" >>> checkwinfilename("foo/bar/b\07la.txt") - "filename contains '\\\\x07', which is invalid on Windows" + "filename contains '\\x07', which is invalid on Windows" >>> checkwinfilename("foo/bar/bla ") "filename ends with ' ', which is not allowed on Windows" >>> checkwinfilename("../bar") + >>> checkwinfilename("foo\\") + "filename ends with '\\', which is invalid on Windows" + >>> checkwinfilename("foo\\/bar") + "directory name ends with '\\', which is invalid on Windows" ''' + if path.endswith('\\'): + return _("filename ends with '\\', which is invalid on Windows") + if '\\/' in path: + return _("directory name ends with '\\', which is invalid on Windows") for n in path.replace('\\', '/').split('/'): if not n: continue