Mercurial > hg
comparison hgext/record.py @ 11500:b782a7eb9037
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.
author | Renato Cunha <renatoc@gmail.com> |
---|---|
date | Thu, 01 Jul 2010 19:27:03 -0300 |
parents | 324cd681fa47 |
children | 9bbfeba33aa3 |
comparison
equal
deleted
inserted
replaced
11499:324cd681fa47 | 11500:b782a7eb9037 |
---|---|
8 '''commands to interactively select changes for commit/qrefresh''' | 8 '''commands to interactively select changes for commit/qrefresh''' |
9 | 9 |
10 from mercurial.i18n import gettext, _ | 10 from mercurial.i18n import gettext, _ |
11 from mercurial import cmdutil, commands, extensions, hg, mdiff, patch | 11 from mercurial import cmdutil, commands, extensions, hg, mdiff, patch |
12 from mercurial import util | 12 from mercurial import util |
13 import copy, cStringIO, errno, operator, os, re, tempfile | 13 import copy, cStringIO, errno, os, re, tempfile |
14 | 14 |
15 lines_re = re.compile(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)') | 15 lines_re = re.compile(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)') |
16 | 16 |
17 def scanpatch(fp): | 17 def scanpatch(fp): |
18 """like patch.iterhunks, but yield different events | 18 """like patch.iterhunks, but yield different events |
353 chunk = copy.copy(chunk) | 353 chunk = copy.copy(chunk) |
354 chunk.toline += fixoffset | 354 chunk.toline += fixoffset |
355 applied[chunk.filename()].append(chunk) | 355 applied[chunk.filename()].append(chunk) |
356 else: | 356 else: |
357 fixoffset += chunk.removed - chunk.added | 357 fixoffset += chunk.removed - chunk.added |
358 return reduce(operator.add, [h for h in applied.itervalues() | 358 return sum([h for h in applied.itervalues() |
359 if h[0].special() or len(h) > 1], []) | 359 if h[0].special() or len(h) > 1], []) |
360 | 360 |
361 def record(ui, repo, *pats, **opts): | 361 def record(ui, repo, *pats, **opts): |
362 '''interactively select changes to commit | 362 '''interactively select changes to commit |
363 | 363 |
364 If a list of files is omitted, all changes reported by :hg:`status` | 364 If a list of files is omitted, all changes reported by :hg:`status` |