comparison hgext3rd/topic/__init__.py @ 3157:f286eefbd20d

topic: add an option to enforce a single head per name in a repository
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 30 Oct 2017 19:24:14 +0100
parents 95c77ef938ef
children 678a9802c56b
comparison
equal deleted inserted replaced
3156:31493a1b0e39 3157:f286eefbd20d
61 topic-mode = warning # print a warning 61 topic-mode = warning # print a warning
62 topic-mode = enforce # abort the commit (except for merge) 62 topic-mode = enforce # abort the commit (except for merge)
63 topic-mode = enforce-all # abort the commit (even for merge) 63 topic-mode = enforce-all # abort the commit (even for merge)
64 topic-mode = random # use a randomized generated topic (except for merge) 64 topic-mode = random # use a randomized generated topic (except for merge)
65 topic-mode = random-all # use a randomized generated topic (even for merge) 65 topic-mode = random-all # use a randomized generated topic (even for merge)
66
67 Single head enforcing
68 =====================
69
70 The extensions come with an option to enforce that there is only one heads for
71 each name in the repository at any time.
72
73 [experimental]
74 enforce-single-head = yes
66 """ 75 """
67 76
68 from __future__ import absolute_import 77 from __future__ import absolute_import
69 78
70 import functools 79 import functools
97 ) 106 )
98 107
99 from . import ( 108 from . import (
100 compat, 109 compat,
101 constants, 110 constants,
111 flow,
102 revset as topicrevset, 112 revset as topicrevset,
103 destination, 113 destination,
104 stack, 114 stack,
105 topicmap, 115 topicmap,
106 discovery, 116 discovery,
150 configitem = registrar.configitem(configtable) 160 configitem = registrar.configitem(configtable)
151 161
152 configitem('experimental', 'enforce-topic', 162 configitem('experimental', 'enforce-topic',
153 default=False, 163 default=False,
154 ) 164 )
165 configitem('experimental', 'enforce-single-head',
166 default=False,
167 )
155 configitem('experimental', 'topic-mode', 168 configitem('experimental', 'topic-mode',
156 default=None, 169 default=None,
157 ) 170 )
158 configitem('_internal', 'keep-topic', 171 configitem('_internal', 'keep-topic',
159 default=False, 172 default=False,
365 def transaction(self, desc, *a, **k): 378 def transaction(self, desc, *a, **k):
366 ctr = self.currenttransaction() 379 ctr = self.currenttransaction()
367 tr = super(topicrepo, self).transaction(desc, *a, **k) 380 tr = super(topicrepo, self).transaction(desc, *a, **k)
368 if desc in ('strip', 'repair') or ctr is not None: 381 if desc in ('strip', 'repair') or ctr is not None:
369 return tr 382 return tr
383
384 if repo.ui.configbool('experimental', 'enforce-single-head'):
385 reporef = weakref.ref(self)
386 origvalidator = tr.validator
387
388 def validator(tr2):
389 repo = reporef()
390 flow.enforcesinglehead(repo, tr2)
391 origvalidator(tr2)
392 tr.validator = validator
370 393
371 # real transaction start 394 # real transaction start
372 ct = self.currenttopic 395 ct = self.currenttopic
373 if not ct: 396 if not ct:
374 return tr 397 return tr