--- a/hgext3rd/topic/flow.py Wed Apr 08 01:16:57 2020 +0800
+++ b/hgext3rd/topic/flow.py Fri May 08 20:36:32 2020 +0800
@@ -7,6 +7,7 @@
extensions,
node,
phases,
+ util,
)
from mercurial.i18n import _
@@ -62,10 +63,18 @@
def reject_publish(repo, tr):
"""prevent a transaction to be publish anything"""
- published = set()
- for r, (o, n) in tr.changes[b'phases'].items():
- if n == phases.public:
- published.add(r)
+ if util.safehasattr(tr.changes[b'phases'], 'items'):
+ # hg <= 5.3 (fdc802f29b2c)
+ published = {
+ r for r, (o, n) in tr.changes[b'phases'].items()
+ if n == phases.public
+ }
+ else:
+ revranges = [
+ r for r, (o, n) in tr.changes[b'phases']
+ if n == phases.public
+ ]
+ published = {r for revrange in revranges for r in revrange}
if published:
r = min(published)
msg = b"rejecting publishing of changeset %s" % repo[r]
@@ -101,7 +110,8 @@
def installpushflag(ui):
entry = extensions.wrapcommand(commands.table, b'push', wrappush)
- if not any(opt for opt in entry[1] if opt[1] == b'publish'): # hg <= 4.9
+ if not any(opt for opt in entry[1] if opt[1] == b'publish'):
+ # hg <= 4.8 (9b8d1ad851f8)
entry[1].append((b'', b'publish', False,
_(b'push the changeset as public')))
extensions.wrapfunction(exchange.pushoperation, '__init__',