comparison mercurial/manifest.py @ 39235:43387fd2aa1f

manifest: rename dir to tree to avoid shadowing built-in And update the argument name in the imanifestlog interface. Differential Revision: https://phab.mercurial-scm.org/D4268
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 10 Aug 2018 11:00:06 -0700
parents 0a57945aaf7f
children aad4b46e89bb
comparison
equal deleted inserted replaced
39234:3682b49e0213 39235:43387fd2aa1f
1433 """Retrieves the manifest instance for the given node. Throws a 1433 """Retrieves the manifest instance for the given node. Throws a
1434 LookupError if not found. 1434 LookupError if not found.
1435 """ 1435 """
1436 return self.get('', node) 1436 return self.get('', node)
1437 1437
1438 def get(self, dir, node, verify=True): 1438 def get(self, tree, node, verify=True):
1439 """Retrieves the manifest instance for the given node. Throws a 1439 """Retrieves the manifest instance for the given node. Throws a
1440 LookupError if not found. 1440 LookupError if not found.
1441 1441
1442 `verify` - if True an exception will be thrown if the node is not in 1442 `verify` - if True an exception will be thrown if the node is not in
1443 the revlog 1443 the revlog
1444 """ 1444 """
1445 if node in self._dirmancache.get(dir, ()): 1445 if node in self._dirmancache.get(tree, ()):
1446 return self._dirmancache[dir][node] 1446 return self._dirmancache[tree][node]
1447 1447
1448 if not self._narrowmatch.always(): 1448 if not self._narrowmatch.always():
1449 if not self._narrowmatch.visitdir(dir[:-1] or '.'): 1449 if not self._narrowmatch.visitdir(tree[:-1] or '.'):
1450 return excludeddirmanifestctx(dir, node) 1450 return excludeddirmanifestctx(tree, node)
1451 if dir: 1451 if tree:
1452 if self._revlog._treeondisk: 1452 if self._revlog._treeondisk:
1453 if verify: 1453 if verify:
1454 dirlog = self._revlog.dirlog(dir) 1454 dirlog = self._revlog.dirlog(tree)
1455 if node not in dirlog.nodemap: 1455 if node not in dirlog.nodemap:
1456 raise LookupError(node, dirlog.indexfile, 1456 raise LookupError(node, dirlog.indexfile,
1457 _('no node')) 1457 _('no node'))
1458 m = treemanifestctx(self, dir, node) 1458 m = treemanifestctx(self, tree, node)
1459 else: 1459 else:
1460 raise error.Abort( 1460 raise error.Abort(
1461 _("cannot ask for manifest directory '%s' in a flat " 1461 _("cannot ask for manifest directory '%s' in a flat "
1462 "manifest") % dir) 1462 "manifest") % tree)
1463 else: 1463 else:
1464 if verify: 1464 if verify:
1465 if node not in self._revlog.nodemap: 1465 if node not in self._revlog.nodemap:
1466 raise LookupError(node, self._revlog.indexfile, 1466 raise LookupError(node, self._revlog.indexfile,
1467 _('no node')) 1467 _('no node'))
1469 m = treemanifestctx(self, '', node) 1469 m = treemanifestctx(self, '', node)
1470 else: 1470 else:
1471 m = manifestctx(self, node) 1471 m = manifestctx(self, node)
1472 1472
1473 if node != revlog.nullid: 1473 if node != revlog.nullid:
1474 mancache = self._dirmancache.get(dir) 1474 mancache = self._dirmancache.get(tree)
1475 if not mancache: 1475 if not mancache:
1476 mancache = util.lrucachedict(self._cachesize) 1476 mancache = util.lrucachedict(self._cachesize)
1477 self._dirmancache[dir] = mancache 1477 self._dirmancache[tree] = mancache
1478 mancache[node] = m 1478 mancache[node] = m
1479 return m 1479 return m
1480 1480
1481 def clearcaches(self, clear_persisted_data=False): 1481 def clearcaches(self, clear_persisted_data=False):
1482 self._dirmancache.clear() 1482 self._dirmancache.clear()