Patchwork [5,of,7] manifest: add copy to mfctx classes

login
register
mail settings
Submitter Durham Goode
Date Nov. 8, 2016, 4:42 p.m.
Message ID <30637bdf444e47e38ede.1478623379@dev111.prn1.facebook.com>
Download mbox | patch
Permalink /patch/17411/
State Accepted
Headers show

Comments

Durham Goode - Nov. 8, 2016, 4:42 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1478621023 28800
#      Tue Nov 08 08:03:43 2016 -0800
# Node ID 30637bdf444e47e38edef0bc52c9ffe313816c66
# Parent  e0dd0793d6d8add4f99244024007986d6bc26dda
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.

Patch

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -1326,6 +1326,11 @@  class memmanifestctx(object):
     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
 
@@ -1355,6 +1360,11 @@  class manifestctx(object):
     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:
@@ -1418,6 +1428,11 @@  class memtreemanifestctx(object):
     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
 
@@ -1467,6 +1482,11 @@  class treemanifestctx(object):
     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