Show More
@@ -38,63 +38,66 b' def parseconfig(ui, raw, action):' | |||||
38 |
|
38 | |||
39 | Returns a tuple of includes, excludes, and profiles. |
|
39 | Returns a tuple of includes, excludes, and profiles. | |
40 | """ |
|
40 | """ | |
41 | includes = set() |
|
41 | with util.timedcm( | |
42 | excludes = set() |
|
42 | 'sparse.parseconfig(ui, %d bytes, action=%s)', len(raw), action | |
43 | profiles = set() |
|
43 | ): | |
44 | current = None |
|
44 | includes = set() | |
45 | havesection = False |
|
45 | excludes = set() | |
|
46 | profiles = set() | |||
|
47 | current = None | |||
|
48 | havesection = False | |||
46 |
|
49 | |||
47 | for line in raw.split(b'\n'): |
|
50 | for line in raw.split(b'\n'): | |
48 | line = line.strip() |
|
51 | line = line.strip() | |
49 | if not line or line.startswith(b'#'): |
|
52 | if not line or line.startswith(b'#'): | |
50 | # empty or comment line, skip |
|
53 | # empty or comment line, skip | |
51 | continue |
|
54 | continue | |
52 | elif line.startswith(b'%include '): |
|
55 | elif line.startswith(b'%include '): | |
53 | line = line[9:].strip() |
|
56 | line = line[9:].strip() | |
54 | if line: |
|
57 | if line: | |
55 | profiles.add(line) |
|
58 | profiles.add(line) | |
56 | elif line == b'[include]': |
|
59 | elif line == b'[include]': | |
57 | if havesection and current != includes: |
|
60 | if havesection and current != includes: | |
58 | # TODO pass filename into this API so we can report it. |
|
61 | # TODO pass filename into this API so we can report it. | |
59 | raise error.Abort( |
|
62 | raise error.Abort( | |
60 | _( |
|
63 | _( | |
61 | b'%(action)s config cannot have includes ' |
|
64 | b'%(action)s config cannot have includes ' | |
62 | b'after excludes' |
|
65 | b'after excludes' | |
|
66 | ) | |||
|
67 | % {b'action': action} | |||
63 | ) |
|
68 | ) | |
64 |
|
|
69 | havesection = True | |
65 |
|
|
70 | current = includes | |
66 |
|
|
71 | continue | |
67 |
|
|
72 | elif line == b'[exclude]': | |
68 |
c |
|
73 | havesection = True | |
69 | elif line == b'[exclude]': |
|
74 | current = excludes | |
70 | havesection = True |
|
75 | elif line: | |
71 |
current |
|
76 | if current is None: | |
72 | elif line: |
|
77 | raise error.Abort( | |
73 | if current is None: |
|
78 | _( | |
74 | raise error.Abort( |
|
79 | b'%(action)s config entry outside of ' | |
75 |
|
|
80 | b'section: %(line)s' | |
76 | b'%(action)s config entry outside of ' |
|
81 | ) | |
77 |
b' |
|
82 | % {b'action': action, b'line': line}, | |
|
83 | hint=_( | |||
|
84 | b'add an [include] or [exclude] line ' | |||
|
85 | b'to declare the entry type' | |||
|
86 | ), | |||
78 | ) |
|
87 | ) | |
79 | % {b'action': action, b'line': line}, |
|
|||
80 | hint=_( |
|
|||
81 | b'add an [include] or [exclude] line ' |
|
|||
82 | b'to declare the entry type' |
|
|||
83 | ), |
|
|||
84 | ) |
|
|||
85 |
|
88 | |||
86 | if line.strip().startswith(b'/'): |
|
89 | if line.strip().startswith(b'/'): | |
87 | ui.warn( |
|
90 | ui.warn( | |
88 | _( |
|
91 | _( | |
89 | b'warning: %(action)s profile cannot use' |
|
92 | b'warning: %(action)s profile cannot use' | |
90 | b' paths starting with /, ignoring %(line)s\n' |
|
93 | b' paths starting with /, ignoring %(line)s\n' | |
|
94 | ) | |||
|
95 | % {b'action': action, b'line': line} | |||
91 | ) |
|
96 | ) | |
92 | % {b'action': action, b'line': line} |
|
97 | continue | |
93 | ) |
|
98 | current.add(line) | |
94 | continue |
|
|||
95 | current.add(line) |
|
|||
96 |
|
99 | |||
97 | return includes, excludes, profiles |
|
100 | return includes, excludes, profiles | |
98 |
|
101 | |||
99 |
|
102 | |||
100 | # Exists as separate function to facilitate monkeypatching. |
|
103 | # Exists as separate function to facilitate monkeypatching. |
General Comments 0
You need to be logged in to leave comments.
Login now