[PATHC] util: don't overwrite os-specific functions with general ones

Sune Foldager cryo at cyanite.org
Sun Apr 5 02:55:25 CDT 2009


On 04/04/2009, at 18.40, Matt Mackall wrote:

> Looks fine.

Thanks. Not sure if I should do anything else with respect to the  
patch? I rebased it to crew tip anway.

> Can't work. We need things like posixfile to get defined. Ideally the
> import would be at the top, but that doesn't allow windows or posix to
> override things.

Right; I didn't consider that.

-- 
Sune.


# HG changeset patch
# User Sune Foldager <cryo at cyanite.org>
# Date 1238861563 -7200
# Node ID 3cba6fa5e505cff38fb0403b648d24868fa8d132
# Parent  7b813bdbd5d072285af45e15cb95b80fd29268fa
util: don't overwrite os-specific functions with general ones

diff -r 7b813bdbd5d0 -r 3cba6fa5e505 mercurial/util.py
--- a/mercurial/util.py	Sat Apr 04 21:09:43 2009 +0200
+++ b/mercurial/util.py	Sat Apr 04 18:12:43 2009 +0200
@@ -776,6 +776,19 @@
          # want to add "foo/bar/baz" before checking if there's a  
"foo/.hg"
          self.auditeddir.update(prefixes)

+def nlinks(pathname):
+    """Return number of hardlinks for the given file."""
+    return os.lstat(pathname).st_nlink
+
+if hasattr(os, 'link'):
+    os_link = os.link
+else:
+    def os_link(src, dst):
+        raise OSError(0, _("Hardlinks not supported"))
+
+def lookup_reg(key, name=None, scope=None):
+    return None
+
  if os.name == 'nt':
      from windows import *
      def expand_glob(pats):
@@ -817,16 +830,6 @@
          pass
      return posixfile(pathname).read()

-def nlinks(pathname):
-    """Return number of hardlinks for the given file."""
-    return os.lstat(pathname).st_nlink
-
-if hasattr(os, 'link'):
-    os_link = os.link
-else:
-    def os_link(src, dst):
-        raise OSError(0, _("Hardlinks not supported"))
-
  def fstat(fp):
      '''stat file object that may not have fileno method.'''
      try:
@@ -962,8 +965,6 @@
      '''Are we running in a GUI?'''
      return os.name == "nt" or os.name == "mac" or  
os.environ.get("DISPLAY")

-def lookup_reg(key, name=None, scope=None):
-    return None

  def mktempcopy(name, emptyok=False, createmode=None):
      """Create a temporary file with the same contents from name



More information about the Mercurial-devel mailing list