Patchwork [12,of,14,"] hgweb: move ismember from `hgweb.common` to `scmutil`

login
register
mail settings
Submitter Pierre-Yves David
Date April 13, 2019, 11:40 p.m.
Message ID <b05e8ee5498f8d3b0c34.1555198842@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/39599/
State Accepted
Headers show

Comments

Pierre-Yves David - April 13, 2019, 11:40 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1555113239 -7200
#      Sat Apr 13 01:53:59 2019 +0200
# Node ID b05e8ee5498f8d3b0c3419309a4a476d791e169d
# Parent  fb4b7793a71ec639bd567f3b088719a0fc16f9c8
# EXP-Topic hgweb-obsolete
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r b05e8ee5498f
hgweb: move ismember from `hgweb.common` to `scmutil`

To implement hidden access control for other protocol than http, we need code
outside of hgweb to access this logic.

Patch

diff --git a/mercurial/hgweb/common.py b/mercurial/hgweb/common.py
--- a/mercurial/hgweb/common.py
+++ b/mercurial/hgweb/common.py
@@ -19,6 +19,7 @@  from ..i18n import _
 from .. import (
     encoding,
     pycompat,
+    scmutil,
     util,
 )
 
@@ -36,15 +37,7 @@  HTTP_NOT_ACCEPTABLE = 406
 HTTP_UNSUPPORTED_MEDIA_TYPE = 415
 HTTP_SERVER_ERROR = 500
 
-
-def ismember(ui, username, userlist):
-    """Check if username is a member of userlist.
-
-    If userlist has a single '*' member, all users are considered members.
-    Can be overridden by extensions to provide more complex authorization
-    schemes.
-    """
-    return userlist == ['*'] or username in userlist
+ismember = scmutil.ismember
 
 def hashiddenaccess(repo, req):
     if bool(req.qsparams.get('access-hidden')):
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1945,3 +1945,12 @@  def bookmarkrevs(repo, mark):
                      "ancestors(head() and not bookmark(%s)) - "
                      "ancestors(bookmark() and not bookmark(%s))",
                      mark, mark, mark)
+
+def ismember(ui, username, userlist):
+    """Check if username is a member of userlist.
+
+    If userlist has a single '*' member, all users are considered members.
+    Can be overridden by extensions to provide more complex authorization
+    schemes.
+    """
+    return userlist == ['*'] or username in userlist