comparison nopushpublish.py @ 400:1e72a3cc2cc3

initial import Simple extension that prevent from pushing in a publishing remote repo.
author David Douard <david.douard@logilab.fr>
date Fri, 25 May 2012 11:21:43 +0200
parents
children 76df267fd76c
comparison
equal deleted inserted replaced
-1:000000000000 400:1e72a3cc2cc3
1 #
2
3 from mercurial import extensions, util
4 from mercurial import discovery
5
6 def checkpublish(orig, repo, remote, outgoing, *args):
7
8 # is remote publishing?
9 publish = True
10 if 'phases' in remote.listkeys('namespaces'):
11 remotephases = remote.listkeys('phases')
12 publish = remotephases.get('publishing', False)
13
14 npublish = 0
15 if publish:
16 for rev in outgoing.missing:
17 if repo[rev].phase():
18 npublish += 1
19 if npublish:
20 repo.ui.warn("Push would publish %s changesets" % npublish)
21
22 ret = orig(repo, remote, outgoing, *args)
23 if npublish:
24 raise util.Abort("Publishing push forbiden",
25 hint="Use `hg phase -p <rev>` to manually publish them")
26
27 return ret
28
29 def uisetup(ui):
30 extensions.wrapfunction(discovery, 'checkheads', checkpublish)