Mercurial > evolve
comparison src/topic/__init__.py @ 1889:d9b929bcc3ad
topicmap: ensure that 'served' view is updated with topicmap
There is multiple place that explicitly update the 'served' branchmap to ensure
it stay up to date. We ensure it use the proper topicmap in this case.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Mon, 14 Mar 2016 00:15:54 +0000 |
parents | dfaf0de6f4d8 |
children | e846b8f402d0 |
comparison
equal
deleted
inserted
replaced
1888:dfaf0de6f4d8 | 1889:d9b929bcc3ad |
---|---|
14 import contextlib | 14 import contextlib |
15 | 15 |
16 from mercurial.i18n import _ | 16 from mercurial.i18n import _ |
17 from mercurial import branchmap | 17 from mercurial import branchmap |
18 from mercurial import bundle2 | 18 from mercurial import bundle2 |
19 from mercurial import changegroup | |
19 from mercurial import cmdutil | 20 from mercurial import cmdutil |
20 from mercurial import commands | 21 from mercurial import commands |
21 from mercurial import context | 22 from mercurial import context |
22 from mercurial import discovery as discoverymod | 23 from mercurial import discovery as discoverymod |
23 from mercurial import error | 24 from mercurial import error |
78 finally: | 79 finally: |
79 repo._branchcaches = oldcaches | 80 repo._branchcaches = oldcaches |
80 branchmap.branchcache = oldbranchcache | 81 branchmap.branchcache = oldbranchcache |
81 branchmap._filename = oldfilename | 82 branchmap._filename = oldfilename |
82 | 83 |
84 def cgapply(orig, repo, *args, **kwargs): | |
85 with usetopicmap(repo): | |
86 return orig(repo, *args, **kwargs) | |
87 | |
83 def reposetup(ui, repo): | 88 def reposetup(ui, repo): |
84 orig = repo.__class__ | 89 orig = repo.__class__ |
85 if not isinstance(repo, localrepo.localrepository): | 90 if not isinstance(repo, localrepo.localrepository): |
86 return # this can be a peer in the ssh case (puzzling) | 91 return # this can be a peer in the ssh case (puzzling) |
87 class topicrepo(repo.__class__): | 92 class topicrepo(repo.__class__): |
104 ctx.extra().get('amend_source') and | 109 ctx.extra().get('amend_source') and |
105 ctx.topic() and | 110 ctx.topic() and |
106 not self.currenttopic): | 111 not self.currenttopic): |
107 # we are amending and need to remove a topic | 112 # we are amending and need to remove a topic |
108 del ctx.extra()[constants.extrakey] | 113 del ctx.extra()[constants.extrakey] |
109 return orig.commitctx(self, ctx, error=error) | 114 with usetopicmap(self): |
115 return orig.commitctx(self, ctx, error=error) | |
110 | 116 |
111 @property | 117 @property |
112 def topics(self): | 118 def topics(self): |
113 topics = set(['', self.currenttopic]) | 119 topics = set(['', self.currenttopic]) |
114 for c in self.set('not public()'): | 120 for c in self.set('not public()'): |
124 if not topic: | 130 if not topic: |
125 super(topicrepo, self).branchmap() | 131 super(topicrepo, self).branchmap() |
126 with usetopicmap(self): | 132 with usetopicmap(self): |
127 branchmap.updatecache(self) | 133 branchmap.updatecache(self) |
128 return self._topiccaches[self.filtername] | 134 return self._topiccaches[self.filtername] |
135 | |
136 def destroyed(self, *args, **kwargs): | |
137 with usetopicmap(self): | |
138 return super(topicrepo, self).destroyed(*args, **kwargs) | |
129 | 139 |
130 def invalidatecaches(self): | 140 def invalidatecaches(self): |
131 super(topicrepo, self).invalidatecaches() | 141 super(topicrepo, self).invalidatecaches() |
132 if '_topiccaches' in vars(self.unfiltered()): | 142 if '_topiccaches' in vars(self.unfiltered()): |
133 self.unfiltered()._topiccaches.clear() | 143 self.unfiltered()._topiccaches.clear() |
306 extensions.wrapfunction(wireproto, 'branchmap', discovery.wireprotobranchmap) | 316 extensions.wrapfunction(wireproto, 'branchmap', discovery.wireprotobranchmap) |
307 extensions.wrapfunction(bundle2, 'handlecheckheads', discovery.handlecheckheads) | 317 extensions.wrapfunction(bundle2, 'handlecheckheads', discovery.handlecheckheads) |
308 bundle2.handlecheckheads.params = frozenset() # we need a proper wrape b2 part stuff | 318 bundle2.handlecheckheads.params = frozenset() # we need a proper wrape b2 part stuff |
309 bundle2.parthandlermapping['check:heads'] = bundle2.handlecheckheads | 319 bundle2.parthandlermapping['check:heads'] = bundle2.handlecheckheads |
310 extensions.wrapfunction(exchange, '_pushb2phases', discovery._pushb2phases) | 320 extensions.wrapfunction(exchange, '_pushb2phases', discovery._pushb2phases) |
321 extensions.wrapfunction(changegroup.cg1unpacker, 'apply', cgapply) | |
311 exchange.b2partsgenmapping['phase'] = exchange._pushb2phases | 322 exchange.b2partsgenmapping['phase'] = exchange._pushb2phases |
312 topicrevset.modsetup() | 323 topicrevset.modsetup() |
313 cmdutil.summaryhooks.add('topic', summaryhook) | 324 cmdutil.summaryhooks.add('topic', summaryhook) |
314 | 325 |
315 if util.safehasattr(cmdutil, 'extraexport'): | 326 if util.safehasattr(cmdutil, 'extraexport'): |