comparison src/topic/discovery.py @ 1886:0504e76bfbd9

push: allow pushing new topic to non-publishing server by default This improves and fix the behavior change introduced by the new "topicmap". * Topics are properly ignored when pushing to a publishing server, * pushing new topics is allowed without --force a non-publishing server, * Pushing extra heads on a topic requires --force. Create of new head on a branch by phase movement is not properly detected for now. We'll improve that part in a later changesets. There is more awful monkey patching going on. We'll have to refactor core to get rid of them.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Sat, 12 Mar 2016 18:19:27 +0000
parents
children 68125d026b07
comparison
equal deleted inserted replaced
1885:d49f75eab6a3 1886:0504e76bfbd9
1 from mercurial import branchmap
2 from . import topicmap
3
4 def _headssummary(orig, repo, remote, outgoing):
5 publishing = ('phases' not in remote.listkeys('namespaces')
6 or bool(remote.listkeys('phases').get('publishing', False)))
7 if publishing:
8 return orig(repo, remote, outgoing)
9 oldgetitem = repo.__getitem__
10 oldrepo = repo.__class__
11 oldbranchcache = branchmap.branchcache
12 oldfilename = branchmap._filename
13 try:
14 class repocls(repo.__class__):
15 def __getitem__(self, key):
16 ctx = super(repocls, self).__getitem__(key)
17 oldbranch = ctx.branch
18 def branch():
19 branch = oldbranch()
20 topic = ctx.topic()
21 if topic:
22 branch = "%s:%s" % (branch, topic)
23 return branch
24 ctx.branch = branch
25 return ctx
26 repo.__class__ = repocls
27 branchmap.branchcache = topicmap.topiccache
28 branchmap._filename = topicmap._filename
29 summary = orig(repo, remote, outgoing)
30 for key, value in summary.iteritems():
31 if ':' in key: # This is a topic
32 if value[0] is None and value[1]:
33 summary[key] = ([value[1].pop(0)], ) + value[1:]
34 return summary
35 finally:
36 repo.__class__ = oldrepo
37 branchmap.branchcache = oldbranchcache
38 branchmap._filename = oldfilename
39
40 def wireprotobranchmap(orig, repo, proto):
41 oldrepo = repo.__class__
42 print repo
43 try:
44 class repocls(repo.__class__):
45 def branchmap(self):
46 usetopic = not self.publishing()
47 return super(repocls, self).branchmap(topic=usetopic)
48 repo.__class__ = repocls
49 return orig(repo, proto)
50 finally:
51 repo.__class__ = oldrepo