D4387: manifest: make tree a public attribute

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Mon Aug 27 16:01:12 UTC 2018


indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  changegroup generation accesses this attribute. We should make it
  public and expose it on the interface.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D4387

AFFECTED FILES
  mercurial/changegroup.py
  mercurial/manifest.py
  mercurial/repository.py

CHANGE DETAILS

diff --git a/mercurial/repository.py b/mercurial/repository.py
--- a/mercurial/repository.py
+++ b/mercurial/repository.py
@@ -991,6 +991,12 @@
 class imanifeststorage(interfaceutil.Interface):
     """Storage interface for manifest data."""
 
+    tree = interfaceutil.Attribute(
+        """The path to the directory this manifest tracks.
+
+        The empty bytestring represents the root manifest.
+        """)
+
     index = interfaceutil.Attribute(
         """An ``ifilerevisionssequence`` instance.""")
 
diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -1285,7 +1285,8 @@
             if tree:
                 indexfile = "meta/" + tree + indexfile
 
-        self._tree = tree
+        self.tree = tree
+
         # The dirlogcache is kept on the root manifest log
         if tree:
             self._dirlogcache = dirlogcache
@@ -1330,7 +1331,7 @@
     def clearcaches(self, clear_persisted_data=False):
         self._revlog.clearcaches()
         self._fulltextcache.clear(clear_persisted_data=clear_persisted_data)
-        self._dirlogcache = {self._tree: self}
+        self._dirlogcache = {self.tree: self}
 
     def dirlog(self, d):
         if d:
@@ -1366,8 +1367,8 @@
             # process.
             if self._treeondisk:
                 assert readtree, "readtree must be set for treemanifest writes"
-                m1 = readtree(self._tree, p1)
-                m2 = readtree(self._tree, p2)
+                m1 = readtree(self.tree, p1)
+                m2 = readtree(self.tree, p2)
                 n = self._addtree(m, transaction, link, m1, m2, readtree)
                 arraytext = None
             else:
@@ -1383,7 +1384,7 @@
     def _addtree(self, m, transaction, link, m1, m2, readtree):
         # If the manifest is unchanged compared to one parent,
         # don't write a new revision
-        if self._tree != '' and (m.unmodifiedsince(m1) or m.unmodifiedsince(
+        if self.tree != '' and (m.unmodifiedsince(m1) or m.unmodifiedsince(
             m2)):
             return m.node()
         def writesubtree(subm, subp1, subp2):
@@ -1393,7 +1394,7 @@
         m.writesubtrees(m1, m2, writesubtree)
         text = m.dirtext()
         n = None
-        if self._tree != '':
+        if self.tree != '':
             # Double-check whether contents are unchanged to one parent
             if text == m1.dirtext():
                 n = m1.node()
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -1065,7 +1065,7 @@
             tree, nodes = tmfnodes.popitem()
             store = mfl.getstorage(tree)
 
-            if not self._filematcher.visitdir(store._tree[:-1] or '.'):
+            if not self._filematcher.visitdir(store.tree[:-1] or '.'):
                 prunednodes = []
             else:
                 frev, flr = store.rev, store.linkrev



To: indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list