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) |
99 future = list(unfi.set(revset, pushop.futureheads, droots)) |
108 future = list(unfi.set(revset, pushop.futureheads, droots)) |
100 pushop.outdatedphases = future |
109 pushop.outdatedphases = future |
101 |
110 |
102 def installpushflag(ui): |
111 def installpushflag(ui): |
103 entry = extensions.wrapcommand(commands.table, b'push', wrappush) |
112 entry = extensions.wrapcommand(commands.table, b'push', wrappush) |
104 if not any(opt for opt in entry[1] if opt[1] == b'publish'): # hg <= 4.9 |
113 if not any(opt for opt in entry[1] if opt[1] == b'publish'): |
|
114 # hg <= 4.8 (9b8d1ad851f8) |
105 entry[1].append((b'', b'publish', False, |
115 entry[1].append((b'', b'publish', False, |
106 _(b'push the changeset as public'))) |
116 _(b'push the changeset as public'))) |
107 extensions.wrapfunction(exchange.pushoperation, '__init__', |
117 extensions.wrapfunction(exchange.pushoperation, '__init__', |
108 extendpushoperation) |
118 extendpushoperation) |
109 extensions.wrapfunction(exchange, '_pushdiscoveryphase', wrapphasediscovery) |
119 extensions.wrapfunction(exchange, '_pushdiscoveryphase', wrapphasediscovery) |