23 topublish = repo.revs('not public() and (%n:) - hidden() - topic()', startnode) |
27 topublish = repo.revs('not public() and (%n:) - hidden() - topic()', startnode) |
24 if topublish: |
28 if topublish: |
25 cl = repo.changelog |
29 cl = repo.changelog |
26 nodes = [cl.node(r) for r in topublish] |
30 nodes = [cl.node(r) for r in topublish] |
27 repo._phasecache.advanceboundary(repo, tr, phases.public, nodes) |
31 repo._phasecache.advanceboundary(repo, tr, phases.public, nodes) |
|
32 |
|
33 def wrappush(orig, repo, remote, *args, **kwargs): |
|
34 """interpret the --publish flag and pass it to the push operation""" |
|
35 newargs = kwargs.copy() |
|
36 if kwargs.pop('publish', False): |
|
37 opargs = kwargs.get('opargs') |
|
38 if opargs is None: |
|
39 opargs = {} |
|
40 newargs['opargs'] = opargs.copy() |
|
41 newargs['opargs']['publish'] = True |
|
42 return orig(repo, remote, *args, **newargs) |
|
43 |
|
44 def extendpushoperation(orig, *args, **kwargs): |
|
45 publish = kwargs.pop('publish', False) |
|
46 op = orig(*args, **kwargs) |
|
47 op.publish = publish |
|
48 return op |
|
49 |
|
50 def wrapphasediscovery(orig, pushop): |
|
51 orig(pushop) |
|
52 if pushop.publish: |
|
53 if not util.safehasattr(pushop, 'remotephases'): |
|
54 msg = _('--publish flag only supported from Mercurial 4.4 and higher') |
|
55 raise error.Abort(msg) |
|
56 if not pushop.remotephases.publishing: |
|
57 unfi = pushop.repo.unfiltered() |
|
58 droots = pushop.remotephases.draftroots |
|
59 revset = '%ln and (not public() or %ln::)' |
|
60 future = list(unfi.set(revset, pushop.futureheads, droots)) |
|
61 pushop.outdatedphases = future |
|
62 |
|
63 def installpushflag(ui): |
|
64 entry = extensions.wrapcommand(commands.table, 'push', wrappush) |
|
65 entry[1].append(('', 'publish', False, |
|
66 _('push the changeset as public'))) |
|
67 extensions.wrapfunction(exchange, 'pushoperation', extendpushoperation) |
|
68 extensions.wrapfunction(exchange, '_pushdiscoveryphase', wrapphasediscovery) |
|
69 exchange.pushdiscoverymapping['phase'] = exchange._pushdiscoveryphase |