annotate contrib/nopushpublish.py @ 402:8ef1096ee5ab

move the extension to contrib to prepare merge with mutable history
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Mon, 30 Jul 2012 14:45:08 +0200
parents nopushpublish.py@76df267fd76c
children 984be08ef504
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
401
76df267fd76c some doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 400
diff changeset
1 # Extension which prevent changeset to be turn public by push operation
400
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
2
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
3 from mercurial import extensions, util
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
4 from mercurial import discovery
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
5
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
6 def checkpublish(orig, repo, remote, outgoing, *args):
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
7
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
8 # is remote publishing?
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
9 publish = True
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
10 if 'phases' in remote.listkeys('namespaces'):
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
11 remotephases = remote.listkeys('phases')
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
12 publish = remotephases.get('publishing', False)
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
13
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
14 npublish = 0
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
15 if publish:
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
16 for rev in outgoing.missing:
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
17 if repo[rev].phase():
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
18 npublish += 1
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
19 if npublish:
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
20 repo.ui.warn("Push would publish %s changesets" % npublish)
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
21
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
22 ret = orig(repo, remote, outgoing, *args)
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
23 if npublish:
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
24 raise util.Abort("Publishing push forbiden",
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
25 hint="Use `hg phase -p <rev>` to manually publish them")
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
26
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
27 return ret
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
28
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
29 def uisetup(ui):
1e72a3cc2cc3 initial import
David Douard <david.douard@logilab.fr>
parents:
diff changeset
30 extensions.wrapfunction(discovery, 'checkheads', checkpublish)