Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 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 | d51c4d85ec23 |
children | a1d88278beff c33d9217e99d |
comparison
equal
deleted
inserted
replaced
19999:169cb9e47f8e | 20000:0849d280663e |
---|---|
561 _winreservednames = '''con prn aux nul | 561 _winreservednames = '''con prn aux nul |
562 com1 com2 com3 com4 com5 com6 com7 com8 com9 | 562 com1 com2 com3 com4 com5 com6 com7 com8 com9 |
563 lpt1 lpt2 lpt3 lpt4 lpt5 lpt6 lpt7 lpt8 lpt9'''.split() | 563 lpt1 lpt2 lpt3 lpt4 lpt5 lpt6 lpt7 lpt8 lpt9'''.split() |
564 _winreservedchars = ':*?"<>|' | 564 _winreservedchars = ':*?"<>|' |
565 def checkwinfilename(path): | 565 def checkwinfilename(path): |
566 '''Check that the base-relative path is a valid filename on Windows. | 566 r'''Check that the base-relative path is a valid filename on Windows. |
567 Returns None if the path is ok, or a UI string describing the problem. | 567 Returns None if the path is ok, or a UI string describing the problem. |
568 | 568 |
569 >>> checkwinfilename("just/a/normal/path") | 569 >>> checkwinfilename("just/a/normal/path") |
570 >>> checkwinfilename("foo/bar/con.xml") | 570 >>> checkwinfilename("foo/bar/con.xml") |
571 "filename contains 'con', which is reserved on Windows" | 571 "filename contains 'con', which is reserved on Windows" |
575 >>> checkwinfilename("foo/bar/AUX/bla.txt") | 575 >>> checkwinfilename("foo/bar/AUX/bla.txt") |
576 "filename contains 'AUX', which is reserved on Windows" | 576 "filename contains 'AUX', which is reserved on Windows" |
577 >>> checkwinfilename("foo/bar/bla:.txt") | 577 >>> checkwinfilename("foo/bar/bla:.txt") |
578 "filename contains ':', which is reserved on Windows" | 578 "filename contains ':', which is reserved on Windows" |
579 >>> checkwinfilename("foo/bar/b\07la.txt") | 579 >>> checkwinfilename("foo/bar/b\07la.txt") |
580 "filename contains '\\\\x07', which is invalid on Windows" | 580 "filename contains '\\x07', which is invalid on Windows" |
581 >>> checkwinfilename("foo/bar/bla ") | 581 >>> checkwinfilename("foo/bar/bla ") |
582 "filename ends with ' ', which is not allowed on Windows" | 582 "filename ends with ' ', which is not allowed on Windows" |
583 >>> checkwinfilename("../bar") | 583 >>> checkwinfilename("../bar") |
584 >>> checkwinfilename("foo\\") | |
585 "filename ends with '\\', which is invalid on Windows" | |
586 >>> checkwinfilename("foo\\/bar") | |
587 "directory name ends with '\\', which is invalid on Windows" | |
584 ''' | 588 ''' |
589 if path.endswith('\\'): | |
590 return _("filename ends with '\\', which is invalid on Windows") | |
591 if '\\/' in path: | |
592 return _("directory name ends with '\\', which is invalid on Windows") | |
585 for n in path.replace('\\', '/').split('/'): | 593 for n in path.replace('\\', '/').split('/'): |
586 if not n: | 594 if not n: |
587 continue | 595 continue |
588 for c in n: | 596 for c in n: |
589 if c in _winreservedchars: | 597 if c in _winreservedchars: |