hgext3rd/topic/flow.py
branchmercurial-4.8
changeset 4356 a71f2271ed76
parent 4263 35130e428ebd
child 4647 228caeb8b7af
equal deleted inserted replaced
4355:75db6a9d0b54 4356:a71f2271ed76
     5     error,
     5     error,
     6     exchange,
     6     exchange,
     7     extensions,
     7     extensions,
     8     node,
     8     node,
     9     phases,
     9     phases,
    10     util,
       
    11 )
    10 )
    12 
    11 
    13 from mercurial.i18n import _
    12 from mercurial.i18n import _
    14 
    13 
    15 def enforcesinglehead(repo, tr):
    14 def enforcesinglehead(repo, tr):
    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