##// END OF EJS Templates
manifest: proxy to revlog instance instead of inheriting...
Gregory Szorc -
r39350:7f5e6d3e default
parent child Browse files
Show More
@@ -1246,7 +1246,8 b' class manifestfulltextcache(util.lrucach'
1246 self.write()
1246 self.write()
1247 self._read = False
1247 self._read = False
1248
1248
1249 class manifestrevlog(revlog.revlog):
1249 @interfaceutil.implementer(repository.imanifeststorage)
1250 class manifestrevlog(object):
1250 '''A revlog that stores manifest texts. This is responsible for caching the
1251 '''A revlog that stores manifest texts. This is responsible for caching the
1251 full-text manifest contents.
1252 full-text manifest contents.
1252 '''
1253 '''
@@ -1291,10 +1292,14 b' class manifestrevlog(revlog.revlog):'
1291 else:
1292 else:
1292 self._dirlogcache = {'': self}
1293 self._dirlogcache = {'': self}
1293
1294
1294 super(manifestrevlog, self).__init__(opener, indexfile,
1295 self._revlog = revlog.revlog(opener, indexfile,
1295 # only root indexfile is cached
1296 # only root indexfile is cached
1296 checkambig=not bool(tree),
1297 checkambig=not bool(tree),
1297 mmaplargeindex=True)
1298 mmaplargeindex=True)
1299
1300 self.index = self._revlog.index
1301 self.version = self._revlog.version
1302 self._generaldelta = self._revlog._generaldelta
1298
1303
1299 def _setupmanifestcachehooks(self, repo):
1304 def _setupmanifestcachehooks(self, repo):
1300 """Persist the manifestfulltextcache on lock release"""
1305 """Persist the manifestfulltextcache on lock release"""
@@ -1323,7 +1328,7 b' class manifestrevlog(revlog.revlog):'
1323 return self._fulltextcache
1328 return self._fulltextcache
1324
1329
1325 def clearcaches(self, clear_persisted_data=False):
1330 def clearcaches(self, clear_persisted_data=False):
1326 super(manifestrevlog, self).clearcaches()
1331 self._revlog.clearcaches()
1327 self._fulltextcache.clear(clear_persisted_data=clear_persisted_data)
1332 self._fulltextcache.clear(clear_persisted_data=clear_persisted_data)
1328 self._dirlogcache = {self._tree: self}
1333 self._dirlogcache = {self._tree: self}
1329
1334
@@ -1350,9 +1355,10 b' class manifestrevlog(revlog.revlog):'
1350 [(x, True) for x in removed])
1355 [(x, True) for x in removed])
1351
1356
1352 arraytext, deltatext = m.fastdelta(self.fulltextcache[p1], work)
1357 arraytext, deltatext = m.fastdelta(self.fulltextcache[p1], work)
1353 cachedelta = self.rev(p1), deltatext
1358 cachedelta = self._revlog.rev(p1), deltatext
1354 text = util.buffer(arraytext)
1359 text = util.buffer(arraytext)
1355 n = self.addrevision(text, transaction, link, p1, p2, cachedelta)
1360 n = self._revlog.addrevision(text, transaction, link, p1, p2,
1361 cachedelta)
1356 else:
1362 else:
1357 # The first parent manifest isn't already loaded, so we'll
1363 # The first parent manifest isn't already loaded, so we'll
1358 # just encode a fulltext of the manifest and pass that
1364 # just encode a fulltext of the manifest and pass that
@@ -1366,7 +1372,7 b' class manifestrevlog(revlog.revlog):'
1366 arraytext = None
1372 arraytext = None
1367 else:
1373 else:
1368 text = m.text()
1374 text = m.text()
1369 n = self.addrevision(text, transaction, link, p1, p2)
1375 n = self._revlog.addrevision(text, transaction, link, p1, p2)
1370 arraytext = bytearray(text)
1376 arraytext = bytearray(text)
1371
1377
1372 if arraytext is not None:
1378 if arraytext is not None:
@@ -1395,12 +1401,90 b' class manifestrevlog(revlog.revlog):'
1395 n = m2.node()
1401 n = m2.node()
1396
1402
1397 if not n:
1403 if not n:
1398 n = self.addrevision(text, transaction, link, m1.node(), m2.node())
1404 n = self._revlog.addrevision(text, transaction, link, m1.node(),
1405 m2.node())
1399
1406
1400 # Save nodeid so parent manifest can calculate its nodeid
1407 # Save nodeid so parent manifest can calculate its nodeid
1401 m.setnode(n)
1408 m.setnode(n)
1402 return n
1409 return n
1403
1410
1411 def __len__(self):
1412 return len(self._revlog)
1413
1414 def __iter__(self):
1415 return self._revlog.__iter__()
1416
1417 def rev(self, node):
1418 return self._revlog.rev(node)
1419
1420 def node(self, rev):
1421 return self._revlog.node(rev)
1422
1423 def lookup(self, value):
1424 return self._revlog.lookup(value)
1425
1426 def parentrevs(self, rev):
1427 return self._revlog.parentrevs(rev)
1428
1429 def parents(self, node):
1430 return self._revlog.parents(node)
1431
1432 def linkrev(self, rev):
1433 return self._revlog.linkrev(rev)
1434
1435 def checksize(self):
1436 return self._revlog.checksize()
1437
1438 def revision(self, node, _df=None, raw=False):
1439 return self._revlog.revision(node, _df=_df, raw=raw)
1440
1441 def revdiff(self, rev1, rev2):
1442 return self._revlog.revdiff(rev1, rev2)
1443
1444 def cmp(self, node, text):
1445 return self._revlog.cmp(node, text)
1446
1447 def deltaparent(self, rev):
1448 return self._revlog.deltaparent(rev)
1449
1450 def emitrevisiondeltas(self, requests):
1451 return self._revlog.emitrevisiondeltas(requests)
1452
1453 def addgroup(self, deltas, linkmapper, transaction, addrevisioncb=None):
1454 return self._revlog.addgroup(deltas, linkmapper, transaction,
1455 addrevisioncb=addrevisioncb)
1456
1457 def getstrippoint(self, minlink):
1458 return self._revlog.getstrippoint(minlink)
1459
1460 def strip(self, minlink, transaction):
1461 return self._revlog.strip(minlink, transaction)
1462
1463 def files(self):
1464 return self._revlog.files()
1465
1466 def clone(self, tr, destrevlog, **kwargs):
1467 if not isinstance(destrevlog, manifestrevlog):
1468 raise error.ProgrammingError('expected manifestrevlog to clone()')
1469
1470 return self._revlog.clone(tr, destrevlog._revlog, **kwargs)
1471
1472 @property
1473 def indexfile(self):
1474 return self._revlog.indexfile
1475
1476 @indexfile.setter
1477 def indexfile(self, value):
1478 self._revlog.indexfile = value
1479
1480 @property
1481 def opener(self):
1482 return self._revlog.opener
1483
1484 @opener.setter
1485 def opener(self, value):
1486 self._revlog.opener = value
1487
1404 @interfaceutil.implementer(repository.imanifestlog)
1488 @interfaceutil.implementer(repository.imanifestlog)
1405 class manifestlog(object):
1489 class manifestlog(object):
1406 """A collection class representing the collection of manifest snapshots
1490 """A collection class representing the collection of manifest snapshots
@@ -988,6 +988,166 b' class imanifestrevisionwritable(imanifes'
988 Returns the binary node of the created revision.
988 Returns the binary node of the created revision.
989 """
989 """
990
990
991 class imanifeststorage(interfaceutil.Interface):
992 """Storage interface for manifest data."""
993
994 index = interfaceutil.Attribute(
995 """An ``ifilerevisionssequence`` instance.""")
996
997 indexfile = interfaceutil.Attribute(
998 """Path of revlog index file.
999
1000 TODO this is revlog specific and should not be exposed.
1001 """)
1002
1003 opener = interfaceutil.Attribute(
1004 """VFS opener to use to access underlying files used for storage.
1005
1006 TODO this is revlog specific and should not be exposed.
1007 """)
1008
1009 version = interfaceutil.Attribute(
1010 """Revlog version number.
1011
1012 TODO this is revlog specific and should not be exposed.
1013 """)
1014
1015 _generaldelta = interfaceutil.Attribute(
1016 """Whether generaldelta storage is being used.
1017
1018 TODO this is revlog specific and should not be exposed.
1019 """)
1020
1021 fulltextcache = interfaceutil.Attribute(
1022 """Dict with cache of fulltexts.
1023
1024 TODO this doesn't feel appropriate for the storage interface.
1025 """)
1026
1027 def __len__():
1028 """Obtain the number of revisions stored for this manifest."""
1029
1030 def __iter__():
1031 """Iterate over revision numbers for this manifest."""
1032
1033 def rev(node):
1034 """Obtain the revision number given a binary node.
1035
1036 Raises ``error.LookupError`` if the node is not known.
1037 """
1038
1039 def node(rev):
1040 """Obtain the node value given a revision number.
1041
1042 Raises ``error.LookupError`` if the revision is not known.
1043 """
1044
1045 def lookup(value):
1046 """Attempt to resolve a value to a node.
1047
1048 Value can be a binary node, hex node, revision number, or a bytes
1049 that can be converted to an integer.
1050
1051 Raises ``error.LookupError`` if a ndoe could not be resolved.
1052
1053 TODO this is only used by debug* commands and can probably be deleted
1054 easily.
1055 """
1056
1057 def parents(node):
1058 """Returns a 2-tuple of parent nodes for a node.
1059
1060 Values will be ``nullid`` if the parent is empty.
1061 """
1062
1063 def parentrevs(rev):
1064 """Like parents() but operates on revision numbers."""
1065
1066 def linkrev(rev):
1067 """Obtain the changeset revision number a revision is linked to."""
1068
1069 def revision(node, _df=None, raw=False):
1070 """Obtain fulltext data for a node."""
1071
1072 def revdiff(rev1, rev2):
1073 """Obtain a delta between two revision numbers.
1074
1075 The returned data is the result of ``bdiff.bdiff()`` on the raw
1076 revision data.
1077 """
1078
1079 def cmp(node, fulltext):
1080 """Compare fulltext to another revision.
1081
1082 Returns True if the fulltext is different from what is stored.
1083 """
1084
1085 def emitrevisiondeltas(requests):
1086 """Produce ``irevisiondelta`` from ``irevisiondeltarequest``s.
1087
1088 See the documentation for ``ifiledata`` for more.
1089 """
1090
1091 def addgroup(deltas, linkmapper, transaction, addrevisioncb=None):
1092 """Process a series of deltas for storage.
1093
1094 See the documentation in ``ifilemutation`` for more.
1095 """
1096
1097 def getstrippoint(minlink):
1098 """Find minimum revision that must be stripped to strip a linkrev.
1099
1100 See the documentation in ``ifilemutation`` for more.
1101 """
1102
1103 def strip(minlink, transaction):
1104 """Remove storage of items starting at a linkrev.
1105
1106 See the documentation in ``ifilemutation`` for more.
1107 """
1108
1109 def checksize():
1110 """Obtain the expected sizes of backing files.
1111
1112 TODO this is used by verify and it should not be part of the interface.
1113 """
1114
1115 def files():
1116 """Obtain paths that are backing storage for this manifest.
1117
1118 TODO this is used by verify and there should probably be a better API
1119 for this functionality.
1120 """
1121
1122 def deltaparent(rev):
1123 """Obtain the revision that a revision is delta'd against.
1124
1125 TODO delta encoding is an implementation detail of storage and should
1126 not be exposed to the storage interface.
1127 """
1128
1129 def clone(tr, dest, **kwargs):
1130 """Clone this instance to another."""
1131
1132 def clearcaches(clear_persisted_data=False):
1133 """Clear any caches associated with this instance."""
1134
1135 def dirlog(d):
1136 """Obtain a manifest storage instance for a tree."""
1137
1138 def add(m, transaction, link, p1, p2, added, removed, readtree=None):
1139 """Add a revision to storage.
1140
1141 ``m`` is an object conforming to ``imanifestdict``.
1142
1143 ``link`` is the linkrev revision number.
1144
1145 ``p1`` and ``p2`` are the parent revision numbers.
1146
1147 ``added`` and ``removed`` are iterables of added and removed paths,
1148 respectively.
1149 """
1150
991 class imanifestlog(interfaceutil.Interface):
1151 class imanifestlog(interfaceutil.Interface):
992 """Interface representing a collection of manifest snapshots.
1152 """Interface representing a collection of manifest snapshots.
993
1153
@@ -177,6 +177,7 b' def main():'
177 ziverify.verifyClass(repository.imanifestrevisionwritable,
177 ziverify.verifyClass(repository.imanifestrevisionwritable,
178 manifest.memtreemanifestctx)
178 manifest.memtreemanifestctx)
179 ziverify.verifyClass(repository.imanifestlog, manifest.manifestlog)
179 ziverify.verifyClass(repository.imanifestlog, manifest.manifestlog)
180 ziverify.verifyClass(repository.imanifeststorage, manifest.manifestrevlog)
180
181
181 vfs = vfsmod.vfs(b'.')
182 vfs = vfsmod.vfs(b'.')
182 fl = filelog.filelog(vfs, b'dummy.i')
183 fl = filelog.filelog(vfs, b'dummy.i')
@@ -198,6 +199,9 b' def main():'
198 # Conforms to imanifestdict.
199 # Conforms to imanifestdict.
199 checkzobject(mctx.read())
200 checkzobject(mctx.read())
200
201
202 mrl = manifest.manifestrevlog(vfs)
203 checkzobject(mrl)
204
201 ziverify.verifyClass(repository.irevisiondelta,
205 ziverify.verifyClass(repository.irevisiondelta,
202 revlog.revlogrevisiondelta)
206 revlog.revlogrevisiondelta)
203 ziverify.verifyClass(repository.irevisiondeltarequest,
207 ziverify.verifyClass(repository.irevisiondeltarequest,
General Comments 0
You need to be logged in to leave comments. Login now