Mercurial > evolve
comparison hgext3rd/topic/__init__.py @ 4531:1d1f8f56daac stable
topic: introduce a `hastopicext(repo)` function
This function check if a repository has the extension enabled or not.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 18 Apr 2019 11:12:58 +0200 |
parents | f6099a171a9d |
children | 659b6f548fc1 |
comparison
equal
deleted
inserted
replaced
4527:65fd9f2982b4 | 4531:1d1f8f56daac |
---|---|
137 templatekw, | 137 templatekw, |
138 util, | 138 util, |
139 ) | 139 ) |
140 | 140 |
141 from . import ( | 141 from . import ( |
142 common, | |
142 compat, | 143 compat, |
143 constants, | 144 constants, |
144 destination, | 145 destination, |
145 discovery, | 146 discovery, |
146 flow, | 147 flow, |
255 | 256 |
256 stackrev = re.compile(r'^s\d+$') | 257 stackrev = re.compile(r'^s\d+$') |
257 topicrev = re.compile(r'^t\d+$') | 258 topicrev = re.compile(r'^t\d+$') |
258 branchrev = re.compile(r'^b\d+$') | 259 branchrev = re.compile(r'^b\d+$') |
259 | 260 |
261 hastopicext = common.hastopicext | |
262 | |
260 def _namemap(repo, name): | 263 def _namemap(repo, name): |
261 revs = None | 264 revs = None |
262 if stackrev.match(name): | 265 if stackrev.match(name): |
263 idx = int(name[1:]) | 266 idx = int(name[1:]) |
264 tname = topic = repo.currenttopic | 267 tname = topic = repo.currenttopic |
365 if repo.ui.config('experimental', 'thg.displaynames') is None: | 368 if repo.ui.config('experimental', 'thg.displaynames') is None: |
366 repo.ui.setconfig('experimental', 'thg.displaynames', 'topics', | 369 repo.ui.setconfig('experimental', 'thg.displaynames', 'topics', |
367 source='topic-extension') | 370 source='topic-extension') |
368 | 371 |
369 class topicrepo(repo.__class__): | 372 class topicrepo(repo.__class__): |
373 | |
374 # attribute for other code to distinct between repo with topic and repo without | |
375 hastopicext = True | |
370 | 376 |
371 def _restrictcapabilities(self, caps): | 377 def _restrictcapabilities(self, caps): |
372 caps = super(topicrepo, self)._restrictcapabilities(caps) | 378 caps = super(topicrepo, self)._restrictcapabilities(caps) |
373 caps.add('topics') | 379 caps.add('topics') |
374 return caps | 380 return caps |