From patchwork Sat Mar 10 08:11:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4,of,5] templatefilters: inline hbisect.shortlabel() From: Yuya Nishihara X-Patchwork-Id: 29244 Message-Id: <50008d6c32bf2eba12b1.1520669474@mimosa> To: mercurial-devel@mercurial-scm.org Date: Sat, 10 Mar 2018 17:11:14 +0900 # HG changeset patch # User Yuya Nishihara # Date 1520342101 21600 # Tue Mar 06 07:15:01 2018 -0600 # Node ID 50008d6c32bf2eba12b13bd2ed34149b653ef004 # Parent 61f2121cac167752acc5014ac7f4c4da100a2097 templatefilters: inline hbisect.shortlabel() It's pretty simple. I don't think the business logic has to be placed in hbisect.py. diff --git a/mercurial/hbisect.py b/mercurial/hbisect.py --- a/mercurial/hbisect.py +++ b/mercurial/hbisect.py @@ -267,12 +267,6 @@ def label(repo, node): return None -def shortlabel(label): - if label: - return label[0].upper() - - return None - def printresult(ui, repo, state, displayer, nodes, good): if len(nodes) == 1: # narrowed it down to a single revision diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py --- a/mercurial/templatefilters.py +++ b/mercurial/templatefilters.py @@ -343,13 +343,15 @@ def short(text): return text[:12] @templatefilter('shortbisect') -def shortbisect(text): - """Any text. Treats `text` as a bisection status, and +def shortbisect(label): + """Any text. Treats `label` as a bisection status, and returns a single-character representing the status (G: good, B: bad, S: skipped, U: untested, I: ignored). Returns single space if `text` is not a valid bisection status. """ - return hbisect.shortlabel(text) or ' ' + if label: + return label[0].upper() + return ' ' @templatefilter('shortdate') def shortdate(text):