comparison mercurial/util.py @ 15358:a347b3614bae stable

util: don't complain about '..' in path components not working on Windows
author Matt Mackall <mpm@selenic.com>
date Mon, 24 Oct 2011 16:57:14 -0500
parents 85322c19c831
children fffe49886a51
comparison
equal deleted inserted replaced
15357:8ec1a2cfd2c0 15358:a347b3614bae
512 "filename contains ':', which is reserved on Windows" 512 "filename contains ':', which is reserved on Windows"
513 >>> checkwinfilename("foo/bar/b\07la.txt") 513 >>> checkwinfilename("foo/bar/b\07la.txt")
514 "filename contains '\\\\x07', which is invalid on Windows" 514 "filename contains '\\\\x07', which is invalid on Windows"
515 >>> checkwinfilename("foo/bar/bla ") 515 >>> checkwinfilename("foo/bar/bla ")
516 "filename ends with ' ', which is not allowed on Windows" 516 "filename ends with ' ', which is not allowed on Windows"
517 >>> checkwinfilename("../bar")
517 ''' 518 '''
518 for n in path.replace('\\', '/').split('/'): 519 for n in path.replace('\\', '/').split('/'):
519 if not n: 520 if not n:
520 continue 521 continue
521 for c in n: 522 for c in n:
528 base = n.split('.')[0] 529 base = n.split('.')[0]
529 if base and base.lower() in _winreservednames: 530 if base and base.lower() in _winreservednames:
530 return _("filename contains '%s', which is reserved " 531 return _("filename contains '%s', which is reserved "
531 "on Windows") % base 532 "on Windows") % base
532 t = n[-1] 533 t = n[-1]
533 if t in '. ': 534 if t in '. ' and n not in '..':
534 return _("filename ends with '%s', which is not allowed " 535 return _("filename ends with '%s', which is not allowed "
535 "on Windows") % t 536 "on Windows") % t
536 537
537 if os.name == 'nt': 538 if os.name == 'nt':
538 checkosfilename = checkwinfilename 539 checkosfilename = checkwinfilename