From patchwork Fri Apr 14 15:31:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1, of, 5] templatekw: eliminate unnecessary temporary variable 'names' from _showlist() From: Yuya Nishihara X-Patchwork-Id: 20203 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Sat, 15 Apr 2017 00:31:33 +0900 # HG changeset patch # User Yuya Nishihara # Date 1491395264 -32400 # Wed Apr 05 21:27:44 2017 +0900 # Node ID ab39d72f0fd0e26f8803482d337adb7528f25a96 # Parent 4c2c30bc38b4f84ce8f215146bbf158e299065b3 templatekw: eliminate unnecessary temporary variable 'names' from _showlist() Replace 'names' with the optional argument 'plural'. diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py --- a/mercurial/templatekw.py +++ b/mercurial/templatekw.py @@ -106,11 +106,10 @@ def _showlist(name, values, plural=None, expand 'end_foos'. ''' templ = args['templ'] - if plural: - names = plural - else: names = name + 's' + if not plural: + plural = name + 's' if not values: - noname = 'no_' + names + noname = 'no_' + plural if noname in templ: yield templ(noname, **args) return @@ -121,7 +120,7 @@ def _showlist(name, values, plural=None, for v in values: yield dict(v, **args) return - startname = 'start_' + names + startname = 'start_' + plural if startname in templ: yield templ(startname, **args) vargs = args.copy() @@ -144,7 +143,7 @@ def _showlist(name, values, plural=None, yield one(v) if last is not None: yield one(last, tag=lastname) - endname = 'end_' + names + endname = 'end_' + plural if endname in templ: yield templ(endname, **args)