hgext3rd/topic/flow.py
changeset 5204 d7f87c7cb1f0
parent 5193 a4d081923c81
child 5276 8431bb224862
equal deleted inserted replaced
5203:034d6d0efa7d 5204:d7f87c7cb1f0
     5     error,
     5     error,
     6     exchange,
     6     exchange,
     7     extensions,
     7     extensions,
     8     node,
     8     node,
     9     phases,
     9     phases,
       
    10     util,
    10 )
    11 )
    11 
    12 
    12 from mercurial.i18n import _
    13 from mercurial.i18n import _
    13 
    14 
    14 from . import (
    15 from . import (
    60         else:
    61         else:
    61             repo.ui.warn(_(b"unknown 'topic-mode.server': %s\n" % mode))
    62             repo.ui.warn(_(b"unknown 'topic-mode.server': %s\n" % mode))
    62 
    63 
    63 def reject_publish(repo, tr):
    64 def reject_publish(repo, tr):
    64     """prevent a transaction to be publish anything"""
    65     """prevent a transaction to be publish anything"""
    65     published = set()
    66     if util.safehasattr(tr.changes[b'phases'], 'items'):
    66     for r, (o, n) in tr.changes[b'phases'].items():
    67         # hg <= 5.3 (fdc802f29b2c)
    67         if n == phases.public:
    68         published = {
    68             published.add(r)
    69             r for r, (o, n) in tr.changes[b'phases'].items()
       
    70             if n == phases.public
       
    71         }
       
    72     else:
       
    73         revranges = [
       
    74             r for r, (o, n) in tr.changes[b'phases']
       
    75             if n == phases.public
       
    76         ]
       
    77         published = {r for revrange in revranges for r in revrange}
    69     if published:
    78     if published:
    70         r = min(published)
    79         r = min(published)
    71         msg = b"rejecting publishing of changeset %s" % repo[r]
    80         msg = b"rejecting publishing of changeset %s" % repo[r]
    72         if len(published) > 1:
    81         if len(published) > 1:
    73             msg += b' and %d others' % (len(published) - 1)
    82             msg += b' and %d others' % (len(published) - 1)