topic: compat with tr.changes[b'phases'], it's now a list
authorAnton Shestakov <av6@dwimlabs.net>
Fri, 20 Mar 2020 12:37:44 +0700
changeset 5204 d7f87c7cb1f0
parent 5203 034d6d0efa7d
child 5211 a28f24828f62
topic: compat with tr.changes[b'phases'], it's now a list
hgext3rd/topic/flow.py
--- 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]