comparison mercurial/manifest.py @ 39243:0d97530eb535

manifest: rename dir argument and attribute to tree dir shadows a built-in. We use it throughout the manifest code, which is unfortunate. This commit updates just manifestrevlog to be more well behaved. .. api:: renamed manifest.manifestrevlog.__init__ dir argument to tree Differential Revision: https://phab.mercurial-scm.org/D4276
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 10 Aug 2018 14:44:50 -0700
parents 1347bcf52d51
children 73cf21b2e8a6
comparison
equal deleted inserted replaced
39242:1347bcf52d51 39243:0d97530eb535
1248 1248
1249 class manifestrevlog(revlog.revlog): 1249 class manifestrevlog(revlog.revlog):
1250 '''A revlog that stores manifest texts. This is responsible for caching the 1250 '''A revlog that stores manifest texts. This is responsible for caching the
1251 full-text manifest contents. 1251 full-text manifest contents.
1252 ''' 1252 '''
1253 def __init__(self, opener, dir='', dirlogcache=None, indexfile=None, 1253 def __init__(self, opener, tree='', dirlogcache=None, indexfile=None,
1254 treemanifest=False): 1254 treemanifest=False):
1255 """Constructs a new manifest revlog 1255 """Constructs a new manifest revlog
1256 1256
1257 `indexfile` - used by extensions to have two manifests at once, like 1257 `indexfile` - used by extensions to have two manifests at once, like
1258 when transitioning between flatmanifeset and treemanifests. 1258 when transitioning between flatmanifeset and treemanifests.
1274 1274
1275 self._treeondisk = optiontreemanifest or treemanifest 1275 self._treeondisk = optiontreemanifest or treemanifest
1276 1276
1277 self._fulltextcache = manifestfulltextcache(cachesize) 1277 self._fulltextcache = manifestfulltextcache(cachesize)
1278 1278
1279 if dir: 1279 if tree:
1280 assert self._treeondisk, 'opts is %r' % opts 1280 assert self._treeondisk, 'opts is %r' % opts
1281 1281
1282 if indexfile is None: 1282 if indexfile is None:
1283 indexfile = '00manifest.i' 1283 indexfile = '00manifest.i'
1284 if dir: 1284 if tree:
1285 indexfile = "meta/" + dir + indexfile 1285 indexfile = "meta/" + tree + indexfile
1286 1286
1287 self._dir = dir 1287 self._tree = tree
1288 # The dirlogcache is kept on the root manifest log 1288 # The dirlogcache is kept on the root manifest log
1289 if dir: 1289 if tree:
1290 self._dirlogcache = dirlogcache 1290 self._dirlogcache = dirlogcache
1291 else: 1291 else:
1292 self._dirlogcache = {'': self} 1292 self._dirlogcache = {'': self}
1293 1293
1294 super(manifestrevlog, self).__init__(opener, indexfile, 1294 super(manifestrevlog, self).__init__(opener, indexfile,
1295 # only root indexfile is cached 1295 # only root indexfile is cached
1296 checkambig=not bool(dir), 1296 checkambig=not bool(tree),
1297 mmaplargeindex=True) 1297 mmaplargeindex=True)
1298 1298
1299 def _setupmanifestcachehooks(self, repo): 1299 def _setupmanifestcachehooks(self, repo):
1300 """Persist the manifestfulltextcache on lock release""" 1300 """Persist the manifestfulltextcache on lock release"""
1301 if not util.safehasattr(repo, '_lockref'): 1301 if not util.safehasattr(repo, '_lockref'):
1323 return self._fulltextcache 1323 return self._fulltextcache
1324 1324
1325 def clearcaches(self, clear_persisted_data=False): 1325 def clearcaches(self, clear_persisted_data=False):
1326 super(manifestrevlog, self).clearcaches() 1326 super(manifestrevlog, self).clearcaches()
1327 self._fulltextcache.clear(clear_persisted_data=clear_persisted_data) 1327 self._fulltextcache.clear(clear_persisted_data=clear_persisted_data)
1328 self._dirlogcache = {self._dir: self} 1328 self._dirlogcache = {self._tree: self}
1329 1329
1330 def dirlog(self, d): 1330 def dirlog(self, d):
1331 if d: 1331 if d:
1332 assert self._treeondisk 1332 assert self._treeondisk
1333 if d not in self._dirlogcache: 1333 if d not in self._dirlogcache:
1358 # just encode a fulltext of the manifest and pass that 1358 # just encode a fulltext of the manifest and pass that
1359 # through to the revlog layer, and let it handle the delta 1359 # through to the revlog layer, and let it handle the delta
1360 # process. 1360 # process.
1361 if self._treeondisk: 1361 if self._treeondisk:
1362 assert readtree, "readtree must be set for treemanifest writes" 1362 assert readtree, "readtree must be set for treemanifest writes"
1363 m1 = readtree(self._dir, p1) 1363 m1 = readtree(self._tree, p1)
1364 m2 = readtree(self._dir, p2) 1364 m2 = readtree(self._tree, p2)
1365 n = self._addtree(m, transaction, link, m1, m2, readtree) 1365 n = self._addtree(m, transaction, link, m1, m2, readtree)
1366 arraytext = None 1366 arraytext = None
1367 else: 1367 else:
1368 text = m.text() 1368 text = m.text()
1369 n = self.addrevision(text, transaction, link, p1, p2) 1369 n = self.addrevision(text, transaction, link, p1, p2)
1375 return n 1375 return n
1376 1376
1377 def _addtree(self, m, transaction, link, m1, m2, readtree): 1377 def _addtree(self, m, transaction, link, m1, m2, readtree):
1378 # If the manifest is unchanged compared to one parent, 1378 # If the manifest is unchanged compared to one parent,
1379 # don't write a new revision 1379 # don't write a new revision
1380 if self._dir != '' and (m.unmodifiedsince(m1) or m.unmodifiedsince(m2)): 1380 if self._tree != '' and (m.unmodifiedsince(m1) or m.unmodifiedsince(
1381 m2)):
1381 return m.node() 1382 return m.node()
1382 def writesubtree(subm, subp1, subp2): 1383 def writesubtree(subm, subp1, subp2):
1383 sublog = self.dirlog(subm.dir()) 1384 sublog = self.dirlog(subm.dir())
1384 sublog.add(subm, transaction, link, subp1, subp2, None, None, 1385 sublog.add(subm, transaction, link, subp1, subp2, None, None,
1385 readtree=readtree) 1386 readtree=readtree)
1386 m.writesubtrees(m1, m2, writesubtree) 1387 m.writesubtrees(m1, m2, writesubtree)
1387 text = m.dirtext() 1388 text = m.dirtext()
1388 n = None 1389 n = None
1389 if self._dir != '': 1390 if self._tree != '':
1390 # Double-check whether contents are unchanged to one parent 1391 # Double-check whether contents are unchanged to one parent
1391 if text == m1.dirtext(): 1392 if text == m1.dirtext():
1392 n = m1.node() 1393 n = m1.node()
1393 elif text == m2.dirtext(): 1394 elif text == m2.dirtext():
1394 n = m2.node() 1395 n = m2.node()