mercurial/store.py
changeset 17651 3b49c28658f6
parent 17649 f65c6a5f256c
child 17652 2c6f7231becc
equal deleted inserted replaced
17650:bf2eb3a126d2 17651:3b49c28658f6
   286 _data = ('data 00manifest.d 00manifest.i 00changelog.d 00changelog.i'
   286 _data = ('data 00manifest.d 00manifest.i 00changelog.d 00changelog.i'
   287          ' phaseroots obsstore')
   287          ' phaseroots obsstore')
   288 
   288 
   289 class basicstore(object):
   289 class basicstore(object):
   290     '''base class for local repository stores'''
   290     '''base class for local repository stores'''
   291     def __init__(self, path, openertype):
   291     def __init__(self, path, vfstype):
   292         self.path = path
   292         self.path = path
   293         self.createmode = _calcmode(path)
   293         self.createmode = _calcmode(path)
   294         op = openertype(self.path)
   294         op = vfstype(self.path)
   295         op.createmode = self.createmode
   295         op.createmode = self.createmode
   296         self.opener = scmutil.filteropener(op, encodedir)
   296         self.opener = scmutil.filteropener(op, encodedir)
   297 
   297 
   298     def join(self, f):
   298     def join(self, f):
   299         return self.path + '/' + encodedir(f)
   299         return self.path + '/' + encodedir(f)
   336 
   336 
   337     def write(self):
   337     def write(self):
   338         pass
   338         pass
   339 
   339 
   340 class encodedstore(basicstore):
   340 class encodedstore(basicstore):
   341     def __init__(self, path, openertype):
   341     def __init__(self, path, vfstype):
   342         self.path = path + '/store'
   342         self.path = path + '/store'
   343         self.createmode = _calcmode(self.path)
   343         self.createmode = _calcmode(self.path)
   344         op = openertype(self.path)
   344         op = vfstype(self.path)
   345         op.createmode = self.createmode
   345         op.createmode = self.createmode
   346         self.opener = scmutil.filteropener(op, encodefilename)
   346         self.opener = scmutil.filteropener(op, encodefilename)
   347 
   347 
   348     def datafiles(self):
   348     def datafiles(self):
   349         for a, b, size in self._walk('data', True):
   349         for a, b, size in self._walk('data', True):
   436         if mode not in ('r', 'rb') and path.startswith('data/'):
   436         if mode not in ('r', 'rb') and path.startswith('data/'):
   437             self.fncache.add(path)
   437             self.fncache.add(path)
   438         return self.opener(self.encode(path), mode, *args, **kw)
   438         return self.opener(self.encode(path), mode, *args, **kw)
   439 
   439 
   440 class fncachestore(basicstore):
   440 class fncachestore(basicstore):
   441     def __init__(self, path, openertype, dotencode):
   441     def __init__(self, path, vfstype, dotencode):
   442         if dotencode:
   442         if dotencode:
   443             encode = _dothybridencode
   443             encode = _dothybridencode
   444         else:
   444         else:
   445             encode = _plainhybridencode
   445             encode = _plainhybridencode
   446         self.encode = encode
   446         self.encode = encode
   447         self.path = path + '/store'
   447         self.path = path + '/store'
   448         self.pathsep = self.path + '/'
   448         self.pathsep = self.path + '/'
   449         self.createmode = _calcmode(self.path)
   449         self.createmode = _calcmode(self.path)
   450         op = openertype(self.path)
   450         op = vfstype(self.path)
   451         op.createmode = self.createmode
   451         op.createmode = self.createmode
   452         fnc = fncache(op)
   452         fnc = fncache(op)
   453         self.fncache = fnc
   453         self.fncache = fnc
   454         self.opener = _fncachevfs(op, fnc, encode)
   454         self.opener = _fncachevfs(op, fnc, encode)
   455 
   455 
   484                 ['store/' + f for f in d.split()])
   484                 ['store/' + f for f in d.split()])
   485 
   485 
   486     def write(self):
   486     def write(self):
   487         self.fncache.write()
   487         self.fncache.write()
   488 
   488 
   489 def store(requirements, path, openertype):
   489 def store(requirements, path, vfstype):
   490     if 'store' in requirements:
   490     if 'store' in requirements:
   491         if 'fncache' in requirements:
   491         if 'fncache' in requirements:
   492             return fncachestore(path, openertype, 'dotencode' in requirements)
   492             return fncachestore(path, vfstype, 'dotencode' in requirements)
   493         return encodedstore(path, openertype)
   493         return encodedstore(path, vfstype)
   494     return basicstore(path, openertype)
   494     return basicstore(path, vfstype)