Patchwork [8,of,9] keyword: use _keywordkwt of repository instead of kwtools['templater']

login
register
mail settings
Submitter Katsunori FUJIWARA
Date June 25, 2017, 7:09 p.m.
Message ID <b534af046ded2dbbb6d5.1498417781@speaknoevil>
Download mbox | patch
Permalink /patch/21711/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - June 25, 2017, 7:09 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1498416377 -32400
#      Mon Jun 26 03:46:17 2017 +0900
# Node ID b534af046ded2dbbb6d537e12cff7c87f1159629
# Parent  ec9915b24ba6de7c5bb4464912a11e46950aad60
keyword: use _keywordkwt of repository instead of kwtools['templater']

Now, kwtemplater instance can be obtained via _keywordkwt property of
repository.

Patch

diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -165,7 +165,7 @@  def svnutcdate(text):
     return util.datestr((util.parsedate(text)[0], 0), '%Y-%m-%d %H:%M:%SZ')
 
 # make keyword tools accessible
-kwtools = {'templater': None, 'hgcmd': ''}
+kwtools = {'hgcmd': ''}
 
 def _defaultkwmaps(ui):
     '''Returns default keywordmaps according to keywordset configuration.'''
@@ -385,7 +385,7 @@  def _kwfwrite(ui, repo, expand, *pats, *
     wctx = repo[None]
     if len(wctx.parents()) > 1:
         raise error.Abort(_('outstanding uncommitted merge'))
-    kwt = kwtools['templater']
+    kwt = getattr(repo, '_keywordkwt', None)
     with repo.wlock():
         status = _status(ui, repo, wctx, kwt, *pats, **opts)
         if status.modified or status.added or status.removed or status.deleted:
@@ -529,7 +529,7 @@  def files(ui, repo, *pats, **opts):
       I = ignored
       i = ignored (not tracked)
     '''
-    kwt = kwtools['templater']
+    kwt = getattr(repo, '_keywordkwt', None)
     wctx = repo[None]
     status = _status(ui, repo, wctx, kwt, *pats, **opts)
     if pats:
@@ -614,7 +614,7 @@  def reposetup(ui, repo):
     if not inc:
         return
 
-    kwtools['templater'] = kwt = kwtemplater(ui, repo, inc, exc)
+    kwt = kwtemplater(ui, repo, inc, exc)
 
     class kwrepo(repo.__class__):
         def file(self, f):