record: removed 'reduce' calls (unsupported by py3k)
authorRenato Cunha <renatoc@gmail.com>
Thu, 01 Jul 2010 19:27:03 -0300
changeset 11500 b782a7eb9037
parent 11499 324cd681fa47
child 11501 deb5d02ae91c
record: removed 'reduce' calls (unsupported by py3k) Quoting python's documentation, "Note that sum(range(n), m) is equivalent to reduce(operator.add, range(n), m)". The "sum" function is a builtin from 2.3 on and there's no reason for not to use it.
hgext/record.py
--- a/hgext/record.py	Thu Jul 01 19:27:03 2010 -0300
+++ b/hgext/record.py	Thu Jul 01 19:27:03 2010 -0300
@@ -10,7 +10,7 @@
 from mercurial.i18n import gettext, _
 from mercurial import cmdutil, commands, extensions, hg, mdiff, patch
 from mercurial import util
-import copy, cStringIO, errno, operator, os, re, tempfile
+import copy, cStringIO, errno, os, re, tempfile
 
 lines_re = re.compile(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)')
 
@@ -355,8 +355,8 @@
                 applied[chunk.filename()].append(chunk)
             else:
                 fixoffset += chunk.removed - chunk.added
-    return reduce(operator.add, [h for h in applied.itervalues()
-                                 if h[0].special() or len(h) > 1], [])
+    return sum([h for h in applied.itervalues()
+               if h[0].special() or len(h) > 1], [])
 
 def record(ui, repo, *pats, **opts):
     '''interactively select changes to commit