Show More
@@ -35,8 +35,7 b' to the repository root.' | |||||
35 |
|
35 | |||
36 | The special lines ``[include]`` and ``[exclude]`` denote the section |
|
36 | The special lines ``[include]`` and ``[exclude]`` denote the section | |
37 | for includes and excludes that follow, respectively. It is illegal to |
|
37 | for includes and excludes that follow, respectively. It is illegal to | |
38 |
have ``[include]`` after ``[exclude]``. |
|
38 | have ``[include]`` after ``[exclude]``. | |
39 | entries are assumed to be in the ``[include]`` section. |
|
|||
40 |
|
39 | |||
41 | Non-special lines resemble file patterns to be added to either includes |
|
40 | Non-special lines resemble file patterns to be added to either includes | |
42 | or excludes. The syntax of these lines is documented by :hg:`help patterns`. |
|
41 | or excludes. The syntax of these lines is documented by :hg:`help patterns`. |
@@ -33,8 +33,10 b' def parseconfig(ui, raw):' | |||||
33 | """ |
|
33 | """ | |
34 | includes = set() |
|
34 | includes = set() | |
35 | excludes = set() |
|
35 | excludes = set() | |
36 | current = includes |
|
|||
37 | profiles = set() |
|
36 | profiles = set() | |
|
37 | current = None | |||
|
38 | havesection = False | |||
|
39 | ||||
38 | for line in raw.split('\n'): |
|
40 | for line in raw.split('\n'): | |
39 | line = line.strip() |
|
41 | line = line.strip() | |
40 | if not line or line.startswith('#'): |
|
42 | if not line or line.startswith('#'): | |
@@ -45,14 +47,23 b' def parseconfig(ui, raw):' | |||||
45 | if line: |
|
47 | if line: | |
46 | profiles.add(line) |
|
48 | profiles.add(line) | |
47 | elif line == '[include]': |
|
49 | elif line == '[include]': | |
48 | if current != includes: |
|
50 | if havesection and current != includes: | |
49 | # TODO pass filename into this API so we can report it. |
|
51 | # TODO pass filename into this API so we can report it. | |
50 | raise error.Abort(_('sparse config cannot have includes ' + |
|
52 | raise error.Abort(_('sparse config cannot have includes ' + | |
51 | 'after excludes')) |
|
53 | 'after excludes')) | |
|
54 | havesection = True | |||
|
55 | current = includes | |||
52 | continue |
|
56 | continue | |
53 | elif line == '[exclude]': |
|
57 | elif line == '[exclude]': | |
|
58 | havesection = True | |||
54 | current = excludes |
|
59 | current = excludes | |
55 | elif line: |
|
60 | elif line: | |
|
61 | if current is None: | |||
|
62 | raise error.Abort(_('sparse config entry outside of ' | |||
|
63 | 'section: %s') % line, | |||
|
64 | hint=_('add an [include] or [exclude] line ' | |||
|
65 | 'to declare the entry type')) | |||
|
66 | ||||
56 | if line.strip().startswith('/'): |
|
67 | if line.strip().startswith('/'): | |
57 | ui.warn(_('warning: sparse profile cannot use' + |
|
68 | ui.warn(_('warning: sparse profile cannot use' + | |
58 | ' paths starting with /, ignoring %s\n') % line) |
|
69 | ' paths starting with /, ignoring %s\n') % line) |
@@ -10,6 +10,18 b' test sparse' | |||||
10 | > rebase= |
|
10 | > rebase= | |
11 | > EOF |
|
11 | > EOF | |
12 |
|
12 | |||
|
13 | Config file without [section] is rejected | |||
|
14 | ||||
|
15 | $ cat > bad.sparse <<EOF | |||
|
16 | > *.html | |||
|
17 | > EOF | |||
|
18 | ||||
|
19 | $ hg debugsparse --import-rules bad.sparse | |||
|
20 | abort: sparse config entry outside of section: *.html | |||
|
21 | (add an [include] or [exclude] line to declare the entry type) | |||
|
22 | [255] | |||
|
23 | $ rm bad.sparse | |||
|
24 | ||||
13 | $ echo a > index.html |
|
25 | $ echo a > index.html | |
14 | $ echo x > data.py |
|
26 | $ echo x > data.py | |
15 | $ echo z > readme.txt |
|
27 | $ echo z > readme.txt | |
@@ -257,6 +269,7 b' Test file permissions changing across a ' | |||||
257 | > EOF |
|
269 | > EOF | |
258 | $ touch a b |
|
270 | $ touch a b | |
259 | $ cat > .hgsparse <<EOF |
|
271 | $ cat > .hgsparse <<EOF | |
|
272 | > [include] | |||
260 | > a |
|
273 | > a | |
261 | > EOF |
|
274 | > EOF | |
262 | $ hg commit -Aqm 'initial' |
|
275 | $ hg commit -Aqm 'initial' |
General Comments 0
You need to be logged in to leave comments.
Login now