[PATCH 4 of 7] manifest: introduce memmanifestctx and memtreemanifestctx

Durham Goode durham at fb.com
Tue Nov 8 11:42:58 EST 2016


# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1478621023 28800
#      Tue Nov 08 08:03:43 2016 -0800
# Node ID e0dd0793d6d8add4f99244024007986d6bc26dda
# Parent  801efaac42a7088b8f09e9d37b11e7d7d8a9c21b
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.

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -1318,6 +1318,17 @@ class manifestlog(object):
     def add(self, m, transaction, link, p1, p2, added, removed):
         return self._revlog.add(m, transaction, link, p1, p2, added, removed)
 
+class memmanifestctx(object):
+    def __init__(self, repo):
+        self._repo = repo
+        self._manifestdict = manifestdict()
+
+    def new(self):
+        return memmanifestctx(self._repo)
+
+    def read(self):
+        return self._manifestdict
+
 class manifestctx(object):
     """A class representing a single revision of a manifest, including its
     contents, its parent revs, and its linkrev.
@@ -1341,6 +1352,9 @@ class manifestctx(object):
     def node(self):
         return self._node
 
+    def new(self):
+        return memmanifestctx(self._repo)
+
     def read(self):
         if not self._data:
             if self._node == revlog.nullid:
@@ -1395,6 +1409,18 @@ class manifestctx(object):
     def find(self, key):
         return self.read().find(key)
 
+class memtreemanifestctx(object):
+    def __init__(self, repo, dir=''):
+        self._repo = repo
+        self._dir = dir
+        self._treemanifest = treemanifest()
+
+    def new(self, dir=''):
+        return memtreemanifestctx(self._repo, dir=dir)
+
+    def read(self):
+        return self._treemanifest
+
 class treemanifestctx(object):
     def __init__(self, repo, dir, node):
         self._repo = repo
@@ -1438,6 +1464,9 @@ class treemanifestctx(object):
     def node(self):
         return self._node
 
+    def new(self, dir=''):
+        return memtreemanifestctx(self._repo, dir=dir)
+
     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


More information about the Mercurial-devel mailing list