Patchwork [10,of,10] templatekw: deprecate showdict() and showlist() (API)

login
register
mail settings
Submitter Yuya Nishihara
Date March 2, 2018, 1:52 a.m.
Message ID <d6bbe8dfafaeb32e48b3.1519955520@mimosa>
Download mbox | patch
Permalink /patch/28654/
State Accepted
Headers show

Comments

Yuya Nishihara - March 2, 2018, 1:52 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1519554875 -32400
#      Sun Feb 25 19:34:35 2018 +0900
# Node ID d6bbe8dfafaeb32e48b38c1815dda69ca0854a5e
# Parent  0e49bbe25cdc0eb0898737dd4f584e89f8b8eb6a
templatekw: deprecate showdict() and showlist() (API)

.. api::

   templatekw.showdict() and showlist() are deprecated in favor of new
   (context, mapping) API. Switch the keyword function to new API and use
   templatekw.compatdict() and compatlist() instead.
Augie Fackler - March 2, 2018, 9:42 p.m.
On Thu, Mar 01, 2018 at 08:52:00PM -0500, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1519554875 -32400
> #      Sun Feb 25 19:34:35 2018 +0900
> # Node ID d6bbe8dfafaeb32e48b38c1815dda69ca0854a5e
> # Parent  0e49bbe25cdc0eb0898737dd4f584e89f8b8eb6a
> templatekw: deprecate showdict() and showlist() (API)

queued, thanks

Patch

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -161,11 +161,19 @@  def compatlist(context, mapping, name, d
 
 def showdict(name, data, mapping, plural=None, key='key', value='value',
              fmt='%s=%s', separator=' '):
+    ui = mapping.get('ui')
+    if ui:
+        ui.deprecwarn("templatekw.showdict() is deprecated, use compatdict()",
+                      '4.6')
     c = [{key: k, value: v} for k, v in data.iteritems()]
     f = _showlist(name, c, mapping['templ'], mapping, plural, separator)
     return hybriddict(data, key=key, value=value, fmt=fmt, gen=f)
 
 def showlist(name, values, mapping, plural=None, element=None, separator=' '):
+    ui = mapping.get('ui')
+    if ui:
+        ui.deprecwarn("templatekw.showlist() is deprecated, use compatlist()",
+                      '4.6')
     if not element:
         element = name
     f = _showlist(name, values, mapping['templ'], mapping, plural, separator)