comparison mercurial/manifest.py @ 32252:d67991c4fefe

treemanifest: allow manifestrevlog to take an explicit treemanifest arg Previously we relied on the opener options to tell the revlog to be a tree manifest. This makes it complicated for extensions to create treemanifests and normal manifests at the same time. Let's add a construtor argument to create a treemanifest revlog as well. I considered removing the options['treemanifest'] logic from manifestrevlog entirely, but doing so shifts the responsibility to the caller which ends up requiring changes in localrepo, bundlerepo, and unionrepo. I figured having the dual mechanism was better than polluting other parts of the code base with treemanifest knowledge.
author Durham Goode <durham@fb.com>
date Tue, 09 May 2017 13:56:46 -0700
parents 9d3136638784
children df448de7cf3b
comparison
equal deleted inserted replaced
32251:a04f5c651e52 32252:d67991c4fefe
1173 1173
1174 class manifestrevlog(revlog.revlog): 1174 class manifestrevlog(revlog.revlog):
1175 '''A revlog that stores manifest texts. This is responsible for caching the 1175 '''A revlog that stores manifest texts. This is responsible for caching the
1176 full-text manifest contents. 1176 full-text manifest contents.
1177 ''' 1177 '''
1178 def __init__(self, opener, dir='', dirlogcache=None, indexfile=None): 1178 def __init__(self, opener, dir='', dirlogcache=None, indexfile=None,
1179 treemanifest=False):
1179 """Constructs a new manifest revlog 1180 """Constructs a new manifest revlog
1180 1181
1181 `indexfile` - used by extensions to have two manifests at once, like 1182 `indexfile` - used by extensions to have two manifests at once, like
1182 when transitioning between flatmanifeset and treemanifests. 1183 when transitioning between flatmanifeset and treemanifests.
1184
1185 `treemanifest` - used to indicate this is a tree manifest revlog. Opener
1186 options can also be used to make this a tree manifest revlog. The opener
1187 option takes precedence, so if it is set to True, we ignore whatever
1188 value is passed in to the constructor.
1183 """ 1189 """
1184 # During normal operations, we expect to deal with not more than four 1190 # During normal operations, we expect to deal with not more than four
1185 # revs at a time (such as during commit --amend). When rebasing large 1191 # revs at a time (such as during commit --amend). When rebasing large
1186 # stacks of commits, the number can go up, hence the config knob below. 1192 # stacks of commits, the number can go up, hence the config knob below.
1187 cachesize = 4 1193 cachesize = 4
1188 usetreemanifest = False 1194 optiontreemanifest = False
1189 usemanifestv2 = False 1195 usemanifestv2 = False
1190 opts = getattr(opener, 'options', None) 1196 opts = getattr(opener, 'options', None)
1191 if opts is not None: 1197 if opts is not None:
1192 cachesize = opts.get('manifestcachesize', cachesize) 1198 cachesize = opts.get('manifestcachesize', cachesize)
1193 usetreemanifest = opts.get('treemanifest', usetreemanifest) 1199 optiontreemanifest = opts.get('treemanifest', False)
1194 usemanifestv2 = opts.get('manifestv2', usemanifestv2) 1200 usemanifestv2 = opts.get('manifestv2', usemanifestv2)
1195 1201
1196 self._treeondisk = usetreemanifest 1202 self._treeondisk = optiontreemanifest or treemanifest
1197 self._usemanifestv2 = usemanifestv2 1203 self._usemanifestv2 = usemanifestv2
1198 1204
1199 self._fulltextcache = util.lrucachedict(cachesize) 1205 self._fulltextcache = util.lrucachedict(cachesize)
1200 1206
1201 if dir: 1207 if dir:
1229 1235
1230 def dirlog(self, dir): 1236 def dirlog(self, dir):
1231 if dir: 1237 if dir:
1232 assert self._treeondisk 1238 assert self._treeondisk
1233 if dir not in self._dirlogcache: 1239 if dir not in self._dirlogcache:
1234 self._dirlogcache[dir] = manifestrevlog(self.opener, dir, 1240 mfrevlog = manifestrevlog(self.opener, dir,
1235 self._dirlogcache) 1241 self._dirlogcache,
1242 treemanifest=self._treeondisk)
1243 self._dirlogcache[dir] = mfrevlog
1236 return self._dirlogcache[dir] 1244 return self._dirlogcache[dir]
1237 1245
1238 def add(self, m, transaction, link, p1, p2, added, removed, readtree=None): 1246 def add(self, m, transaction, link, p1, p2, added, removed, readtree=None):
1239 if (p1 in self.fulltextcache and util.safehasattr(m, 'fastdelta') 1247 if (p1 in self.fulltextcache and util.safehasattr(m, 'fastdelta')
1240 and not self._usemanifestv2): 1248 and not self._usemanifestv2):