[PATCH] util: move windows and posix wildcard imports to begin of file

Adrian Buehlmann adrian at cadifra.com
Thu Jul 21 04:54:44 CDT 2011


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1311239126 -7200
# Node ID 812684d6af83113b37f26f964fdaee87e9f74363
# Parent  6d1d0b9c4ecce74ed782d87fa7f10acd54c1c640
util: move windows and posix wildcard imports to begin of file

making it more explicit for people reading the code that definitions from
windows.py or posix.py are poured into the same namespace as util, hopefully
helping to prevent future accidental redefinitions (see de9eb6b1da4f)

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -19,6 +19,11 @@
 import os, time, calendar, textwrap, unicodedata, signal
 import imp, socket, urllib
 
+if os.name == 'nt':
+    from windows import *
+else:
+    from posix import *
+
 # Python compatibility
 
 def sha1(s):
@@ -487,6 +492,9 @@
             return _("filename ends with '%s', which is not allowed "
                      "on Windows") % t
 
+if os.name == 'nt':
+    checkosfilename = checkwinfilename
+
 def lookupreg(key, name=None, scope=None):
     return None
 
@@ -498,12 +506,6 @@
     """
     pass
 
-if os.name == 'nt':
-    checkosfilename = checkwinfilename
-    from windows import *
-else:
-    from posix import *
-
 def makelock(info, pathname):
     try:
         return os.symlink(info, pathname)


More information about the Mercurial-devel mailing list