hgext3rd/topic/__init__.py
changeset 4563 8b3781d9a616
parent 4526 ede9b37572f0
parent 4556 b5186fe43c7c
child 4574 5e8c47c553db
--- a/hgext3rd/topic/__init__.py	Wed Apr 17 00:20:44 2019 +0530
+++ b/hgext3rd/topic/__init__.py	Tue Apr 23 13:26:35 2019 +0200
@@ -139,6 +139,7 @@
 )
 
 from . import (
+    common,
     compat,
     constants,
     destination,
@@ -181,8 +182,8 @@
 
 __version__ = '0.15.0.dev'
 
-testedwith = '4.4.2 4.5.2 4.6.2 4.7 4.8 4.9'
-minimumhgversion = '4.4'
+testedwith = '4.5.2 4.6.2 4.7 4.8 4.9'
+minimumhgversion = '4.5'
 buglink = 'https://bz.mercurial-scm.org/'
 
 if util.safehasattr(registrar, 'configitem'):
@@ -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')
@@ -559,6 +565,8 @@
 
 def wrapinit(orig, self, repo, *args, **kwargs):
     orig(self, repo, *args, **kwargs)
+    if not hastopicext(repo):
+        return
     if constants.extrakey not in self._extra:
         if getattr(repo, 'currenttopic', ''):
             self._extra[constants.extrakey] = repo.currenttopic
@@ -1114,6 +1122,8 @@
     return topicmode
 
 def commitwrap(orig, ui, repo, *args, **opts):
+    if not hastopicext(repo):
+        return orig(ui, repo, *args, **opts)
     with repo.wlock():
         topicmode = _configtopicmode(ui)
         ismergecommit = len(repo[None].parents()) == 2
@@ -1155,10 +1165,11 @@
 
 def committextwrap(orig, repo, ctx, subs, extramsg):
     ret = orig(repo, ctx, subs, extramsg)
-    t = repo.currenttopic
-    if t:
-        ret = ret.replace("\nHG: branch",
-                          "\nHG: topic '%s'\nHG: branch" % t)
+    if hastopicext(repo):
+        t = repo.currenttopic
+        if t:
+            ret = ret.replace("\nHG: branch",
+                              "\nHG: topic '%s'\nHG: branch" % t)
     return ret
 
 def pushoutgoingwrap(orig, ui, repo, *args, **opts):
@@ -1175,6 +1186,8 @@
     ist0 = False
     try:
         ret = orig(repo, node, branchmerge, force, *args, **kwargs)
+        if not hastopicext(repo):
+            return ret
         # The mergeupdatewrap function makes the destination's topic as the
         # current topic. This is right for merge but wrong for rebase. We check
         # if rebase is running and update the currenttopic to topic of new