comparison mercurial/exchange.py @ 40686:9b8d1ad851f8

push: add --publish flag to change phase of pushed changesets This flag is copied from topic extension, where it proved to be useful. It makes all pushed changesets public on both ends if the push succeeds. Doesn't currently work for any subrepos that are implicitly pushed together with their owner repo.
author Anton Shestakov <av6@dwimlabs.net>
date Sat, 27 Oct 2018 21:13:23 +0800
parents 440f5b65be57
children 33d30fb1e4ae
comparison
equal deleted inserted replaced
40685:e41f6c2e69c4 40686:9b8d1ad851f8
357 A new pushoperation should be created at the beginning of each push and 357 A new pushoperation should be created at the beginning of each push and
358 discarded afterward. 358 discarded afterward.
359 """ 359 """
360 360
361 def __init__(self, repo, remote, force=False, revs=None, newbranch=False, 361 def __init__(self, repo, remote, force=False, revs=None, newbranch=False,
362 bookmarks=(), pushvars=None): 362 bookmarks=(), publish=False, pushvars=None):
363 # repo we push from 363 # repo we push from
364 self.repo = repo 364 self.repo = repo
365 self.ui = repo.ui 365 self.ui = repo.ui
366 # repo we push to 366 # repo we push to
367 self.remote = remote 367 self.remote = remote
419 # map { pushkey partid -> callback handling failure} 419 # map { pushkey partid -> callback handling failure}
420 # used to handle exception from mandatory pushkey part failure 420 # used to handle exception from mandatory pushkey part failure
421 self.pkfailcb = {} 421 self.pkfailcb = {}
422 # an iterable of pushvars or None 422 # an iterable of pushvars or None
423 self.pushvars = pushvars 423 self.pushvars = pushvars
424 # publish pushed changesets
425 self.publish = publish
424 426
425 @util.propertycache 427 @util.propertycache
426 def futureheads(self): 428 def futureheads(self):
427 """future remote heads if the changeset push succeeds""" 429 """future remote heads if the changeset push succeeds"""
428 return self.outgoing.missingheads 430 return self.outgoing.missingheads
476 _('deleting remote bookmark %s failed!\n')), 478 _('deleting remote bookmark %s failed!\n')),
477 } 479 }
478 480
479 481
480 def push(repo, remote, force=False, revs=None, newbranch=False, bookmarks=(), 482 def push(repo, remote, force=False, revs=None, newbranch=False, bookmarks=(),
481 opargs=None): 483 publish=False, opargs=None):
482 '''Push outgoing changesets (limited by revs) from a local 484 '''Push outgoing changesets (limited by revs) from a local
483 repository to remote. Return an integer: 485 repository to remote. Return an integer:
484 - None means nothing to push 486 - None means nothing to push
485 - 0 means HTTP error 487 - 0 means HTTP error
486 - 1 means we pushed and remote head count is unchanged *or* 488 - 1 means we pushed and remote head count is unchanged *or*
488 - other values as described by addchangegroup() 490 - other values as described by addchangegroup()
489 ''' 491 '''
490 if opargs is None: 492 if opargs is None:
491 opargs = {} 493 opargs = {}
492 pushop = pushoperation(repo, remote, force, revs, newbranch, bookmarks, 494 pushop = pushoperation(repo, remote, force, revs, newbranch, bookmarks,
493 **pycompat.strkwargs(opargs)) 495 publish, **pycompat.strkwargs(opargs))
494 if pushop.remote.local(): 496 if pushop.remote.local():
495 missing = (set(pushop.repo.requirements) 497 missing = (set(pushop.repo.requirements)
496 - pushop.remote.local().supported) 498 - pushop.remote.local().supported)
497 if missing: 499 if missing:
498 msg = _("required features are not" 500 msg = _("required features are not"
628 revset = 'heads((%%ln::%%ln) %s)' % extracond 630 revset = 'heads((%%ln::%%ln) %s)' % extracond
629 # Get the list of all revs draft on remote by public here. 631 # Get the list of all revs draft on remote by public here.
630 # XXX Beware that revset break if droots is not strictly 632 # XXX Beware that revset break if droots is not strictly
631 # XXX root we may want to ensure it is but it is costly 633 # XXX root we may want to ensure it is but it is costly
632 fallback = list(unfi.set(revset, droots, pushop.fallbackheads)) 634 fallback = list(unfi.set(revset, droots, pushop.fallbackheads))
633 if not outgoing.missing: 635 if not pushop.remotephases.publishing and pushop.publish:
636 future = list(unfi.set('%ln and (not public() or %ln::)',
637 pushop.futureheads, droots))
638 elif not outgoing.missing:
634 future = fallback 639 future = fallback
635 else: 640 else:
636 # adds changeset we are going to push as draft 641 # adds changeset we are going to push as draft
637 # 642 #
638 # should not be necessary for publishing server, but because of an 643 # should not be necessary for publishing server, but because of an