contrib/nopushpublish.py
author Laurent Charignon <lcharignon@fb.com>
Sun, 17 Jan 2016 16:55:40 -0800
changeset 1589 d6630a6bff86
parent 413 984be08ef504
child 1670 4f5e915ddb71
permissions -rw-r--r--
touch: prompt the user for what to do with the revived changeset This patch improves our interface for reviving changesets. This patch makes touch not assume that the user wants to create divergence by default and gives a prompt instead. The prompt is skipped for changeset that have no living successor as no divergence would be created by reviving them anyway. To restore the previous behavior, one should now use the --allowdivergence flag. The prompt looks like: [10] <description> reviving this changeset will create divergence unless you make a duplicate. (a)llow divergence or (d)uplicate the changeset? a In further patches we will want to add one more choice to that prompt, for example having a marker between the old and revived nodes but no divergence displayed on the UI.

# 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 forbiden",
                         hint="Use `hg phase -p <rev>` to manually publish them")

    return ret

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