73 self.publish = publish |
72 self.publish = publish |
74 |
73 |
75 def wrapphasediscovery(orig, pushop): |
74 def wrapphasediscovery(orig, pushop): |
76 orig(pushop) |
75 orig(pushop) |
77 if getattr(pushop, 'publish', False): |
76 if getattr(pushop, 'publish', False): |
78 if not util.safehasattr(pushop, 'remotephases'): |
|
79 msg = _('--publish flag only supported from Mercurial 4.4 and higher') |
|
80 raise error.Abort(msg) |
|
81 if not pushop.remotephases.publishing: |
77 if not pushop.remotephases.publishing: |
82 unfi = pushop.repo.unfiltered() |
78 unfi = pushop.repo.unfiltered() |
83 droots = pushop.remotephases.draftroots |
79 droots = pushop.remotephases.draftroots |
84 revset = '%ln and (not public() or %ln::)' |
80 revset = '%ln and (not public() or %ln::)' |
85 future = list(unfi.set(revset, pushop.futureheads, droots)) |
81 future = list(unfi.set(revset, pushop.futureheads, droots)) |
86 pushop.outdatedphases = future |
82 pushop.outdatedphases = future |
87 |
83 |
88 def installpushflag(ui): |
84 def installpushflag(ui): |
89 entry = extensions.wrapcommand(commands.table, 'push', wrappush) |
85 entry = extensions.wrapcommand(commands.table, 'push', wrappush) |
90 entry[1].append(('', 'publish', False, |
86 if not any(opt for opt in entry[1] if opt[1] == 'publish'): # hg <= 4.9 |
91 _('push the changeset as public'))) |
87 entry[1].append(('', 'publish', False, |
|
88 _('push the changeset as public'))) |
92 extensions.wrapfunction(exchange.pushoperation, '__init__', |
89 extensions.wrapfunction(exchange.pushoperation, '__init__', |
93 extendpushoperation) |
90 extendpushoperation) |
94 extensions.wrapfunction(exchange, '_pushdiscoveryphase', wrapphasediscovery) |
91 extensions.wrapfunction(exchange, '_pushdiscoveryphase', wrapphasediscovery) |
95 exchange.pushdiscoverymapping['phase'] = exchange._pushdiscoveryphase |
92 exchange.pushdiscoverymapping['phase'] = exchange._pushdiscoveryphase |