Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/formatter.py @ 17630:ff5ed1ecd43a
formatter: improve implementation of data method
This alternate syntax was proposed by Bryan O'Sullivan in a review of
772b3764d3e8. I haven't been able to measure any particular performance
difference, but the new syntax is more concise and easier to read.
author | David M. Carr <david@carrclan.us> |
---|---|
date | Thu, 20 Sep 2012 23:30:59 -0400 |
parents | 772b3764d3e8 |
children | 3326fd05eb1f |
comparison
equal
deleted
inserted
replaced
17629:331d611813ec | 17630:ff5ed1ecd43a |
---|---|
24 if self._item is not None: | 24 if self._item is not None: |
25 self._showitem() | 25 self._showitem() |
26 self._item = {} | 26 self._item = {} |
27 def data(self, **data): | 27 def data(self, **data): |
28 '''insert data into item that's not shown in default output''' | 28 '''insert data into item that's not shown in default output''' |
29 for k, v in data.iteritems(): | 29 self._item.update(data) |
30 self._item[k] = v | |
31 def write(self, fields, deftext, *fielddata, **opts): | 30 def write(self, fields, deftext, *fielddata, **opts): |
32 '''do default text output while assigning data to item''' | 31 '''do default text output while assigning data to item''' |
33 for k, v in zip(fields.split(), fielddata): | 32 for k, v in zip(fields.split(), fielddata): |
34 self._item[k] = v | 33 self._item[k] = v |
35 def plain(self, text, **opts): | 34 def plain(self, text, **opts): |