Mercurial > evolve
comparison src/topic/__init__.py @ 1885:d49f75eab6a3
topic: take topic in account for all branch head computation
This changeset introduce a "topicmap" that is tracking not just the head of all
branches, but the heads of all branch+topic pair. Including the head of the part
of the branch without any topic. In practice this means that BRANCHNAME now
resolve to the tipmost part for the branch without topic and impact various
other logic like head checking during push and default destination for update and
merge (these aspect will need adjustment in later changesets).
The on-the-fly-temporary-monkey-patching process is pretty horrible, but allow
to move forward without waiting on having core patched.
We use 'branch:topic' as the branchmap key, this is a small and easy hack that
help use a lot for (future) support of heads discovery/checking and on disc
cache. I'm not sure it is worthwhile to improve this until an implementation
into core.
Note that this changeset change the branchmap in all cases, including during
exchange, see next changeset for improved behavior.
We also currently have the on-disk cache disabled because the core branchmap is
lacking phase information in its cache key. This will get done in a later
changesets
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Sat, 12 Mar 2016 15:36:17 +0000 |
parents | 8a53f99d9061 |
children | 0504e76bfbd9 |
comparison
equal
deleted
inserted
replaced
1884:8a53f99d9061 | 1885:d49f75eab6a3 |
---|---|
24 from mercurial import node | 24 from mercurial import node |
25 from mercurial import obsolete | 25 from mercurial import obsolete |
26 from mercurial import patch | 26 from mercurial import patch |
27 from mercurial import phases | 27 from mercurial import phases |
28 from mercurial import util | 28 from mercurial import util |
29 from mercurial import branchmap | |
29 | 30 |
30 from . import constants | 31 from . import constants |
31 from . import revset as topicrevset | 32 from . import revset as topicrevset |
32 from . import destination | 33 from . import destination |
34 from . import topicmap | |
33 | 35 |
34 cmdtable = {} | 36 cmdtable = {} |
35 command = cmdutil.command(cmdtable) | 37 command = cmdutil.command(cmdtable) |
36 | 38 |
37 testedwith = '3.7' | 39 testedwith = '3.7' |
89 return topics | 91 return topics |
90 | 92 |
91 @property | 93 @property |
92 def currenttopic(self): | 94 def currenttopic(self): |
93 return self.vfs.tryread('topic') | 95 return self.vfs.tryread('topic') |
96 | |
97 def branchmap(self, topic=True): | |
98 if not topic: | |
99 super(topicrepo, self).branchmap() | |
100 oldbranchcache = branchmap.branchcache | |
101 oldfilename = branchmap._filename | |
102 oldcaches = getattr(self, '_branchcaches', {}) | |
103 try: | |
104 branchmap.branchcache = topicmap.topiccache | |
105 branchmap._filename = topicmap._filename | |
106 self._branchcaches = getattr(self, '_topiccaches', {}) | |
107 branchmap.updatecache(self) | |
108 self._topiccaches = self._branchcaches | |
109 return self._topiccaches[self.filtername] | |
110 finally: | |
111 self._branchcaches = oldcaches | |
112 branchmap.branchcache = oldbranchcache | |
113 branchmap._filename = oldfilename | |
114 | |
115 def invalidatecaches(self): | |
116 super(topicrepo, self).invalidatecaches() | |
117 if '_topiccaches' in vars(self.unfiltered()): | |
118 self.unfiltered()._topiccaches.clear() | |
94 | 119 |
95 repo.__class__ = topicrepo | 120 repo.__class__ = topicrepo |
96 if util.safehasattr(repo, 'names'): | 121 if util.safehasattr(repo, 'names'): |
97 repo.names.addnamespace(namespaces.namespace( | 122 repo.names.addnamespace(namespaces.namespace( |
98 'topics', 'topic', namemap=_namemap, nodemap=_nodemap, | 123 'topics', 'topic', namemap=_namemap, nodemap=_nodemap, |