[PATCH default] formatter: improve implementation of data method

David Carr davidmc24 at gmail.com
Fri Sep 21 07:20:04 CDT 2012

# HG changeset patch
# User David M. Carr  <david at carrclan.us>
# Date 1348198259 14400
# Node ID 9d390bd2fc4e00ce330a520db6634040099edd9e
# Parent  ccd28eca37f67bcf534b016c0fd6b99140bc0632
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.

diff --git a/mercurial/formatter.py b/mercurial/formatter.py
--- a/mercurial/formatter.py
+++ b/mercurial/formatter.py
@@ -26,8 +26,7 @@
         self._item = {}
     def data(self, **data):
         '''insert data into item that's not shown in default output'''
-        for k, v in data.iteritems():
-            self._item[k] = v
+        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):

More information about the Mercurial-devel mailing list