[PATCH 6 of 9] store: invoke "os.stat()" for "createmode" initialization via vfs
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Mon Oct 8 12:06:16 CDT 2012
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1349714515 -32400
# Node ID ef7a5af78db825a4e8f00f7f6a65d0b509a3eeb5
# Parent 4956dd12c3b003bb566fd29ba44a91e707626cc3
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".
diff -r 4956dd12c3b0 -r ef7a5af78db8 mercurial/scmutil.py
--- 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
diff -r 4956dd12c3b0 -r ef7a5af78db8 mercurial/store.py
--- 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
More information about the Mercurial-devel
mailing list