comparison mercurial/util.py @ 13944:bc32bb0e909f

util: new function checkfilename checkfilename checks for restrictions on filenames imposed by Mercurial itself, irrespective of on what platform it is run.
author Adrian Buehlmann <adrian@cadifra.com>
date Fri, 15 Apr 2011 16:15:30 +0200
parents 545091b12724
children d2d1ef6a5238
comparison
equal deleted inserted replaced
13943:545091b12724 13944:bc32bb0e909f
491 shutil.copy(src, dst) 491 shutil.copy(src, dst)
492 num += 1 492 num += 1
493 493
494 return hardlink, num 494 return hardlink, num
495 495
496 def checkfilename(f):
497 '''Check that the filename f is an acceptable filename for a tracked file'''
498 if '\r' in f or '\n' in f:
499 raise Abort(_("'\\n' and '\\r' disallowed in filenames: %r") % f)
500
496 _windows_reserved_filenames = '''con prn aux nul 501 _windows_reserved_filenames = '''con prn aux nul
497 com1 com2 com3 com4 com5 com6 com7 com8 com9 502 com1 com2 com3 com4 com5 com6 com7 com8 com9
498 lpt1 lpt2 lpt3 lpt4 lpt5 lpt6 lpt7 lpt8 lpt9'''.split() 503 lpt1 lpt2 lpt3 lpt4 lpt5 lpt6 lpt7 lpt8 lpt9'''.split()
499 _windows_reserved_chars = ':*?"<>|' 504 _windows_reserved_chars = ':*?"<>|'
500 def checkwinfilename(path): 505 def checkwinfilename(path):