equal
deleted
inserted
replaced
4 # |
4 # |
5 # This software may be used and distributed according to the terms |
5 # This software may be used and distributed according to the terms |
6 # of the GNU General Public License, incorporated herein by reference. |
6 # of the GNU General Public License, incorporated herein by reference. |
7 |
7 |
8 from i18n import _ |
8 from i18n import _ |
9 import util |
9 import util, re |
|
10 |
|
11 _commentre = None |
10 |
12 |
11 def _parselines(fp): |
13 def _parselines(fp): |
12 for line in fp: |
14 for line in fp: |
13 if not line.endswith('\n'): |
15 if "#" in line: |
14 line += '\n' |
16 global _commentre |
15 escape = False |
17 if not _commentre: |
16 for i in xrange(len(line)): |
18 _commentre = re.compile(r'((^|[^\\])(\\\\)*)#.*') |
17 if escape: escape = False |
19 # remove comments prefixed by an even number of escapes |
18 elif line[i] == '\\': escape = True |
20 line = _commentre.sub(r'\1', line) |
19 elif line[i] == '#': break |
21 # fixup properly escaped comments that survived the above |
20 line = line[:i].rstrip() |
22 line = line.replace("\\#", "#") |
|
23 line = line.rstrip() |
21 if line: |
24 if line: |
22 yield line |
25 yield line |
23 |
26 |
24 def ignore(root, files, warn): |
27 def ignore(root, files, warn): |
25 '''return the contents of .hgignore files as a list of patterns. |
28 '''return the contents of .hgignore files as a list of patterns. |