changeset 14926:4e7e63fc685a

util: eliminate wildcard imports
author Adrian Buehlmann <adrian@cadifra.com>
date Sat, 23 Jul 2011 12:29:52 +0200
parents ab545a15d807
children 2aa3e07b2f07
files mercurial/posix.py mercurial/util.py mercurial/windows.py tests/test-check-pyflakes.t
diffstat 4 files changed, 55 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/posix.py	Sat Jul 23 14:33:35 2011 -0500
+++ b/mercurial/posix.py	Sat Jul 23 12:29:52 2011 +0200
@@ -348,3 +348,6 @@
     child process under Windows, unneeded on other systems.
     """
     pass
+
+def executablepath():
+    return None # available on Windows only
--- a/mercurial/util.py	Sat Jul 23 14:33:35 2011 -0500
+++ b/mercurial/util.py	Sat Jul 23 12:29:52 2011 +0200
@@ -20,9 +20,54 @@
 import imp, socket, urllib
 
 if os.name == 'nt':
-    from windows import *
+    import windows as platform
 else:
-    from posix import *
+    import posix as platform
+
+checkexec = platform.checkexec
+checklink = platform.checklink
+executablepath = platform.executablepath
+expandglobs = platform.expandglobs
+explainexit = platform.explainexit
+findexe = platform.findexe
+gethgcmd = platform.gethgcmd
+getuser = platform.getuser
+groupmembers = platform.groupmembers
+groupname = platform.groupname
+hidewindow = platform.hidewindow
+isexec = platform.isexec
+isowner = platform.isowner
+localpath = platform.localpath
+lookupreg = platform.lookupreg
+makedir = platform.makedir
+nlinks = platform.nlinks
+normpath = platform.normpath
+nulldev = platform.nulldev
+openhardlinks = platform.openhardlinks
+oslink = platform.oslink
+parsepatchoutput = platform.parsepatchoutput
+pconvert = platform.pconvert
+popen = platform.popen
+posixfile = platform.posixfile
+quotecommand = platform.quotecommand
+realpath = platform.realpath
+rename = platform.rename
+samedevice = platform.samedevice
+samefile = platform.samefile
+samestat = platform.samestat
+setbinary = platform.setbinary
+setflags = platform.setflags
+setsignalhandler = platform.setsignalhandler
+shellquote = platform.shellquote
+spawndetached = platform.spawndetached
+sshargs = platform.sshargs
+statfiles = platform.statfiles
+termwidth = platform.termwidth
+testpid = platform.testpid
+umask = platform.umask
+unlink = platform.unlink
+unlinkpath = platform.unlinkpath
+username = platform.username
 
 # Python compatibility
 
@@ -482,6 +527,8 @@
 
 if os.name == 'nt':
     checkosfilename = checkwinfilename
+else:
+    checkosfilename = platform.checkosfilename
 
 def makelock(info, pathname):
     try:
--- a/mercurial/windows.py	Sat Jul 23 14:33:35 2011 -0500
+++ b/mercurial/windows.py	Sat Jul 23 12:29:52 2011 +0200
@@ -281,6 +281,9 @@
     # Don't support groups on Windows for now
     raise KeyError()
 
+def isexec(f):
+    return False
+
 from win32 import *
 
 expandglobs = True
--- a/tests/test-check-pyflakes.t	Sat Jul 23 14:33:35 2011 -0500
+++ b/tests/test-check-pyflakes.t	Sat Jul 23 12:29:52 2011 +0200
@@ -7,8 +7,6 @@
   mercurial/commands.py:*: 'mpatch' imported but unused (glob)
   mercurial/commands.py:*: 'osutil' imported but unused (glob)
   hgext/inotify/linux/__init__.py:*: 'from _inotify import *' used; unable to detect undefined names (glob)
-  mercurial/util.py:*: 'from posix import *' used; unable to detect undefined names (glob)
   mercurial/windows.py:*: 'from win32 import *' used; unable to detect undefined names (glob)
-  mercurial/util.py:*: 'from windows import *' used; unable to detect undefined names (glob)