Patchwork [5,of,8] exthelper: reintroduce the ability to register templates

login
register
mail settings
Submitter Matt Harbison
Date Dec. 28, 2018, 6:47 a.m.
Message ID <75ad6f9b2df7c8f7d4d8.1545979639@Envy>
Download mbox | patch
Permalink /patch/37374/
State Accepted
Headers show

Comments

Matt Harbison - Dec. 28, 2018, 6:47 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1545965722 18000
#      Thu Dec 27 21:55:22 2018 -0500
# Node ID 75ad6f9b2df7c8f7d4d8b2613242cc46298e618c
# Parent  2b04921466a9ff3428ac83a0ae9da35ee2d75dd5
exthelper: reintroduce the ability to register templates

Same mechanism as revsets earlier in this series.  The LFS extension is updated
to provide test coverage.

This also seems to make the test failure around issue6033 mentioned in
0a7f582f6f1f much less regular on Windows.

Patch

diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py
--- a/hgext/lfs/__init__.py
+++ b/hgext/lfs/__init__.py
@@ -169,6 +169,7 @@  configtable = eh.configtable
 extsetup = eh.finalextsetup
 uisetup = eh.finaluisetup
 reposetup = eh.finalreposetup
+templatekeyword = eh.templatekeyword
 
 eh.configitem('experimental', 'lfs.serve',
     default=True,
@@ -199,7 +200,6 @@  eh.configitem('lfs', 'track',
 eh.configitem('lfs', 'retry',
     default=5,
 )
-templatekeyword = registrar.templatekeyword()
 filesetpredicate = registrar.filesetpredicate()
 
 lfsprocessor = (
@@ -347,7 +347,7 @@  def lfsfileset(mctx, x):
         return wrapper.pointerfromctx(ctx, f, removed=True) is not None
     return mctx.predicate(lfsfilep, predrepr='<lfs>')
 
-@templatekeyword('lfs_files', requires={'ctx'})
+@eh.templatekeyword('lfs_files', requires={'ctx'})
 def lfsfiles(context, mapping):
     """List of strings. All files modified, added, or removed by this
     changeset."""
diff --git a/mercurial/exthelper.py b/mercurial/exthelper.py
--- a/mercurial/exthelper.py
+++ b/mercurial/exthelper.py
@@ -41,6 +41,7 @@  class exthelper(object):
         self.configtable = {}
         self.configitem = registrar.configitem(self.configtable)
         self.revsetpredicate = registrar.revsetpredicate()
+        self.templatekeyword = registrar.templatekeyword()
 
     def merge(self, other):
         self._uicallables.extend(other._uicallables)
@@ -48,6 +49,7 @@  class exthelper(object):
         self._extcallables.extend(other._extcallables)
         self._repocallables.extend(other._repocallables)
         self.revsetpredicate._table.update(other.revsetpredicate._table)
+        self.templatekeyword._table.update(other.templatekeyword._table)
         self._commandwrappers.extend(other._commandwrappers)
         self._extcommandwrappers.extend(other._extcommandwrappers)
         self._functionwrappers.extend(other._functionwrappers)