changeset 6643:4f0ec124224f

evolve: drop compatibility for experimental.auto-publish for hg 4.8
author Anton Shestakov <av6@dwimlabs.net>
date Fri, 03 Nov 2023 15:26:57 -0300
parents 196babdbb593
children f8ae37ff5bfb
files hgext3rd/evolve/__init__.py hgext3rd/evolve/safeguard.py hgext3rd/topic/__init__.py tests/test-check-sdist.t
diffstat 4 files changed, 3 insertions(+), 78 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/__init__.py	Sat Jan 06 17:08:01 2024 -0300
+++ b/hgext3rd/evolve/__init__.py	Fri Nov 03 15:26:57 2023 -0300
@@ -317,7 +317,6 @@
     obshistory,
     revset,
     rewind,
-    safeguard,
     templatekw,
     utility,
 )
@@ -358,7 +357,6 @@
 eh.merge(evolvecmd.eh)
 eh.merge(obsexchange.eh)
 eh.merge(obshashtree.eh)
-eh.merge(safeguard.eh)
 eh.merge(obscache.eh)
 eh.merge(obshistory.eh)
 eh.merge(templatekw.eh)
--- a/hgext3rd/evolve/safeguard.py	Sat Jan 06 17:08:01 2024 -0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-# Code dedicated to adding various "safeguard" around evolution
-#
-# Some of these will be pollished and upstream when mature. Some other will be
-# replaced by better alternative later.
-#
-# Copyright 2017 Pierre-Yves David <pierre-yves.david@ens-lyon.org>
-#
-# This software may be used and distributed according to the terms of the
-# GNU General Public License version 2 or any later version.
-
-from mercurial.i18n import _
-
-from mercurial import (
-    configitems,
-    error,
-)
-
-from . import exthelper
-
-eh = exthelper.exthelper()
-
-# hg <= 4.8 (33d30fb1e4ae)
-if b'auto-publish' not in configitems.coreitems.get(b'experimental', {}):
-
-    eh.configitem(b'experimental', b'auto-publish', b'publish')
-
-    def _checkpublish(pushop):
-        repo = pushop.repo
-        ui = repo.ui
-        behavior = ui.config(b'experimental', b'auto-publish')
-        nocheck = behavior not in (b'warn', b'abort')
-        if nocheck or getattr(pushop, 'publish', False):
-            return
-        remotephases = pushop.remote.listkeys(b'phases')
-        publishing = remotephases.get(b'publishing', False)
-        if publishing:
-            if pushop.revs is None:
-                published = repo.filtered(b'served').revs(b"not public()")
-            else:
-                published = repo.revs(b"::%ln - public()", pushop.revs)
-                # we want to use pushop.revs in the revset even if they
-                # themselves are secret, but we don't want to have anything
-                # that the server won't see in the result of this expression
-                published &= repo.filtered(b'served')
-            if published:
-                if behavior == b'warn':
-                    ui.warn(_(b'%i changesets about to be published\n')
-                            % len(published))
-                elif behavior == b'abort':
-                    msg = _(b'push would publish 1 changesets')
-                    hint = _(b"behavior controlled by "
-                             b"'experimental.auto-publish' config")
-                    raise error.Abort(msg, hint=hint)
-
-    @eh.reposetup
-    def setuppublishprevention(ui, repo):
-
-        class noautopublishrepo(repo.__class__):
-
-            def checkpush(self, pushop):
-                super(noautopublishrepo, self).checkpush(pushop)
-                _checkpublish(pushop)
-
-        repo.__class__ = noautopublishrepo
--- a/hgext3rd/topic/__init__.py	Sat Jan 06 17:08:01 2024 -0300
+++ b/hgext3rd/topic/__init__.py	Fri Nov 03 15:26:57 2023 -0300
@@ -569,17 +569,8 @@
     # Wrap changelog.add to drop empty topic
     extensions.wrapfunction(changelog.changelog, 'add', wrapadd)
     # Make exchange._checkpublish handle experimental.topic.publish-bare-branch
-    if util.safehasattr(exchange, '_checkpublish'):
-        extensions.wrapfunction(exchange, '_checkpublish',
-                                flow.replacecheckpublish)
-    else:
-        # hg <= 4.8 (33d30fb1e4ae)
-        try:
-            evolve = extensions.find(b'evolve')
-            extensions.wrapfunction(evolve.safeguard, '_checkpublish',
-                                    flow.replacecheckpublish)
-        except (KeyError, AttributeError):
-            pass
+    extensions.wrapfunction(exchange, '_checkpublish',
+                            flow.replacecheckpublish)
 
     try:
         histedit = extensions.find(b'histedit')
--- a/tests/test-check-sdist.t	Sat Jan 06 17:08:01 2024 -0300
+++ b/tests/test-check-sdist.t	Fri Nov 03 15:26:57 2023 -0300
@@ -37,7 +37,7 @@
   $ egrep '^tests/test-.*\.(t|py)$' files > test-files
   $ egrep -v '^tests/test-.*\.(t|py)$' files > other-files
   $ wc -l other-files
-  147 other-files
+  146 other-files
   $ wc -l test-files
   ??? test-files (glob)
   $ fgrep debian files