Mercurial > public > mercurial-scm > hg
comparison mercurial/manifest.py @ 30342:fe1ee393de78
manifest: introduce memmanifestctx and memtreemanifestctx
This introduces two new classes to represent in-memory manifest instances.
Similar to memchangectx, this lets us prepare a manifest in memory, then in a
future patch we will add the apis that can commit this in memory structure.
author | Durham Goode <durham@fb.com> |
---|---|
date | Tue, 08 Nov 2016 08:03:43 -0800 |
parents | 3dfb5a0171c9 |
children | 952e1916ae56 |
comparison
equal
deleted
inserted
replaced
30341:3dfb5a0171c9 | 30342:fe1ee393de78 |
---|---|
1321 return m | 1321 return m |
1322 | 1322 |
1323 def add(self, m, transaction, link, p1, p2, added, removed): | 1323 def add(self, m, transaction, link, p1, p2, added, removed): |
1324 return self._revlog.add(m, transaction, link, p1, p2, added, removed) | 1324 return self._revlog.add(m, transaction, link, p1, p2, added, removed) |
1325 | 1325 |
1326 class memmanifestctx(object): | |
1327 def __init__(self, repo): | |
1328 self._repo = repo | |
1329 self._manifestdict = manifestdict() | |
1330 | |
1331 def new(self): | |
1332 return memmanifestctx(self._repo) | |
1333 | |
1334 def read(self): | |
1335 return self._manifestdict | |
1336 | |
1326 class manifestctx(object): | 1337 class manifestctx(object): |
1327 """A class representing a single revision of a manifest, including its | 1338 """A class representing a single revision of a manifest, including its |
1328 contents, its parent revs, and its linkrev. | 1339 contents, its parent revs, and its linkrev. |
1329 """ | 1340 """ |
1330 def __init__(self, repo, node): | 1341 def __init__(self, repo, node): |
1343 def _revlog(self): | 1354 def _revlog(self): |
1344 return self._repo.manifestlog._revlog | 1355 return self._repo.manifestlog._revlog |
1345 | 1356 |
1346 def node(self): | 1357 def node(self): |
1347 return self._node | 1358 return self._node |
1359 | |
1360 def new(self): | |
1361 return memmanifestctx(self._repo) | |
1348 | 1362 |
1349 def read(self): | 1363 def read(self): |
1350 if not self._data: | 1364 if not self._data: |
1351 if self._node == revlog.nullid: | 1365 if self._node == revlog.nullid: |
1352 self._data = manifestdict() | 1366 self._data = manifestdict() |
1397 d = mdiff.patchtext(revlog.revdiff(revlog.deltaparent(r), r)) | 1411 d = mdiff.patchtext(revlog.revdiff(revlog.deltaparent(r), r)) |
1398 return manifestdict(d) | 1412 return manifestdict(d) |
1399 | 1413 |
1400 def find(self, key): | 1414 def find(self, key): |
1401 return self.read().find(key) | 1415 return self.read().find(key) |
1416 | |
1417 class memtreemanifestctx(object): | |
1418 def __init__(self, repo, dir=''): | |
1419 self._repo = repo | |
1420 self._dir = dir | |
1421 self._treemanifest = treemanifest() | |
1422 | |
1423 def new(self, dir=''): | |
1424 return memtreemanifestctx(self._repo, dir=dir) | |
1425 | |
1426 def read(self): | |
1427 return self._treemanifest | |
1402 | 1428 |
1403 class treemanifestctx(object): | 1429 class treemanifestctx(object): |
1404 def __init__(self, repo, dir, node): | 1430 def __init__(self, repo, dir, node): |
1405 self._repo = repo | 1431 self._repo = repo |
1406 self._dir = dir | 1432 self._dir = dir |
1441 return self._data | 1467 return self._data |
1442 | 1468 |
1443 def node(self): | 1469 def node(self): |
1444 return self._node | 1470 return self._node |
1445 | 1471 |
1472 def new(self, dir=''): | |
1473 return memtreemanifestctx(self._repo, dir=dir) | |
1474 | |
1446 def readdelta(self, shallow=False): | 1475 def readdelta(self, shallow=False): |
1447 '''Returns a manifest containing just the entries that are present | 1476 '''Returns a manifest containing just the entries that are present |
1448 in this manifest, but not in its p1 manifest. This is efficient to read | 1477 in this manifest, but not in its p1 manifest. This is efficient to read |
1449 if the revlog delta is already p1. | 1478 if the revlog delta is already p1. |
1450 | 1479 |