mercurial/manifest.py
changeset 29941 1cc93a154723
parent 29940 fa145a205a7f
child 29959 483003c27938
equal deleted inserted replaced
29940:fa145a205a7f 29941:1cc93a154723
   894 
   894 
   895 class manifestrevlog(revlog.revlog):
   895 class manifestrevlog(revlog.revlog):
   896     '''A revlog that stores manifest texts. This is responsible for caching the
   896     '''A revlog that stores manifest texts. This is responsible for caching the
   897     full-text manifest contents.
   897     full-text manifest contents.
   898     '''
   898     '''
   899     def __init__(self, opener, dir=''):
   899     def __init__(self, opener, dir='', dirlogcache=None):
   900         # During normal operations, we expect to deal with not more than four
   900         # During normal operations, we expect to deal with not more than four
   901         # revs at a time (such as during commit --amend). When rebasing large
   901         # revs at a time (such as during commit --amend). When rebasing large
   902         # stacks of commits, the number can go up, hence the config knob below.
   902         # stacks of commits, the number can go up, hence the config knob below.
   903         cachesize = 4
   903         cachesize = 4
   904         usetreemanifest = False
   904         usetreemanifest = False
   919             assert self._treeondisk, 'opts is %r' % opts
   919             assert self._treeondisk, 'opts is %r' % opts
   920             if not dir.endswith('/'):
   920             if not dir.endswith('/'):
   921                 dir = dir + '/'
   921                 dir = dir + '/'
   922             indexfile = "meta/" + dir + "00manifest.i"
   922             indexfile = "meta/" + dir + "00manifest.i"
   923         self._dir = dir
   923         self._dir = dir
       
   924         # The dirlogcache is kept on the root manifest log
       
   925         if dir:
       
   926             self._dirlogcache = dirlogcache
       
   927         else:
       
   928             self._dirlogcache = {'': self}
   924 
   929 
   925         super(manifestrevlog, self).__init__(opener, indexfile)
   930         super(manifestrevlog, self).__init__(opener, indexfile)
   926 
   931 
   927     @property
   932     @property
   928     def fulltextcache(self):
   933     def fulltextcache(self):
   929         return self._fulltextcache
   934         return self._fulltextcache
   930 
   935 
   931     def clearcaches(self):
   936     def clearcaches(self):
   932         super(manifestrevlog, self).clearcaches()
   937         super(manifestrevlog, self).clearcaches()
   933         self._fulltextcache.clear()
   938         self._fulltextcache.clear()
       
   939         self._dirlogcache = {'': self}
       
   940 
       
   941     def dirlog(self, dir):
       
   942         if dir:
       
   943             assert self._treeondisk
       
   944         if dir not in self._dirlogcache:
       
   945             self._dirlogcache[dir] = manifestrevlog(self.opener, dir,
       
   946                                                     self._dirlogcache)
       
   947         return self._dirlogcache[dir]
   934 
   948 
   935 class manifestlog(object):
   949 class manifestlog(object):
   936     """A collection class representing the collection of manifest snapshots
   950     """A collection class representing the collection of manifest snapshots
   937     referenced by commits in the repository.
   951     referenced by commits in the repository.
   938 
   952 
  1113         if opts is not None:
  1127         if opts is not None:
  1114             cachesize = opts.get('manifestcachesize', cachesize)
  1128             cachesize = opts.get('manifestcachesize', cachesize)
  1115             usetreemanifest = opts.get('treemanifest', usetreemanifest)
  1129             usetreemanifest = opts.get('treemanifest', usetreemanifest)
  1116         self._mancache = util.lrucachedict(cachesize)
  1130         self._mancache = util.lrucachedict(cachesize)
  1117         self._treeinmem = usetreemanifest
  1131         self._treeinmem = usetreemanifest
  1118         super(manifest, self).__init__(opener, dir=dir)
  1132         super(manifest, self).__init__(opener, dir=dir, dirlogcache=dirlogcache)
  1119         # The dirlogcache is kept on the root manifest log
       
  1120         if dir:
       
  1121             self._dirlogcache = dirlogcache
       
  1122         else:
       
  1123             self._dirlogcache = {'': self}
       
  1124 
  1133 
  1125     def _newmanifest(self, data=''):
  1134     def _newmanifest(self, data=''):
  1126         if self._treeinmem:
  1135         if self._treeinmem:
  1127             return treemanifest(self._dir, data)
  1136             return treemanifest(self._dir, data)
  1128         return manifestdict(data)
  1137         return manifestdict(data)
  1129 
  1138 
  1130     def dirlog(self, dir):
  1139     def dirlog(self, dir):
       
  1140         """This overrides the base revlog implementation to allow construction
       
  1141         'manifest' types instead of manifestrevlog types. This is only needed
       
  1142         until we migrate off the 'manifest' type."""
  1131         if dir:
  1143         if dir:
  1132             assert self._treeondisk
  1144             assert self._treeondisk
  1133         if dir not in self._dirlogcache:
  1145         if dir not in self._dirlogcache:
  1134             self._dirlogcache[dir] = manifest(self.opener, dir,
  1146             self._dirlogcache[dir] = manifest(self.opener, dir,
  1135                                               self._dirlogcache)
  1147                                               self._dirlogcache)
  1280         return n
  1292         return n
  1281 
  1293 
  1282     def clearcaches(self):
  1294     def clearcaches(self):
  1283         super(manifest, self).clearcaches()
  1295         super(manifest, self).clearcaches()
  1284         self._mancache.clear()
  1296         self._mancache.clear()
  1285         self._dirlogcache = {'': self}