comparison mercurial/util.py @ 13947:d2d1ef6a5238

checkwinfilename: use %r in format string
author Adrian Buehlmann <adrian@cadifra.com>
date Sat, 16 Apr 2011 20:08:43 +0200
parents bc32bb0e909f
children d13913355390
comparison
equal deleted inserted replaced
13946:3c2f9f611ef6 13947:d2d1ef6a5238
515 >>> checkwinfilename("foo/bar/AUX/bla.txt") 515 >>> checkwinfilename("foo/bar/AUX/bla.txt")
516 "filename contains 'AUX', which is reserved on Windows" 516 "filename contains 'AUX', which is reserved on Windows"
517 >>> checkwinfilename("foo/bar/bla:.txt") 517 >>> checkwinfilename("foo/bar/bla:.txt")
518 "filename contains ':', which is reserved on Windows" 518 "filename contains ':', which is reserved on Windows"
519 >>> checkwinfilename("foo/bar/b\07la.txt") 519 >>> checkwinfilename("foo/bar/b\07la.txt")
520 "filename contains '\\x07', which is invalid on Windows" 520 "filename contains '\\\\x07', which is invalid on Windows"
521 >>> checkwinfilename("foo/bar/bla ") 521 >>> checkwinfilename("foo/bar/bla ")
522 "filename ends with ' ', which is not allowed on Windows" 522 "filename ends with ' ', which is not allowed on Windows"
523 ''' 523 '''
524 for n in path.replace('\\', '/').split('/'): 524 for n in path.replace('\\', '/').split('/'):
525 if not n: 525 if not n:
527 for c in n: 527 for c in n:
528 if c in _windows_reserved_chars: 528 if c in _windows_reserved_chars:
529 return _("filename contains '%s', which is reserved " 529 return _("filename contains '%s', which is reserved "
530 "on Windows") % c 530 "on Windows") % c
531 if ord(c) <= 31: 531 if ord(c) <= 31:
532 return _("filename contains '%s', which is invalid " 532 return _("filename contains %r, which is invalid "
533 "on Windows") % c 533 "on Windows") % c
534 base = n.split('.')[0] 534 base = n.split('.')[0]
535 if base and base.lower() in _windows_reserved_filenames: 535 if base and base.lower() in _windows_reserved_filenames:
536 return _("filename contains '%s', which is reserved " 536 return _("filename contains '%s', which is reserved "
537 "on Windows") % base 537 "on Windows") % base