# HG changeset patch # User Pierre-Yves David # Date 1555578778 -7200 # Node ID 1d1f8f56daacff64f58471b3d999af53d69ea827 # Parent 65fd9f2982b42a116196ad170163d7dc1c4b0c9e topic: introduce a `hastopicext(repo)` function This function check if a repository has the extension enabled or not. diff -r 65fd9f2982b4 -r 1d1f8f56daac hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py Wed Apr 17 21:39:28 2019 +0200 +++ b/hgext3rd/topic/__init__.py Thu Apr 18 11:12:58 2019 +0200 @@ -139,6 +139,7 @@ ) from . import ( + common, compat, constants, destination, @@ -257,6 +258,8 @@ topicrev = re.compile(r'^t\d+$') branchrev = re.compile(r'^b\d+$') +hastopicext = common.hastopicext + def _namemap(repo, name): revs = None if stackrev.match(name): @@ -368,6 +371,9 @@ class topicrepo(repo.__class__): + # attribute for other code to distinct between repo with topic and repo without + hastopicext = True + def _restrictcapabilities(self, caps): caps = super(topicrepo, self)._restrictcapabilities(caps) caps.add('topics') diff -r 65fd9f2982b4 -r 1d1f8f56daac hgext3rd/topic/common.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hgext3rd/topic/common.py Thu Apr 18 11:12:58 2019 +0200 @@ -0,0 +1,8 @@ +# Copyright 2019 Pierre-Yves David +# +# This software may be used and distributed according to the terms of the +# GNU General Public License version 2 or any later version. + +def hastopicext(repo): + """True if the repo use the topic extension""" + return getattr(repo, 'hastopicext', False)