[PATCH evolve-ext] topic: use self instead of repo in topicrepo methods

Anton Shestakov av6 at dwimlabs.net
Wed Jul 18 10:29:40 UTC 2018


# HG changeset patch
# User Anton Shestakov <av6 at dwimlabs.net>
# Date 1531909036 -28800
#      Wed Jul 18 18:17:16 2018 +0800
# Node ID 3e63522314b688d32c393d783c501a5eab88c74e
# Parent  1fa3bf6e9e93cc244dea752196955a6d0c6b25b1
topic: use self instead of repo in topicrepo methods

Referring to repo here was somehow preventing it from being garbage-collected
(important in hgweb, where currently every request gets a new repo).

diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py
+++ b/hgext3rd/topic/__init__.py
@@ -364,7 +364,7 @@ def reposetup(ui, repo):
         def commit(self, *args, **kwargs):
             backup = self.ui.backupconfig('ui', 'allowemptycommit')
             try:
-                if repo.currenttopic != repo['.'].topic():
+                if self.currenttopic != self['.'].topic():
                     # bypass the core "nothing changed" logic
                     self.ui.setconfig('ui', 'allowemptycommit', True)
                 return super(topicrepo, self).commit(*args, **kwargs)
@@ -374,7 +374,7 @@ def reposetup(ui, repo):
         def commitctx(self, ctx, error=None):
             topicfilter = topicmap.topicfilter(self.filtername)
             if topicfilter != self.filtername:
-                other = repo.filtered(topicmap.topicfilter(repo.filtername))
+                other = self.filtered(topicmap.topicfilter(self.filtername))
                 other.commitctx(ctx, error=error)
 
             if isinstance(ctx, context.workingcommitctx):
@@ -409,7 +409,7 @@ def reposetup(ui, repo):
 
         def branchmap(self, topic=None):
             if topic is None:
-                topic = getattr(repo, '_autobranchmaptopic', False)
+                topic = getattr(self, '_autobranchmaptopic', False)
             topicfilter = topicmap.topicfilter(self.filtername)
             if not topic or topicfilter == self.filtername:
                 return super(topicrepo, self).branchmap()
@@ -437,7 +437,7 @@ def reposetup(ui, repo):
                 return tr
 
             reporef = weakref.ref(self)
-            if repo.ui.configbool('experimental', 'enforce-single-head'):
+            if self.ui.configbool('experimental', 'enforce-single-head'):
                 origvalidator = tr.validator
 
                 def validator(tr2):
@@ -446,7 +446,7 @@ def reposetup(ui, repo):
                     origvalidator(tr2)
                 tr.validator = validator
 
-            topicmodeserver = repo.ui.config('experimental',
+            topicmodeserver = self.ui.config('experimental',
                                              'topic-mode.server', 'ignore')
             ispush = (desc.startswith('push') or desc.startswith('serve'))
             if (topicmodeserver != 'ignore' and ispush):
@@ -458,7 +458,7 @@ def reposetup(ui, repo):
                     return origvalidator(tr2)
                 tr.validator = validator
 
-            elif (repo.ui.configbool('experimental', 'topic.publish-bare-branch')
+            elif (self.ui.configbool('experimental', 'topic.publish-bare-branch')
                     and (desc.startswith('push')
                          or desc.startswith('serve'))
                     ):


More information about the Mercurial-devel mailing list