Mercurial > hg
comparison mercurial/formatter.py @ 26373:aa610ffad4e8
formatter: use dict.update() to set arguments passed to write functions
This isn't important, but update() is better than loop in general.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 23 Sep 2015 21:54:47 +0900 |
parents | 55de800937e0 |
children | 56b2bcea2529 |
comparison
equal
deleted
inserted
replaced
26372:55de800937e0 | 26373:aa610ffad4e8 |
---|---|
48 self._item.update(data) | 48 self._item.update(data) |
49 def write(self, fields, deftext, *fielddata, **opts): | 49 def write(self, fields, deftext, *fielddata, **opts): |
50 '''do default text output while assigning data to item''' | 50 '''do default text output while assigning data to item''' |
51 fieldkeys = fields.split() | 51 fieldkeys = fields.split() |
52 assert len(fieldkeys) == len(fielddata) | 52 assert len(fieldkeys) == len(fielddata) |
53 for k, v in zip(fieldkeys, fielddata): | 53 self._item.update(zip(fieldkeys, fielddata)) |
54 self._item[k] = v | |
55 def condwrite(self, cond, fields, deftext, *fielddata, **opts): | 54 def condwrite(self, cond, fields, deftext, *fielddata, **opts): |
56 '''do conditional write (primarily for plain formatter)''' | 55 '''do conditional write (primarily for plain formatter)''' |
57 fieldkeys = fields.split() | 56 fieldkeys = fields.split() |
58 assert len(fieldkeys) == len(fielddata) | 57 assert len(fieldkeys) == len(fielddata) |
59 for k, v in zip(fieldkeys, fielddata): | 58 self._item.update(zip(fieldkeys, fielddata)) |
60 self._item[k] = v | |
61 def plain(self, text, **opts): | 59 def plain(self, text, **opts): |
62 '''show raw text for non-templated mode''' | 60 '''show raw text for non-templated mode''' |
63 pass | 61 pass |
64 def end(self): | 62 def end(self): |
65 '''end output for the formatter''' | 63 '''end output for the formatter''' |