comparison mercurial/ignore.py @ 25066:e91b32d3c67b

ignore: refactor syntax concatenation This refactors the syntax+rule concatenation logic to be more separated. It determines the syntax and the rule separately and then puts them back together. This will help in a later patch when we want to process just the rule before it gets concatenated.
author Durham Goode <durham@fb.com>
date Thu, 07 May 2015 21:00:46 -0700
parents 8cf7f0c4cb14
children 3139900f31b1
comparison
equal deleted inserted replaced
25065:8cf7f0c4cb14 25066:e91b32d3c67b
38 try: 38 try:
39 syntax = syntaxes[s] 39 syntax = syntaxes[s]
40 except KeyError: 40 except KeyError:
41 warnings.append(_("ignoring invalid syntax '%s'") % s) 41 warnings.append(_("ignoring invalid syntax '%s'") % s)
42 continue 42 continue
43 pat = syntax + line 43
44 linesyntax = syntax
44 for s, rels in syntaxes.iteritems(): 45 for s, rels in syntaxes.iteritems():
45 if line.startswith(rels): 46 if line.startswith(rels):
46 pat = line 47 linesyntax = rels
48 line = line[len(rels):]
47 break 49 break
48 elif line.startswith(s+':'): 50 elif line.startswith(s+':'):
49 pat = rels + line[len(s) + 1:] 51 linesyntax = rels
52 line = line[len(s) + 1:]
50 break 53 break
51 patterns.append(pat) 54 patterns.append(linesyntax + line)
52 55
53 return patterns, warnings 56 return patterns, warnings
54 57
55 def readignorefile(filepath, warn, skipwarning=False): 58 def readignorefile(filepath, warn, skipwarning=False):
56 try: 59 try: