Show More
@@ -115,9 +115,7 b' class statichttprepository(localrepo.loc' | |||||
115 | raise error.RepoError(_("requirement '%s' not supported") % r) |
|
115 | raise error.RepoError(_("requirement '%s' not supported") % r) | |
116 |
|
116 | |||
117 | # setup store |
|
117 | # setup store | |
118 | def pjoin(a, b): |
|
118 | self.store = store.store(requirements, self.path, opener) | |
119 | return a + '/' + b |
|
|||
120 | self.store = store.store(requirements, self.path, opener, pjoin) |
|
|||
121 | self.spath = self.store.path |
|
119 | self.spath = self.store.path | |
122 | self.sopener = self.store.opener |
|
120 | self.sopener = self.store.opener | |
123 | self.sjoin = self.store.join |
|
121 | self.sjoin = self.store.join |
@@ -169,8 +169,7 b' def _calcmode(path):' | |||||
169 |
|
169 | |||
170 | class basicstore(object): |
|
170 | class basicstore(object): | |
171 | '''base class for local repository stores''' |
|
171 | '''base class for local repository stores''' | |
172 |
def __init__(self, path, opener |
|
172 | def __init__(self, path, opener): | |
173 | self.pathjoiner = pathjoiner |
|
|||
174 | self.path = path |
|
173 | self.path = path | |
175 | self.createmode = _calcmode(path) |
|
174 | self.createmode = _calcmode(path) | |
176 | op = opener(self.path) |
|
175 | op = opener(self.path) | |
@@ -178,19 +177,21 b' class basicstore(object):' | |||||
178 | self.opener = lambda f, *args, **kw: op(encodedir(f), *args, **kw) |
|
177 | self.opener = lambda f, *args, **kw: op(encodedir(f), *args, **kw) | |
179 |
|
178 | |||
180 | def join(self, f): |
|
179 | def join(self, f): | |
181 |
return self. |
|
180 | return self.path + '/' + encodedir(f) | |
182 |
|
181 | |||
183 | def _walk(self, relpath, recurse): |
|
182 | def _walk(self, relpath, recurse): | |
184 | '''yields (unencoded, encoded, size)''' |
|
183 | '''yields (unencoded, encoded, size)''' | |
185 |
path = self. |
|
184 | path = self.path | |
186 | striplen = len(self.path) + len(os.sep) |
|
185 | if relpath: | |
|
186 | path += '/' + relpath | |||
|
187 | striplen = len(self.path) + 1 | |||
187 | l = [] |
|
188 | l = [] | |
188 | if os.path.isdir(path): |
|
189 | if os.path.isdir(path): | |
189 | visit = [path] |
|
190 | visit = [path] | |
190 | while visit: |
|
191 | while visit: | |
191 | p = visit.pop() |
|
192 | p = visit.pop() | |
192 | for f, kind, st in osutil.listdir(p, stat=True): |
|
193 | for f, kind, st in osutil.listdir(p, stat=True): | |
193 |
fp = |
|
194 | fp = p + '/' + f | |
194 | if kind == stat.S_IFREG and f[-2:] in ('.d', '.i'): |
|
195 | if kind == stat.S_IFREG and f[-2:] in ('.d', '.i'): | |
195 | n = util.pconvert(fp[striplen:]) |
|
196 | n = util.pconvert(fp[striplen:]) | |
196 | l.append((decodedir(n), n, st.st_size)) |
|
197 | l.append((decodedir(n), n, st.st_size)) | |
@@ -217,9 +218,8 b' class basicstore(object):' | |||||
217 | pass |
|
218 | pass | |
218 |
|
219 | |||
219 | class encodedstore(basicstore): |
|
220 | class encodedstore(basicstore): | |
220 |
def __init__(self, path, opener |
|
221 | def __init__(self, path, opener): | |
221 |
self.path |
|
222 | self.path = path + '/store' | |
222 | self.path = self.pathjoiner(path, 'store') |
|
|||
223 | self.createmode = _calcmode(self.path) |
|
223 | self.createmode = _calcmode(self.path) | |
224 | op = opener(self.path) |
|
224 | op = opener(self.path) | |
225 | op.createmode = self.createmode |
|
225 | op.createmode = self.createmode | |
@@ -234,11 +234,11 b' class encodedstore(basicstore):' | |||||
234 | yield a, b, size |
|
234 | yield a, b, size | |
235 |
|
235 | |||
236 | def join(self, f): |
|
236 | def join(self, f): | |
237 |
return self. |
|
237 | return self.path + '/' + encodefilename(f) | |
238 |
|
238 | |||
239 | def copylist(self): |
|
239 | def copylist(self): | |
240 | return (['requires', '00changelog.i'] + |
|
240 | return (['requires', '00changelog.i'] + | |
241 |
[ |
|
241 | ['store/' + f for f in _data.split()]) | |
242 |
|
242 | |||
243 | class fncache(object): |
|
243 | class fncache(object): | |
244 | # the filename used to be partially encoded |
|
244 | # the filename used to be partially encoded | |
@@ -299,10 +299,9 b' class fncache(object):' | |||||
299 | return iter(self.entries) |
|
299 | return iter(self.entries) | |
300 |
|
300 | |||
301 | class fncachestore(basicstore): |
|
301 | class fncachestore(basicstore): | |
302 |
def __init__(self, path, opener, |
|
302 | def __init__(self, path, opener, encode): | |
303 | self.encode = encode |
|
303 | self.encode = encode | |
304 |
self.path |
|
304 | self.path = path + '/store' | |
305 | self.path = self.pathjoiner(path, 'store') |
|
|||
306 | self.createmode = _calcmode(self.path) |
|
305 | self.createmode = _calcmode(self.path) | |
307 | op = opener(self.path) |
|
306 | op = opener(self.path) | |
308 | op.createmode = self.createmode |
|
307 | op.createmode = self.createmode | |
@@ -316,17 +315,16 b' class fncachestore(basicstore):' | |||||
316 | self.opener = fncacheopener |
|
315 | self.opener = fncacheopener | |
317 |
|
316 | |||
318 | def join(self, f): |
|
317 | def join(self, f): | |
319 |
return self. |
|
318 | return self.path + '/' + self.encode(f) | |
320 |
|
319 | |||
321 | def datafiles(self): |
|
320 | def datafiles(self): | |
322 | rewrite = False |
|
321 | rewrite = False | |
323 | existing = [] |
|
322 | existing = [] | |
324 | pjoin = self.pathjoiner |
|
|||
325 | spath = self.path |
|
323 | spath = self.path | |
326 | for f in self.fncache: |
|
324 | for f in self.fncache: | |
327 | ef = self.encode(f) |
|
325 | ef = self.encode(f) | |
328 | try: |
|
326 | try: | |
329 |
st = os.stat( |
|
327 | st = os.stat(spath + '/' + ef) | |
330 | yield f, ef, st.st_size |
|
328 | yield f, ef, st.st_size | |
331 | existing.append(f) |
|
329 | existing.append(f) | |
332 | except OSError: |
|
330 | except OSError: | |
@@ -341,17 +339,16 b' class fncachestore(basicstore):' | |||||
341 | d = ('data dh fncache' |
|
339 | d = ('data dh fncache' | |
342 | ' 00manifest.d 00manifest.i 00changelog.d 00changelog.i') |
|
340 | ' 00manifest.d 00manifest.i 00changelog.d 00changelog.i') | |
343 | return (['requires', '00changelog.i'] + |
|
341 | return (['requires', '00changelog.i'] + | |
344 |
[ |
|
342 | ['store/' + f for f in d.split()]) | |
345 |
|
343 | |||
346 | def write(self): |
|
344 | def write(self): | |
347 | self.fncache.write() |
|
345 | self.fncache.write() | |
348 |
|
346 | |||
349 |
def store(requirements, path, opener |
|
347 | def store(requirements, path, opener): | |
350 | pathjoiner = pathjoiner or os.path.join |
|
|||
351 | if 'store' in requirements: |
|
348 | if 'store' in requirements: | |
352 | if 'fncache' in requirements: |
|
349 | if 'fncache' in requirements: | |
353 | auxencode = lambda f: _auxencode(f, 'dotencode' in requirements) |
|
350 | auxencode = lambda f: _auxencode(f, 'dotencode' in requirements) | |
354 | encode = lambda f: _hybridencode(f, auxencode) |
|
351 | encode = lambda f: _hybridencode(f, auxencode) | |
355 |
return fncachestore(path, opener, |
|
352 | return fncachestore(path, opener, encode) | |
356 |
return encodedstore(path, opener |
|
353 | return encodedstore(path, opener) | |
357 |
return basicstore(path, opener |
|
354 | return basicstore(path, opener) |
General Comments 0
You need to be logged in to leave comments.
Login now