# HG changeset patch # User Anton Shestakov # Date 1586278943 -28800 # Node ID 9ed5f9c5d8aecc991d4146495c7e7f2f7e39a244 # Parent 1a81bbc94d45fd3a06c6a13c40145d64356f8445 topic: hg <= 4.8 compatibility for wrapping exchange._checkpublish() phase-divergent update to 1a81bbc94d45: diff -r 1a81bbc94d45 -r 9ed5f9c5d8ae hgext3rd/evolve/safeguard.py --- a/hgext3rd/evolve/safeguard.py Wed Apr 08 01:02:23 2020 +0800 +++ b/hgext3rd/evolve/safeguard.py Wed Apr 08 01:02:23 2020 +0800 @@ -19,11 +19,35 @@ eh = exthelper.exthelper() -# hg <= 4.8 +# 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) + 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): @@ -31,25 +55,6 @@ def checkpush(self, pushop): super(noautopublishrepo, self).checkpush(pushop) - behavior = self.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 = self.filtered(b'served').revs(b"not public()") - else: - published = self.revs(b"::%ln - public()", pushop.revs) - if published: - if behavior == b'warn': - self.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) + _checkpublish(pushop) repo.__class__ = noautopublishrepo diff -r 1a81bbc94d45 -r 9ed5f9c5d8ae hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py Wed Apr 08 01:02:23 2020 +0800 +++ b/hgext3rd/topic/__init__.py Wed Apr 08 01:02:23 2020 +0800 @@ -383,9 +383,16 @@ extensions.wrapfunction(changelog.changelog, 'add', wrapadd) # Make exchange._checkpublish handle experimental.topic.publish-bare-branch if util.safehasattr(exchange, '_checkpublish'): - # hg <= 4.8 (33d30fb1e4ae) 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 server.setupserver(ui)