changeset 5204:d7f87c7cb1f0

topic: compat with tr.changes[b'phases'], it's now a list
author Anton Shestakov <av6@dwimlabs.net>
date Fri, 20 Mar 2020 12:37:44 +0700
parents 034d6d0efa7d
children a28f24828f62
files hgext3rd/topic/flow.py
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/flow.py	Thu Mar 19 20:09:18 2020 +0530
+++ b/hgext3rd/topic/flow.py	Fri Mar 20 12:37:44 2020 +0700
@@ -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]