Patchwork [13,of,14,evolve-ext] templatekw: add `instabilities` alias for `troubles`

login
register
mail settings
Submitter Matt Harbison
Date April 28, 2019, 4:29 a.m.
Message ID <b7745c93b5d9b7d16a7b.1556425740@Envy>
Download mbox | patch
Permalink /patch/39865/
State New
Headers show

Comments

Matt Harbison - April 28, 2019, 4:29 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1556419516 14400
#      Sat Apr 27 22:45:16 2019 -0400
# Node ID b7745c93b5d9b7d16a7bd5d2a1ef50d3920763a2
# Parent  5e8af05d917815e23977d7ab054d17d8a343e0a5
templatekw: add `instabilities` alias for `troubles`

Per https://www.mercurial-scm.org/wiki/CEDVocabulary

Patch

diff --git a/hgext3rd/evolve/templatekw.py b/hgext3rd/evolve/templatekw.py
--- a/hgext3rd/evolve/templatekw.py
+++ b/hgext3rd/evolve/templatekw.py
@@ -24,17 +24,32 @@ 
 ### template keywords
 
 if util.safehasattr(templatekw, 'compatlist'):
+    @eh.templatekeyword('instabilities', requires=set(['ctx', 'templ']))
+    def showinstabilities(context, mapping):
+        """List of strings. Evolution instabilities affecting the changeset
+        (zero or more of "orphan", "content-divergent" or "phase-divergent")."""
+        ctx = context.resource(mapping, 'ctx')
+        return templatekw.compatlist(context, mapping, 'instability',
+                                     ctx.instabilities(),
+                                     plural='instabilities')
+
     @eh.templatekeyword('troubles', requires=set(['ctx', 'templ']))
-    def showtroubles(context, mapping):
+    def showtroubles(context, mapping):   # legacy name for instabilities
         ctx = context.resource(mapping, 'ctx')
         return templatekw.compatlist(context, mapping, 'trouble',
                                      ctx.instabilities(), plural='troubles')
 else:
     # older template API in hg < 4.6
+    @eh.templatekeyword('instabilities')
+    def showinstabilities(**args):
+        """List of strings. Evolution instabilities affecting the changeset
+        (zero or more of "orphan", "content-divergent" or "phase-divergent")."""
+        ctx = args['ctx']
+        return templatekw.showlist('instability', ctx.instabilities(), args,
+                                   plural='instabilities')
+
     @eh.templatekeyword('troubles')
     def showtroubles(**args):
-        """List of strings. Evolution troubles affecting the changeset
-        (zero or more of "unstable", "divergent" or "bumped")."""
         ctx = args['ctx']
         return templatekw.showlist('trouble', ctx.instabilities(), args,
                                    plural='troubles')
diff --git a/tests/test-evolve-content-divergent-basic.t b/tests/test-evolve-content-divergent-basic.t
--- a/tests/test-evolve-content-divergent-basic.t
+++ b/tests/test-evolve-content-divergent-basic.t
@@ -20,7 +20,7 @@ 
   > git = 1
   > unified = 0
   > [ui]
-  > logtemplate = {rev}:{node|short}@{branch}({phase}) {desc|firstline} [{troubles}]\n
+  > logtemplate = {rev}:{node|short}@{branch}({phase}) {desc|firstline} [{instabilities}]\n
   > [extensions]
   > EOF
   $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
diff --git a/tests/test-evolve-content-divergent-corner-cases.t b/tests/test-evolve-content-divergent-corner-cases.t
--- a/tests/test-evolve-content-divergent-corner-cases.t
+++ b/tests/test-evolve-content-divergent-corner-cases.t
@@ -20,7 +20,7 @@ 
   > git = 1
   > unified = 0
   > [ui]
-  > logtemplate = {rev}:{node|short}@{branch}({phase}) {desc|firstline} [{troubles}]\n
+  > logtemplate = {rev}:{node|short}@{branch}({phase}) {desc|firstline} [{instabilities}]\n
   > [extensions]
   > EOF
   $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
diff --git a/tests/test-evolve-content-divergent-meta.t b/tests/test-evolve-content-divergent-meta.t
--- a/tests/test-evolve-content-divergent-meta.t
+++ b/tests/test-evolve-content-divergent-meta.t
@@ -9,7 +9,7 @@ 
 
   $ cat >> $HGRCPATH <<EOF
   > [alias]
-  > glog = log -GT "{rev}:{node|short} {desc|firstline}\n {phase} {troubles}\n\n"
+  > glog = log -GT "{rev}:{node|short} {desc|firstline}\n {phase} {instabilities}\n\n"
   > [phases]
   > publish = False
   > [extensions]
diff --git a/tests/test-evolve-public-content-divergent-corner-cases.t b/tests/test-evolve-public-content-divergent-corner-cases.t
--- a/tests/test-evolve-public-content-divergent-corner-cases.t
+++ b/tests/test-evolve-public-content-divergent-corner-cases.t
@@ -9,7 +9,7 @@ 
 =====
   $ cat >> $HGRCPATH <<EOF
   > [alias]
-  > glog = log -GT "{rev}:{node|short} {desc|firstline}\n {phase} {troubles}\n\n"
+  > glog = log -GT "{rev}:{node|short} {desc|firstline}\n {phase} {instabilities}\n\n"
   > [phases]
   > publish = False
   > [extensions]
diff --git a/tests/test-evolve-public-content-divergent-discard.t b/tests/test-evolve-public-content-divergent-discard.t
--- a/tests/test-evolve-public-content-divergent-discard.t
+++ b/tests/test-evolve-public-content-divergent-discard.t
@@ -14,7 +14,7 @@ 
 =====
   $ cat >> $HGRCPATH <<EOF
   > [alias]
-  > glog = log -GT "{rev}:{node|short} {desc|firstline}\n {phase} {troubles}\n\n"
+  > glog = log -GT "{rev}:{node|short} {desc|firstline}\n {phase} {instabilities}\n\n"
   > [phases]
   > publish = False
   > [extensions]
diff --git a/tests/test-evolve-public-content-divergent-main.t b/tests/test-evolve-public-content-divergent-main.t
--- a/tests/test-evolve-public-content-divergent-main.t
+++ b/tests/test-evolve-public-content-divergent-main.t
@@ -12,7 +12,7 @@ 
 =====
   $ cat >> $HGRCPATH <<EOF
   > [alias]
-  > glog = log -GT "{rev}:{node|short} {desc|firstline}\n {phase} {troubles}\n\n"
+  > glog = log -GT "{rev}:{node|short} {desc|firstline}\n {phase} {instabilities}\n\n"
   > [phases]
   > publish = False
   > [extensions]
diff --git a/tests/test-evolve.t b/tests/test-evolve.t
--- a/tests/test-evolve.t
+++ b/tests/test-evolve.t
@@ -441,7 +441,7 @@ 
 
 (ninja test for the {trouble} template:
 
-  $ hg log -G --template '{rev} {troubles}\n'
+  $ hg log -G --template '{rev} {instabilities}\n'
   @  10
   |
   | *  9 orphan