acl: grp module is not available on windows
authorPatrick Mezard <pmezard@gmail.com>
Mon, 10 May 2010 21:09:48 +0200
changeset 11138 99eee847beaa
parent 11137 94afe7bc87a9
child 11139 f2c6b9819a6d
acl: grp module is not available on windows
hgext/acl.py
mercurial/posix.py
mercurial/windows.py
--- a/hgext/acl.py	Sun May 09 22:51:25 2010 +0200
+++ b/hgext/acl.py	Mon May 10 21:09:48 2010 +0200
@@ -150,7 +150,7 @@
 
 from mercurial.i18n import _
 from mercurial import util, match
-import getpass, urllib, grp
+import getpass, urllib
 
 def _getusers(ui, group):
 
@@ -161,7 +161,7 @@
 
     ui.debug('acl: "%s" not defined in [acl.groups]\n' % group)
     # If no users found in group definition, get users from OS-level group
-    return grp.getgrnam(group).gr_mem
+    return util.groupmembers(group)
 
 def _usermatch(ui, user, usersorgroups):
 
--- a/mercurial/posix.py	Sun May 09 22:51:25 2010 +0200
+++ b/mercurial/posix.py	Mon May 10 21:09:48 2010 +0200
@@ -259,6 +259,12 @@
     except KeyError:
         return str(gid)
 
+def groupmembers(name):
+    """Return the list of members of the group with the given
+    name, KeyError if the group does not exist.
+    """
+    return list(grp.getgrnam(name).gr_mem)
+
 def spawndetached(args):
     return os.spawnvp(os.P_NOWAIT | getattr(os, 'P_DETACH', 0),
                       args[0], args)
--- a/mercurial/windows.py	Sun May 09 22:51:25 2010 +0200
+++ b/mercurial/windows.py	Mon May 10 21:09:48 2010 +0200
@@ -363,6 +363,10 @@
     # current line but on the new one. Keep room for it.
     return 79
 
+def groupmembers(name):
+    # Don't support groups on Windows for now
+    raise KeyError()
+
 try:
     # override functions with win32 versions if possible
     from win32 import *