contrib/nopushpublish.py
author Manuel Jacob <me@manueljacob.de>
Wed, 11 Mar 2020 16:04:06 +0100
branchstable
changeset 5206 dc3571a37b56
parent 1670 4f5e915ddb71
permissions -rw-r--r--
evolve: support ancestor of orphan split with unrelated changeset in between This is done by searching for roots and heads within the range delimited on both sides by the target revs instead of just within the target revs. Example: o 5 | o 4 | o 3 | | * 2 | | | x 1 |/ o 0 1 is obsoleted by 3 and 5. We are considering the case when 2 gets evolved. Before the change, both roots and heads were [3, 5]. The user was offered a choice between 3 and 5 as the destination. After the change, roots are [3] and heads are [5]. 5 is chosen as the destination.

# Extension which prevent changeset to be turn public by push operation
#
# Copyright 2011 Logilab SA        <contact@logilab.fr>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.


from mercurial import extensions, util
from mercurial import discovery

def checkpublish(orig, repo, remote, outgoing, *args):

    # is remote publishing?
    publish = True
    if 'phases' in remote.listkeys('namespaces'):
        remotephases = remote.listkeys('phases')
        publish = remotephases.get('publishing', False)

    npublish = 0
    if publish:
        for rev in outgoing.missing:
            if repo[rev].phase():
                npublish += 1
    if npublish:
        repo.ui.warn("Push would publish %s changesets" % npublish)

    ret = orig(repo, remote, outgoing, *args)
    if npublish:
        raise util.Abort("Publishing push forbidden",
                         hint="Use `hg phase -p <rev>` to manually publish them")

    return ret

def uisetup(ui):
    extensions.wrapfunction(discovery, 'checkheads', checkpublish)