diff mercurial/manifest.py @ 30355:fa54f7ade491

manifest: remove manifest.add and add memmfctx.write This removes one more dependency on the manifest class by moving the write functionality onto the memmanifestctx classes and changing the one consumer to use the new API. By moving the write path to a manifestctx, we now give the individual manifests control over how they're read and serialized. This will be useful in developing new manifest formats and storage systems.
author Durham Goode <durham@fb.com>
date Tue, 08 Nov 2016 08:03:43 -0800
parents 952e1916ae56
children ed45283a0ca7
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
@@ -1320,14 +1320,14 @@
             mancache[node] = m
         return m
 
-    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 _revlog(self):
+        return self._repo.manifestlog._revlog
+
     def new(self):
         return memmanifestctx(self._repo)
 
@@ -1339,6 +1339,10 @@
     def read(self):
         return self._manifestdict
 
+    def write(self, transaction, link, p1, p2, added, removed):
+        return self._revlog().add(self._manifestdict, transaction, link, p1, p2,
+                                  added, removed)
+
 class manifestctx(object):
     """A class representing a single revision of a manifest, including its
     contents, its parent revs, and its linkrev.
@@ -1430,6 +1434,9 @@
         self._dir = dir
         self._treemanifest = treemanifest()
 
+    def _revlog(self):
+        return self._repo.manifestlog._revlog
+
     def new(self, dir=''):
         return memtreemanifestctx(self._repo, dir=dir)
 
@@ -1441,6 +1448,10 @@
     def read(self):
         return self._treemanifest
 
+    def write(self, transaction, link, p1, p2, added, removed):
+        return self._revlog().add(self._treemanifest, transaction, link, p1, p2,
+                                  added, removed)
+
 class treemanifestctx(object):
     def __init__(self, repo, dir, node):
         self._repo = repo