diff mercurial/scmutil.py @ 50479:4bddc2f72879

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.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 13 Apr 2019 01:53:59 +0200
parents 28dfb2df4ab9
children 9096b00fd881
line wrap: on
line diff
--- a/mercurial/scmutil.py	Fri Apr 05 01:17:15 2019 +0200
+++ b/mercurial/scmutil.py	Sat Apr 13 01:53:59 2019 +0200
@@ -2313,3 +2313,13 @@
         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 == [b'*'] or username in userlist