Mercurial > evolve
comparison hgext3rd/topic/__init__.py @ 4563:8b3781d9a616
branching: merge with stable
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 23 Apr 2019 13:26:35 +0200 |
parents | ede9b37572f0 b5186fe43c7c |
children | 5e8c47c553db |
comparison
equal
deleted
inserted
replaced
4530:d081cc4f5fef | 4563:8b3781d9a616 |
---|---|
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, |
179 'topic.active': 'green', | 180 'topic.active': 'green', |
180 } | 181 } |
181 | 182 |
182 __version__ = '0.15.0.dev' | 183 __version__ = '0.15.0.dev' |
183 | 184 |
184 testedwith = '4.4.2 4.5.2 4.6.2 4.7 4.8 4.9' | 185 testedwith = '4.5.2 4.6.2 4.7 4.8 4.9' |
185 minimumhgversion = '4.4' | 186 minimumhgversion = '4.5' |
186 buglink = 'https://bz.mercurial-scm.org/' | 187 buglink = 'https://bz.mercurial-scm.org/' |
187 | 188 |
188 if util.safehasattr(registrar, 'configitem'): | 189 if util.safehasattr(registrar, 'configitem'): |
189 | 190 |
190 from mercurial import configitems | 191 from mercurial import configitems |
254 context.basectx.topicidx = _contexttopicidx | 255 context.basectx.topicidx = _contexttopicidx |
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+$') |
260 | |
261 hastopicext = common.hastopicext | |
259 | 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:]) |
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__): |
370 | 373 |
374 # attribute for other code to distinct between repo with topic and repo without | |
375 hastopicext = True | |
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 |
375 | 381 |
557 """:topicidx: Integer. Index of the changeset as a stack alias""" | 563 """:topicidx: Integer. Index of the changeset as a stack alias""" |
558 return args['ctx'].topicidx() | 564 return args['ctx'].topicidx() |
559 | 565 |
560 def wrapinit(orig, self, repo, *args, **kwargs): | 566 def wrapinit(orig, self, repo, *args, **kwargs): |
561 orig(self, repo, *args, **kwargs) | 567 orig(self, repo, *args, **kwargs) |
568 if not hastopicext(repo): | |
569 return | |
562 if constants.extrakey not in self._extra: | 570 if constants.extrakey not in self._extra: |
563 if getattr(repo, 'currenttopic', ''): | 571 if getattr(repo, 'currenttopic', ''): |
564 self._extra[constants.extrakey] = repo.currenttopic | 572 self._extra[constants.extrakey] = repo.currenttopic |
565 else: | 573 else: |
566 # Empty key will be dropped from extra by another hack at the changegroup level | 574 # Empty key will be dropped from extra by another hack at the changegroup level |
1112 topicmode = _validmode[0] | 1120 topicmode = _validmode[0] |
1113 | 1121 |
1114 return topicmode | 1122 return topicmode |
1115 | 1123 |
1116 def commitwrap(orig, ui, repo, *args, **opts): | 1124 def commitwrap(orig, ui, repo, *args, **opts): |
1125 if not hastopicext(repo): | |
1126 return orig(ui, repo, *args, **opts) | |
1117 with repo.wlock(): | 1127 with repo.wlock(): |
1118 topicmode = _configtopicmode(ui) | 1128 topicmode = _configtopicmode(ui) |
1119 ismergecommit = len(repo[None].parents()) == 2 | 1129 ismergecommit = len(repo[None].parents()) == 2 |
1120 | 1130 |
1121 notopic = not repo.currenttopic | 1131 notopic = not repo.currenttopic |
1153 f.write(randomname.randomtopicname(ui)) | 1163 f.write(randomname.randomtopicname(ui)) |
1154 return orig(ui, repo, *args, **opts) | 1164 return orig(ui, repo, *args, **opts) |
1155 | 1165 |
1156 def committextwrap(orig, repo, ctx, subs, extramsg): | 1166 def committextwrap(orig, repo, ctx, subs, extramsg): |
1157 ret = orig(repo, ctx, subs, extramsg) | 1167 ret = orig(repo, ctx, subs, extramsg) |
1158 t = repo.currenttopic | 1168 if hastopicext(repo): |
1159 if t: | 1169 t = repo.currenttopic |
1160 ret = ret.replace("\nHG: branch", | 1170 if t: |
1161 "\nHG: topic '%s'\nHG: branch" % t) | 1171 ret = ret.replace("\nHG: branch", |
1172 "\nHG: topic '%s'\nHG: branch" % t) | |
1162 return ret | 1173 return ret |
1163 | 1174 |
1164 def pushoutgoingwrap(orig, ui, repo, *args, **opts): | 1175 def pushoutgoingwrap(orig, ui, repo, *args, **opts): |
1165 if opts.get('topic'): | 1176 if opts.get('topic'): |
1166 topicrevs = repo.revs('topic(%s) - obsolete()', opts['topic']) | 1177 topicrevs = repo.revs('topic(%s) - obsolete()', opts['topic']) |
1173 wlock = repo.wlock() | 1184 wlock = repo.wlock() |
1174 isrebase = False | 1185 isrebase = False |
1175 ist0 = False | 1186 ist0 = False |
1176 try: | 1187 try: |
1177 ret = orig(repo, node, branchmerge, force, *args, **kwargs) | 1188 ret = orig(repo, node, branchmerge, force, *args, **kwargs) |
1189 if not hastopicext(repo): | |
1190 return ret | |
1178 # The mergeupdatewrap function makes the destination's topic as the | 1191 # The mergeupdatewrap function makes the destination's topic as the |
1179 # current topic. This is right for merge but wrong for rebase. We check | 1192 # current topic. This is right for merge but wrong for rebase. We check |
1180 # if rebase is running and update the currenttopic to topic of new | 1193 # if rebase is running and update the currenttopic to topic of new |
1181 # rebased commit. We have explicitly stored in config if rebase is | 1194 # rebased commit. We have explicitly stored in config if rebase is |
1182 # running. | 1195 # running. |