mercurial/manifest.py
changeset 38530 c82ea938efbb
parent 38510 561a450c7b64
child 38555 f2f9bacf0587
equal deleted inserted replaced
38529:1ad873c3e4a4 38530:c82ea938efbb
    19 from . import (
    19 from . import (
    20     error,
    20     error,
    21     mdiff,
    21     mdiff,
    22     policy,
    22     policy,
    23     pycompat,
    23     pycompat,
       
    24     repository,
    24     revlog,
    25     revlog,
    25     util,
    26     util,
       
    27 )
       
    28 from .utils import (
       
    29     interfaceutil,
    26 )
    30 )
    27 
    31 
    28 parsers = policy.importmod(r'parsers')
    32 parsers = policy.importmod(r'parsers')
    29 propertycache = util.propertycache
    33 propertycache = util.propertycache
    30 
    34 
   361 try:
   365 try:
   362     _lazymanifest = parsers.lazymanifest
   366     _lazymanifest = parsers.lazymanifest
   363 except AttributeError:
   367 except AttributeError:
   364     pass
   368     pass
   365 
   369 
       
   370 @interfaceutil.implementer(repository.imanifestdict)
   366 class manifestdict(object):
   371 class manifestdict(object):
   367     def __init__(self, data=''):
   372     def __init__(self, data=''):
   368         self._lm = _lazymanifest(data)
   373         self._lm = _lazymanifest(data)
   369 
   374 
   370     def __getitem__(self, key):
   375     def __getitem__(self, key):
  1260 
  1265 
  1261         # Save nodeid so parent manifest can calculate its nodeid
  1266         # Save nodeid so parent manifest can calculate its nodeid
  1262         m.setnode(n)
  1267         m.setnode(n)
  1263         return n
  1268         return n
  1264 
  1269 
       
  1270 @interfaceutil.implementer(repository.imanifestlog)
  1265 class manifestlog(object):
  1271 class manifestlog(object):
  1266     """A collection class representing the collection of manifest snapshots
  1272     """A collection class representing the collection of manifest snapshots
  1267     referenced by commits in the repository.
  1273     referenced by commits in the repository.
  1268 
  1274 
  1269     In this situation, 'manifest' refers to the abstract concept of a snapshot
  1275     In this situation, 'manifest' refers to the abstract concept of a snapshot
  1340 
  1346 
  1341     def clearcaches(self):
  1347     def clearcaches(self):
  1342         self._dirmancache.clear()
  1348         self._dirmancache.clear()
  1343         self._revlog.clearcaches()
  1349         self._revlog.clearcaches()
  1344 
  1350 
       
  1351 @interfaceutil.implementer(repository.imanifestrevisionwritable)
  1345 class memmanifestctx(object):
  1352 class memmanifestctx(object):
  1346     def __init__(self, manifestlog):
  1353     def __init__(self, manifestlog):
  1347         self._manifestlog = manifestlog
  1354         self._manifestlog = manifestlog
  1348         self._manifestdict = manifestdict()
  1355         self._manifestdict = manifestdict()
  1349 
  1356 
  1363 
  1370 
  1364     def write(self, transaction, link, p1, p2, added, removed):
  1371     def write(self, transaction, link, p1, p2, added, removed):
  1365         return self._revlog().add(self._manifestdict, transaction, link, p1, p2,
  1372         return self._revlog().add(self._manifestdict, transaction, link, p1, p2,
  1366                                   added, removed)
  1373                                   added, removed)
  1367 
  1374 
       
  1375 @interfaceutil.implementer(repository.imanifestrevisionstored)
  1368 class manifestctx(object):
  1376 class manifestctx(object):
  1369     """A class representing a single revision of a manifest, including its
  1377     """A class representing a single revision of a manifest, including its
  1370     contents, its parent revs, and its linkrev.
  1378     contents, its parent revs, and its linkrev.
  1371     """
  1379     """
  1372     def __init__(self, manifestlog, node):
  1380     def __init__(self, manifestlog, node):
  1439         return manifestdict(d)
  1447         return manifestdict(d)
  1440 
  1448 
  1441     def find(self, key):
  1449     def find(self, key):
  1442         return self.read().find(key)
  1450         return self.read().find(key)
  1443 
  1451 
       
  1452 @interfaceutil.implementer(repository.imanifestrevisionwritable)
  1444 class memtreemanifestctx(object):
  1453 class memtreemanifestctx(object):
  1445     def __init__(self, manifestlog, dir=''):
  1454     def __init__(self, manifestlog, dir=''):
  1446         self._manifestlog = manifestlog
  1455         self._manifestlog = manifestlog
  1447         self._dir = dir
  1456         self._dir = dir
  1448         self._treemanifest = treemanifest()
  1457         self._treemanifest = treemanifest()
  1465         def readtree(dir, node):
  1474         def readtree(dir, node):
  1466             return self._manifestlog.get(dir, node).read()
  1475             return self._manifestlog.get(dir, node).read()
  1467         return self._revlog().add(self._treemanifest, transaction, link, p1, p2,
  1476         return self._revlog().add(self._treemanifest, transaction, link, p1, p2,
  1468                                   added, removed, readtree=readtree)
  1477                                   added, removed, readtree=readtree)
  1469 
  1478 
       
  1479 @interfaceutil.implementer(repository.imanifestrevisionstored)
  1470 class treemanifestctx(object):
  1480 class treemanifestctx(object):
  1471     def __init__(self, manifestlog, dir, node):
  1481     def __init__(self, manifestlog, dir, node):
  1472         self._manifestlog = manifestlog
  1482         self._manifestlog = manifestlog
  1473         self._dir = dir
  1483         self._dir = dir
  1474         self._data = None
  1484         self._data = None