comparison mercurial/util.py @ 34069:ca6a3852daf0

util: use set for reserved Windows filenames Previously, we were performing membership testing against a list. Change it to a set for a minor perf win. While we're at it, explode the assignment in place so less work is needed at module import time. Differential Revision: https://phab.mercurial-scm.org/D600
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 31 Aug 2017 19:40:15 -0700
parents 2ad028635ccd
children 30535fe47e78
comparison
equal deleted inserted replaced
34068:d2fc88426d21 34069:ca6a3852daf0
1228 progress(topic, num) 1228 progress(topic, num)
1229 progress(topic, None) 1229 progress(topic, None)
1230 1230
1231 return hardlink, num 1231 return hardlink, num
1232 1232
1233 _winreservednames = b'''con prn aux nul 1233 _winreservednames = {
1234 com1 com2 com3 com4 com5 com6 com7 com8 com9 1234 'con', 'prn', 'aux', 'nul',
1235 lpt1 lpt2 lpt3 lpt4 lpt5 lpt6 lpt7 lpt8 lpt9'''.split() 1235 'com1', 'com2', 'com3', 'com4', 'com5', 'com6', 'com7', 'com8', 'com9',
1236 'lpt1', 'lpt2', 'lpt3', 'lpt4', 'lpt5', 'lpt6', 'lpt7', 'lpt8', 'lpt9',
1237 }
1236 _winreservedchars = ':*?"<>|' 1238 _winreservedchars = ':*?"<>|'
1237 def checkwinfilename(path): 1239 def checkwinfilename(path):
1238 r'''Check that the base-relative path is a valid filename on Windows. 1240 r'''Check that the base-relative path is a valid filename on Windows.
1239 Returns None if the path is ok, or a UI string describing the problem. 1241 Returns None if the path is ok, or a UI string describing the problem.
1240 1242