Patchwork [evolve-ext] templatekw: do not override in-core {obsolete} keyword

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 8, 2018, 3:21 p.m.
Message ID <f5ad6b61447577fc501b.1533741688@mimosa>
Download mbox | patch
Permalink /patch/33424/
State New
Headers show

Comments

Yuya Nishihara - Aug. 8, 2018, 3:21 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1533727294 -32400
#      Wed Aug 08 20:21:34 2018 +0900
# Node ID f5ad6b61447577fc501b244c340a614bb6b68355
# Parent  544f394997aa18727c7e6e13f4b9ef3d98d009c9
templatekw: do not override in-core {obsolete} keyword

The extension version uses old API, which will be deprecated in Mercurial 4.8.
Boris Feld - Oct. 19, 2018, 4:06 p.m.
I was checking the in-flight patches and saw that we never acknowledge
the reception of those patches.

Thank you, they have been merged in evolve.

Sorry about the delay.

On 08/08/2018 17:21, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1533727294 -32400
> #      Wed Aug 08 20:21:34 2018 +0900
> # Node ID f5ad6b61447577fc501b244c340a614bb6b68355
> # Parent  544f394997aa18727c7e6e13f4b9ef3d98d009c9
> templatekw: do not override in-core {obsolete} keyword
>
> The extension version uses old API, which will be deprecated in Mercurial 4.8.
>
> diff --git a/hgext3rd/evolve/templatekw.py b/hgext3rd/evolve/templatekw.py
> --- a/hgext3rd/evolve/templatekw.py
> +++ b/hgext3rd/evolve/templatekw.py
> @@ -26,13 +26,15 @@ eh = exthelper.exthelper()
>  ### template keywords
>  # XXX it does not handle troubles well :-/
>  
> -@eh.templatekw('obsolete')
> -def obsoletekw(repo, ctx, templ, **args):
> -    """String. Whether the changeset is ``obsolete``.
> -    """
> -    if ctx.obsolete():
> -        return 'obsolete'
> -    return ''
> +if not util.safehasattr(templatekw, 'showobsolete'):
> +    # hg < 4.2
> +    @eh.templatekw('obsolete')
> +    def obsoletekw(repo, ctx, templ, **args):
> +        """String. Whether the changeset is ``obsolete``.
> +        """
> +        if ctx.obsolete():
> +            return 'obsolete'
> +        return ''
>  
>  if util.safehasattr(templatekw, 'compatlist'):
>      @eh.templatekw('troubles', requires=set(['ctx', 'templ']))
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext3rd/evolve/templatekw.py b/hgext3rd/evolve/templatekw.py
--- a/hgext3rd/evolve/templatekw.py
+++ b/hgext3rd/evolve/templatekw.py
@@ -26,13 +26,15 @@  eh = exthelper.exthelper()
 ### template keywords
 # XXX it does not handle troubles well :-/
 
-@eh.templatekw('obsolete')
-def obsoletekw(repo, ctx, templ, **args):
-    """String. Whether the changeset is ``obsolete``.
-    """
-    if ctx.obsolete():
-        return 'obsolete'
-    return ''
+if not util.safehasattr(templatekw, 'showobsolete'):
+    # hg < 4.2
+    @eh.templatekw('obsolete')
+    def obsoletekw(repo, ctx, templ, **args):
+        """String. Whether the changeset is ``obsolete``.
+        """
+        if ctx.obsolete():
+            return 'obsolete'
+        return ''
 
 if util.safehasattr(templatekw, 'compatlist'):
     @eh.templatekw('troubles', requires=set(['ctx', 'templ']))