Commits

Yuya Nishihara committed cf273bb

hgext: import textful extension 301e1f8f2a78

Comments (0)

Files changed (1)

dot.hgext/textful/__init__.py

     def textfulsetup(ui, filters):
         filters.append(somefilter)
 """
-import errno
-from mercurial import extensions, dispatch, error, util
+import errno, sys
+from mercurial import extensions, dispatch, error, localrepo, util
 from mercurial.i18n import _
 
-# TODO: localrepo.(un)filteredpropertycache ?
-propertycache = util.propertycache
+try:
+    unfilteredpropertycache = localrepo.unfilteredpropertycache
+except AttributeError:  # hg<2.5
+    unfilteredpropertycache = util.propertycache
+
+testedwith = '2.4.2 2.5-rc'
+buglink = 'https://bitbucket.org/yuja/hgext-textful/issues'
 
 _filters = []
 """List of fctx.data filters; extended by sub-extensions"""
 @clswrapper
 def wraprepo(parcls):
     class textfulrepo(parcls):
-        @propertycache
+        @unfilteredpropertycache
         def _textfulenabled(self):
             return self.ui.configbool('textful', '_enabled')
 
 
     return textfulrepo
 
+def _loadable(ui):
+    return not ui.plain() and 'tortoisehg' not in sys.modules
+
 def reposetup(ui, repo):
-    if ui.plain():
+    if not _loadable(ui):
         return
     wraprepo(repo)
 
 def uisetup(ui):
-    if ui.plain():
+    if not _loadable(ui):
         return
 
     def textfulcmd(orig, lui, repo, cmd, fullargs, ui, options, d, cmdpats,