changeset 17726:7cb7e17c23b2

store: invoke "os.stat()" for "createmode" initialization via vfs This just replaces "os.stat()" invocation: refactoring around "self.createmode" and "vfs.createmode" initialization is omitted. This patch also newly adds "stat()" function to "abstractvfs".
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Tue, 09 Oct 2012 01:41:55 +0900
parents ffd589d4b785
children 6492b39a44d5
files mercurial/scmutil.py mercurial/store.py
diffstat 2 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/scmutil.py	Tue Oct 09 01:41:55 2012 +0900
+++ b/mercurial/scmutil.py	Tue Oct 09 01:41:55 2012 +0900
@@ -219,6 +219,9 @@
     def mkdir(self, path=None):
         return os.mkdir(self.join(path))
 
+    def stat(self, path=None):
+        return os.stat(self.join(path))
+
 class vfs(abstractvfs):
     '''Operate files relative to a base directory
 
--- a/mercurial/store.py	Tue Oct 09 01:41:55 2012 +0900
+++ b/mercurial/store.py	Tue Oct 09 01:41:55 2012 +0900
@@ -274,10 +274,10 @@
 def _plainhybridencode(f):
     return _hybridencode(f, False)
 
-def _calcmode(path):
+def _calcmode(vfs):
     try:
         # files in .hg/ will be created using this mode
-        mode = os.stat(path).st_mode
+        mode = vfs.stat().st_mode
             # avoid some useless chmods
         if (0777 & ~util.umask) == (0777 & mode):
             mode = None
@@ -293,7 +293,7 @@
     def __init__(self, path, vfstype):
         vfs = vfstype(path)
         self.path = vfs.base
-        self.createmode = _calcmode(path)
+        self.createmode = _calcmode(vfs)
         vfs.createmode = self.createmode
         self.vfs = scmutil.filtervfs(vfs, encodedir)
         self.opener = self.vfs
@@ -344,7 +344,7 @@
     def __init__(self, path, vfstype):
         vfs = vfstype(path + '/store')
         self.path = vfs.base
-        self.createmode = _calcmode(self.path)
+        self.createmode = _calcmode(vfs)
         vfs.createmode = self.createmode
         self.vfs = scmutil.filtervfs(vfs, encodefilename)
         self.opener = self.vfs
@@ -457,7 +457,7 @@
         vfs = vfstype(path + '/store')
         self.path = vfs.base
         self.pathsep = self.path + '/'
-        self.createmode = _calcmode(self.path)
+        self.createmode = _calcmode(vfs)
         vfs.createmode = self.createmode
         fnc = fncache(vfs)
         self.fncache = fnc