Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
mercurial-devel
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mercurial
mercurial-devel
Commits
9b44b25d
Commit
9b44b25d
authored
1 year ago
by
Arun Kulshreshtha
Browse files
Options
Downloads
Patches
Plain Diff
narrow: prevent removal of ACL-defined excludes
parent
bf7c24e1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!754
bundle: highlight misbehavior when --base does not match any revision
,
!751
narrow: fix narrow acl exclusion enforcement
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hgext/narrow/narrowwirepeer.py
+31
-9
31 additions, 9 deletions
hgext/narrow/narrowwirepeer.py
tests/test-narrow-acl-excludes.t
+3
-9
3 additions, 9 deletions
tests/test-narrow-acl-excludes.t
with
34 additions
and
18 deletions
hgext/narrow/narrowwirepeer.py
+
31
−
9
View file @
9b44b25d
...
...
@@ -6,6 +6,10 @@
# GNU General Public License version 2 or any later version.
from
mercurial.i18n
import
_
from
mercurial.utils
import
stringutil
from
mercurial
import
(
bundle2
,
error
,
...
...
@@ -82,10 +86,10 @@
# work around ''.split(',') => ['']
return
data
.
split
(
b
'
,
'
)
if
data
else
[]
oldincludes
=
splitpaths
(
oldincludes
)
newincludes
=
splitpaths
(
newincludes
)
oldexcludes
=
splitpaths
(
oldexcludes
)
newexcludes
=
splitpaths
(
newexcludes
)
oldincludes
=
set
(
splitpaths
(
oldincludes
)
)
newincludes
=
set
(
splitpaths
(
newincludes
)
)
oldexcludes
=
set
(
splitpaths
(
oldexcludes
)
)
newexcludes
=
set
(
splitpaths
(
newexcludes
)
)
# enforce narrow acl if set
if
repo
.
ui
.
has_section
(
exchange
.
_NARROWACL_SECTION
):
...
...
@@ -89,6 +93,24 @@
# enforce narrow acl if set
if
repo
.
ui
.
has_section
(
exchange
.
_NARROWACL_SECTION
):
exchange
.
applynarrowacl
(
repo
,
{
'
includepats
'
:
newincludes
})
kwargs
=
exchange
.
applynarrowacl
(
repo
,
{
'
includepats
'
:
newincludes
,
'
excludepats
'
:
newexcludes
}
)
newincludes
=
kwargs
[
'
includepats
'
]
requiredexcludes
=
kwargs
[
'
excludepats
'
]
-
newexcludes
if
requiredexcludes
:
# XXX: The below code to get the username was copied from exchange.py,
# where it is noted that this is technically a layering violation for
# assuming the existence of HTTP. Using it anyway to make the error
# message consistent with the error message for invalid includes.
ui
=
repo
.
ui
username
=
ui
.
shortuser
(
ui
.
environ
.
get
(
b
'
REMOTE_USER
'
)
or
ui
.
username
()
)
raise
error
.
Abort
(
_
(
b
"
The following excludes cannot be removed for %s: %s
"
)
%
(
username
,
stringutil
.
pprint
(
list
(
requiredexcludes
)))
)
newexcludes
=
kwargs
[
'
excludepats
'
]
# validate the patterns
...
...
@@ -93,9 +115,9 @@
# validate the patterns
narrowspec
.
validatepatterns
(
set
(
oldincludes
)
)
narrowspec
.
validatepatterns
(
set
(
newincludes
)
)
narrowspec
.
validatepatterns
(
set
(
oldexcludes
)
)
narrowspec
.
validatepatterns
(
set
(
newexcludes
)
)
narrowspec
.
validatepatterns
(
oldincludes
)
narrowspec
.
validatepatterns
(
newincludes
)
narrowspec
.
validatepatterns
(
oldexcludes
)
narrowspec
.
validatepatterns
(
newexcludes
)
common
=
wireprototypes
.
decodelist
(
commonheads
)
known
=
wireprototypes
.
decodelist
(
known
)
...
...
This diff is collapsed.
Click to expand it.
tests/test-narrow-acl-excludes.t
+
3
−
9
View file @
9b44b25d
...
...
@@ -64,11 +64,9 @@
$
hg
-
R
narrowclone1
tracked
--
removeexclude
f3
comparing
with
http:
//local
host:$HGPORT1
/
searching
for
changes
adding
changesets
adding
manifests
adding
file
changes
added
0
changesets
with
1
changes
to
1
files
abort:
The
following
excludes
cannot
be
removed
for
test:
['
path:f3
']
[
255
]
$
ls
-
A
-
1
narrowclone1
|
sort
.
hg
f1
f2
...
...
@@ -71,7 +69,6 @@
$
ls
-
A
-
1
narrowclone1
|
sort
.
hg
f1
f2
f3
$
hg
-
R
narrowclone1
tracked
I
path:
.
...
...
@@ -76,6 +73,3 @@
$
hg
-
R
narrowclone1
tracked
I
path:
.
XXX:
BUG
!
This
test
demonstrates
that
we
are
presently
able
to
gain
access
to
f3
by
removing
the
exclusion
.
X
path:f3
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment