[PATCH 3 of 3 evolve-ext] safeguard: use self instead of repo in noautopublishrepo.checkpush()

Anton Shestakov av6 at dwimlabs.net
Fri Apr 6 02:58:36 EDT 2018


# HG changeset patch
# User Anton Shestakov <av6 at dwimlabs.net>
# Date 1522996642 -28800
#      Fri Apr 06 14:37:22 2018 +0800
# Node ID 86695bae7a72ae1b64ec6d1fa9370abf473f6544
# Parent  ce9f0f1cfbc2bc7fd305625d9da79953fcd43fe1
safeguard: use self instead of repo in noautopublishrepo.checkpush()

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/evolve/safeguard.py b/hgext3rd/evolve/safeguard.py
--- a/hgext3rd/evolve/safeguard.py
+++ b/hgext3rd/evolve/safeguard.py
@@ -25,17 +25,17 @@ def setuppublishprevention(ui, repo):
 
         def checkpush(self, pushop):
             super(noautopublishrepo, self).checkpush(pushop)
-            behavior = repo.ui.config('experimental', 'auto-publish', 'default')
+            behavior = self.ui.config('experimental', 'auto-publish', 'default')
             remotephases = pushop.remote.listkeys('phases')
             publishing = remotephases.get('publishing', False)
             if behavior in ('warn', 'abort') and publishing:
                 if pushop.revs is None:
-                    published = repo.filtered('served').revs("not public()")
+                    published = self.filtered('served').revs("not public()")
                 else:
-                    published = repo.revs("::%ln - public()", pushop.revs)
+                    published = self.revs("::%ln - public()", pushop.revs)
                 if published:
                     if behavior == 'warn':
-                        repo.ui.warn(_('%i changesets about to be published\n') % len(published))
+                        self.ui.warn(_('%i changesets about to be published\n') % len(published))
                     elif behavior == 'abort':
                         msg = _('push would publish 1 changesets')
                         hint = _("behavior controlled by 'experimental.auto-publish' config")


More information about the Mercurial-devel mailing list