Patchwork [2,of,6,RFC] manifest: break reference cycle of manifestaccessor and localrepo

login
register
mail settings
Submitter Durham Goode
Date Nov. 3, 2016, 10:27 p.m.
Message ID <89ee090611f9eecbab00.1478212058@dev111.prn1.facebook.com>
Download mbox | patch
Permalink /patch/17328/
State Changes Requested
Headers show

Comments

Durham Goode - Nov. 3, 2016, 10:27 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1478211020 25200
#      Thu Nov 03 15:10:20 2016 -0700
# Branch stable
# Node ID 89ee090611f9eecbab008678174b16b692b5c3c9
# Parent  1788ee9e1df92ac94b9be84eac6d16e3bad903a9
manifest: break reference cycle of manifestaccessor and localrepo

Since our manifestaccessor held a reference to localrepo._constructmanifest, it
caused a reference cycle. This patch breaks that cycle.

bundlerepo and unionrepo abuse the manifest/repo relationship a bit more, so for
now they maintain the reference cycle.

Patch

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -353,6 +353,11 @@  class bundlerepository(localrepo.localre
         return m
 
     @localrepo.unfilteredpropertycache
+    def manifestaccessor(self):
+        return localrepo.revlogaccessor('00manifest.i', self.svfs,
+                                        self._constructmanifest)
+
+    @localrepo.unfilteredpropertycache
     def manstart(self):
         self.changelog
         return self.manstart
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -508,16 +508,14 @@  class localrepository(object):
     def manifest(self):
         return self.manifestlog._oldmanifest
 
-    def _constructmanifest(self):
-        # This is a temporary function while we migrate from manifest to
-        # manifestlog. It allows bundlerepo and unionrepo to intercept the
-        # manifest creation.
-        return manifest.manifest(self.svfs)
-
     @unfilteredpropertycache
     def manifestaccessor(self):
-        return revlogaccessor('00manifest.i', self.svfs,
-                              self._constructmanifest)
+        svfs = self.svfs
+        def _constructmanifest():
+            return manifest.manifest(svfs)
+
+        return revlogaccessor('00manifest.i', svfs,
+                              _constructmanifest)
 
     @storecache('00manifest.i')
     def manifestlog(self):
diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py
--- a/mercurial/unionrepo.py
+++ b/mercurial/unionrepo.py
@@ -212,6 +212,11 @@  class unionrepository(localrepo.localrep
         return unionmanifest(self.svfs, self.repo2.svfs,
                              self.unfiltered()._clrev)
 
+    @localrepo.unfilteredpropertycache
+    def manifestaccessor(self):
+        return localrepo.revlogaccessor('00manifest.i', self.svfs,
+                                        self._constructmanifest)
+
     def url(self):
         return self._url