##// END OF EJS Templates
store: simplify class hierarchy
Matt Mackall -
r6898:69aeaaaf default
parent child Browse files
Show More
@@ -47,19 +47,24 b' def _dirwalk(path, recurse):'
47 47 elif kind == stat.S_IFREG:
48 48 yield pe, st.st_size
49 49
50 class _store:
51 '''base class for local repository stores'''
52 def __init__(self, path):
53 self.path = path
50 def _calcmode(path):
54 51 try:
55 52 # files in .hg/ will be created using this mode
56 mode = os.stat(self.path).st_mode
53 mode = os.stat(path).st_mode
57 54 # avoid some useless chmods
58 55 if (0777 & ~util._umask) == (0777 & mode):
59 56 mode = None
60 57 except OSError:
61 58 mode = None
62 self.createmode = mode
59 return mode
60
61 class basicstore:
62 '''base class for local repository stores'''
63 def __init__(self, path, opener):
64 self.path = path
65 self.createmode = _calcmode(path)
66 self.opener = opener(self.path)
67 self.opener.createmode = self.createmode
63 68
64 69 def join(self, f):
65 70 return os.path.join(self.path, f)
@@ -93,15 +98,10 b' class _store:'
93 98 for x in meta:
94 99 yield x
95 100
96 class directstore(_store):
101 class encodedstore(basicstore):
97 102 def __init__(self, path, opener):
98 _store.__init__(self, path)
99 self.opener = opener(self.path)
100 self.opener.createmode = self.createmode
101
102 class encodedstore(_store):
103 def __init__(self, path, opener):
104 _store.__init__(self, os.path.join(path, 'store'))
103 self.path = os.path.join(path, 'store')
104 self.createmode = _calcmode(self.path)
105 105 self.encodefn = encodefilename
106 106 op = opener(self.path)
107 107 op.createmode = self.createmode
@@ -120,7 +120,6 b' class encodedstore(_store):'
120 120 return os.path.join(self.path, self.encodefn(f))
121 121
122 122 def store(requirements, path, opener):
123 if 'store' not in requirements:
124 return directstore(path, opener)
125 else:
123 if 'store' in requirements:
126 124 return encodedstore(path, opener)
125 return basicstore(path, opener)
@@ -23,4 +23,4 b' echo'
23 23 echo % verify
24 24 hg verify
25 25
26 return 0
26 exit 0
General Comments 0
You need to be logged in to leave comments. Login now