Show More
@@ -6,6 +6,10 b'' | |||||
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 |
|
8 | |||
|
9 | from mercurial.i18n import _ | |||
|
10 | ||||
|
11 | from mercurial.utils import stringutil | |||
|
12 | ||||
9 | from mercurial import ( |
|
13 | from mercurial import ( | |
10 | bundle2, |
|
14 | bundle2, | |
11 | error, |
|
15 | error, | |
@@ -82,20 +86,38 b' def narrow_widen(' | |||||
82 | # work around ''.split(',') => [''] |
|
86 | # work around ''.split(',') => [''] | |
83 | return data.split(b',') if data else [] |
|
87 | return data.split(b',') if data else [] | |
84 |
|
88 | |||
85 | oldincludes = splitpaths(oldincludes) |
|
89 | oldincludes = set(splitpaths(oldincludes)) | |
86 | newincludes = splitpaths(newincludes) |
|
90 | newincludes = set(splitpaths(newincludes)) | |
87 | oldexcludes = splitpaths(oldexcludes) |
|
91 | oldexcludes = set(splitpaths(oldexcludes)) | |
88 | newexcludes = splitpaths(newexcludes) |
|
92 | newexcludes = set(splitpaths(newexcludes)) | |
89 |
|
93 | |||
90 | # enforce narrow acl if set |
|
94 | # enforce narrow acl if set | |
91 | if repo.ui.has_section(exchange._NARROWACL_SECTION): |
|
95 | if repo.ui.has_section(exchange._NARROWACL_SECTION): | |
92 |
exchange.applynarrowacl( |
|
96 | kwargs = exchange.applynarrowacl( | |
|
97 | repo, {'includepats': newincludes, 'excludepats': newexcludes} | |||
|
98 | ) | |||
|
99 | newincludes = kwargs['includepats'] | |||
|
100 | requiredexcludes = kwargs['excludepats'] - newexcludes | |||
|
101 | if requiredexcludes: | |||
|
102 | # XXX: The below code to get the username was copied from exchange.py, | |||
|
103 | # where it is noted that this is technically a layering violation for | |||
|
104 | # assuming the existence of HTTP. Using it anyway to make the error | |||
|
105 | # message consistent with the error message for invalid includes. | |||
|
106 | ui = repo.ui | |||
|
107 | username = ui.shortuser( | |||
|
108 | ui.environ.get(b'REMOTE_USER') or ui.username() | |||
|
109 | ) | |||
|
110 | raise error.Abort( | |||
|
111 | _(b"The following excludes cannot be removed for %s: %s") | |||
|
112 | % (username, stringutil.pprint(list(requiredexcludes))) | |||
|
113 | ) | |||
|
114 | newexcludes = kwargs['excludepats'] | |||
93 |
|
115 | |||
94 | # validate the patterns |
|
116 | # validate the patterns | |
95 |
narrowspec.validatepatterns( |
|
117 | narrowspec.validatepatterns(oldincludes) | |
96 |
narrowspec.validatepatterns( |
|
118 | narrowspec.validatepatterns(newincludes) | |
97 |
narrowspec.validatepatterns( |
|
119 | narrowspec.validatepatterns(oldexcludes) | |
98 |
narrowspec.validatepatterns( |
|
120 | narrowspec.validatepatterns(newexcludes) | |
99 |
|
121 | |||
100 | common = wireprototypes.decodelist(commonheads) |
|
122 | common = wireprototypes.decodelist(commonheads) | |
101 | known = wireprototypes.decodelist(known) |
|
123 | known = wireprototypes.decodelist(known) |
@@ -64,18 +64,12 b' Narrow should not be able to remove the ' | |||||
64 | $ hg -R narrowclone1 tracked --removeexclude f3 |
|
64 | $ hg -R narrowclone1 tracked --removeexclude f3 | |
65 | comparing with http://localhost:$HGPORT1/ |
|
65 | comparing with http://localhost:$HGPORT1/ | |
66 | searching for changes |
|
66 | searching for changes | |
67 | adding changesets |
|
67 | abort: The following excludes cannot be removed for test: ['path:f3'] | |
68 | adding manifests |
|
68 | [255] | |
69 | adding file changes |
|
|||
70 | added 0 changesets with 1 changes to 1 files |
|
|||
71 | $ ls -A -1 narrowclone1 | sort |
|
69 | $ ls -A -1 narrowclone1 | sort | |
72 | .hg |
|
70 | .hg | |
73 | f1 |
|
71 | f1 | |
74 | f2 |
|
72 | f2 | |
75 | f3 |
|
|||
76 | $ hg -R narrowclone1 tracked |
|
73 | $ hg -R narrowclone1 tracked | |
77 | I path:. |
|
74 | I path:. | |
78 |
|
75 | X path:f3 | ||
79 |
|
||||
80 | XXX: BUG! This test demonstrates that we are presently |
|
|||
81 | able to gain access to f3 by removing the exclusion. |
|
General Comments 0
You need to be logged in to leave comments.
Login now