D4821: localrepo: capture repo interface factory functions as lambas

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Wed Oct 3 09:03:58 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG6962ebc8f817: localrepo: capture repo interface factory functions as lambas (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4821?vs=11522&id=11600

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

AFFECTED FILES
  mercurial/localrepo.py

CHANGE DETAILS

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -534,7 +534,7 @@
     for iface, fn in REPO_INTERFACES:
         # We pass all potentially useful state to give extensions tons of
         # flexibility.
-        typ = fn(ui=ui,
+        typ = fn()(ui=ui,
                  intents=intents,
                  requirements=requirements,
                  features=features,
@@ -803,10 +803,12 @@
 
 # List of repository interfaces and factory functions for them. Each
 # will be called in order during ``makelocalrepository()`` to iteratively
-# derive the final type for a local repository instance.
+# derive the final type for a local repository instance. We capture the
+# function as a lambda so we don't hold a reference and the module-level
+# functions can be wrapped.
 REPO_INTERFACES = [
-    (repository.ilocalrepositorymain, makemain),
-    (repository.ilocalrepositoryfilestorage, makefilestorage),
+    (repository.ilocalrepositorymain, lambda: makemain),
+    (repository.ilocalrepositoryfilestorage, lambda: makefilestorage),
 ]
 
 @interfaceutil.implementer(repository.ilocalrepositorymain)



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


More information about the Mercurial-devel mailing list