Mercurial > public > mercurial-scm > evolve
diff 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 |
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py Sun Oct 15 00:07:21 2017 +0530 +++ b/hgext3rd/topic/__init__.py Mon Oct 30 19:24:14 2017 +0100 @@ -63,6 +63,15 @@ topic-mode = enforce-all # abort the commit (even for merge) topic-mode = random # use a randomized generated topic (except for merge) topic-mode = random-all # use a randomized generated topic (even for merge) + +Single head enforcing +===================== + +The extensions come with an option to enforce that there is only one heads for +each name in the repository at any time. + + [experimental] + enforce-single-head = yes """ from __future__ import absolute_import @@ -99,6 +108,7 @@ from . import ( compat, constants, + flow, revset as topicrevset, destination, stack, @@ -152,6 +162,9 @@ configitem('experimental', 'enforce-topic', default=False, ) + configitem('experimental', 'enforce-single-head', + default=False, + ) configitem('experimental', 'topic-mode', default=None, ) @@ -368,6 +381,16 @@ if desc in ('strip', 'repair') or ctr is not None: return tr + if repo.ui.configbool('experimental', 'enforce-single-head'): + reporef = weakref.ref(self) + origvalidator = tr.validator + + def validator(tr2): + repo = reporef() + flow.enforcesinglehead(repo, tr2) + origvalidator(tr2) + tr.validator = validator + # real transaction start ct = self.currenttopic if not ct: