changeset 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 362f6f651b2e
files mercurial/manifest.py
diffstat 1 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/manifest.py	Tue Nov 08 08:03:43 2016 -0800
+++ b/mercurial/manifest.py	Tue Nov 08 08:03:43 2016 -0800
@@ -1331,6 +1331,11 @@
     def new(self):
         return memmanifestctx(self._repo)
 
+    def copy(self):
+        memmf = memmanifestctx(self._repo)
+        memmf._manifestdict = self.read().copy()
+        return memmf
+
     def read(self):
         return self._manifestdict
 
@@ -1360,6 +1365,11 @@
     def new(self):
         return memmanifestctx(self._repo)
 
+    def copy(self):
+        memmf = memmanifestctx(self._repo)
+        memmf._manifestdict = self.read().copy()
+        return memmf
+
     def read(self):
         if not self._data:
             if self._node == revlog.nullid:
@@ -1423,6 +1433,11 @@
     def new(self, dir=''):
         return memtreemanifestctx(self._repo, dir=dir)
 
+    def copy(self):
+        memmf = memtreemanifestctx(self._repo, dir=self._dir)
+        memmf._treemanifest = self._treemanifest.copy()
+        return memmf
+
     def read(self):
         return self._treemanifest
 
@@ -1472,6 +1487,11 @@
     def new(self, dir=''):
         return memtreemanifestctx(self._repo, dir=dir)
 
+    def copy(self):
+        memmf = memtreemanifestctx(self._repo, dir=self._dir)
+        memmf._treemanifest = self.read().copy()
+        return memmf
+
     def readdelta(self, shallow=False):
         '''Returns a manifest containing just the entries that are present
         in this manifest, but not in its p1 manifest. This is efficient to read