[PATCH 4 of 9] store: initialize vfs field first to use it for initialization of others

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Mon Oct 8 12:06:14 CDT 2012


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1349714515 -32400
# Node ID 6874c01dafdb6ea259b9f4649f522cb5fb005cd4
# Parent  78af21a7663ffa9828bc52c6a6bd1ff516eaa4f8
store: initialize vfs field first to use it for initialization of others

This patch initializes "vfs" field in the constructor of each store
classes to use it for initialization of others.

In this patch, "self.vfs.base" is used to initialize "self.path",
because redo join of path components for "self.path" is redundant.

diff -r 78af21a7663f -r 6874c01dafdb 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
@@ -291,9 +291,9 @@
 class basicstore(object):
     '''base class for local repository stores'''
     def __init__(self, path, vfstype):
-        self.path = path
+        vfs = vfstype(path)
+        self.path = vfs.base
         self.createmode = _calcmode(path)
-        vfs = vfstype(self.path)
         vfs.createmode = self.createmode
         self.vfs = scmutil.filtervfs(vfs, encodedir)
         self.opener = self.vfs
@@ -342,9 +342,9 @@
 
 class encodedstore(basicstore):
     def __init__(self, path, vfstype):
-        self.path = path + '/store'
+        vfs = vfstype(path + '/store')
+        self.path = vfs.base
         self.createmode = _calcmode(self.path)
-        vfs = vfstype(self.path)
         vfs.createmode = self.createmode
         self.vfs = scmutil.filtervfs(vfs, encodefilename)
         self.opener = self.vfs
@@ -448,10 +448,10 @@
         else:
             encode = _plainhybridencode
         self.encode = encode
-        self.path = path + '/store'
+        vfs = vfstype(path + '/store')
+        self.path = vfs.base
         self.pathsep = self.path + '/'
         self.createmode = _calcmode(self.path)
-        vfs = vfstype(self.path)
         vfs.createmode = self.createmode
         fnc = fncache(vfs)
         self.fncache = fnc


More information about the Mercurial-devel mailing list