comparison mercurial/manifest.py @ 30343:952e1916ae56

manifest: add copy to mfctx classes This adds copy functionality to the manifestctx classes. This will be used in an upcoming diff to copy a manifestctx during commit so we can modify the manifest before committing.
author Durham Goode <durham@fb.com>
date Tue, 08 Nov 2016 08:03:43 -0800
parents fe1ee393de78
children fa54f7ade491
comparison
equal deleted inserted replaced
30342:fe1ee393de78 30343:952e1916ae56
1329 self._manifestdict = manifestdict() 1329 self._manifestdict = manifestdict()
1330 1330
1331 def new(self): 1331 def new(self):
1332 return memmanifestctx(self._repo) 1332 return memmanifestctx(self._repo)
1333 1333
1334 def copy(self):
1335 memmf = memmanifestctx(self._repo)
1336 memmf._manifestdict = self.read().copy()
1337 return memmf
1338
1334 def read(self): 1339 def read(self):
1335 return self._manifestdict 1340 return self._manifestdict
1336 1341
1337 class manifestctx(object): 1342 class manifestctx(object):
1338 """A class representing a single revision of a manifest, including its 1343 """A class representing a single revision of a manifest, including its
1357 def node(self): 1362 def node(self):
1358 return self._node 1363 return self._node
1359 1364
1360 def new(self): 1365 def new(self):
1361 return memmanifestctx(self._repo) 1366 return memmanifestctx(self._repo)
1367
1368 def copy(self):
1369 memmf = memmanifestctx(self._repo)
1370 memmf._manifestdict = self.read().copy()
1371 return memmf
1362 1372
1363 def read(self): 1373 def read(self):
1364 if not self._data: 1374 if not self._data:
1365 if self._node == revlog.nullid: 1375 if self._node == revlog.nullid:
1366 self._data = manifestdict() 1376 self._data = manifestdict()
1420 self._dir = dir 1430 self._dir = dir
1421 self._treemanifest = treemanifest() 1431 self._treemanifest = treemanifest()
1422 1432
1423 def new(self, dir=''): 1433 def new(self, dir=''):
1424 return memtreemanifestctx(self._repo, dir=dir) 1434 return memtreemanifestctx(self._repo, dir=dir)
1435
1436 def copy(self):
1437 memmf = memtreemanifestctx(self._repo, dir=self._dir)
1438 memmf._treemanifest = self._treemanifest.copy()
1439 return memmf
1425 1440
1426 def read(self): 1441 def read(self):
1427 return self._treemanifest 1442 return self._treemanifest
1428 1443
1429 class treemanifestctx(object): 1444 class treemanifestctx(object):
1470 return self._node 1485 return self._node
1471 1486
1472 def new(self, dir=''): 1487 def new(self, dir=''):
1473 return memtreemanifestctx(self._repo, dir=dir) 1488 return memtreemanifestctx(self._repo, dir=dir)
1474 1489
1490 def copy(self):
1491 memmf = memtreemanifestctx(self._repo, dir=self._dir)
1492 memmf._treemanifest = self.read().copy()
1493 return memmf
1494
1475 def readdelta(self, shallow=False): 1495 def readdelta(self, shallow=False):
1476 '''Returns a manifest containing just the entries that are present 1496 '''Returns a manifest containing just the entries that are present
1477 in this manifest, but not in its p1 manifest. This is efficient to read 1497 in this manifest, but not in its p1 manifest. This is efficient to read
1478 if the revlog delta is already p1. 1498 if the revlog delta is already p1.
1479 1499