formatter: verify number of arguments passed to write functions
zip() takes the shortest length, which can be a source of bug.
--- a/mercurial/formatter.py Sat Sep 26 11:50:47 2015 +0900
+++ b/mercurial/formatter.py Wed Sep 23 21:51:48 2015 +0900
@@ -48,11 +48,15 @@
self._item.update(data)
def write(self, fields, deftext, *fielddata, **opts):
'''do default text output while assigning data to item'''
- for k, v in zip(fields.split(), fielddata):
+ fieldkeys = fields.split()
+ assert len(fieldkeys) == len(fielddata)
+ for k, v in zip(fieldkeys, fielddata):
self._item[k] = v
def condwrite(self, cond, fields, deftext, *fielddata, **opts):
'''do conditional write (primarily for plain formatter)'''
- for k, v in zip(fields.split(), fielddata):
+ fieldkeys = fields.split()
+ assert len(fieldkeys) == len(fielddata)
+ for k, v in zip(fieldkeys, fielddata):
self._item[k] = v
def plain(self, text, **opts):
'''show raw text for non-templated mode'''