[PATCH 11 of 11] merge: don't fiddle with name lookups or i18n in hot loops
Bryan O'Sullivan
bos at serpentine.com
Sat Feb 9 08:06:51 CST 2013
# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1360418465 0
# Node ID 994e4c0ed9a6d2ff25aacfcc9603ed9cef3909ac
# Parent a278d66b8f8621ebafbb30a201000fca63983697
merge: don't fiddle with name lookups or i18n in hot loops
We perform attribute dereferences and i18n lookups before looping.
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -321,21 +321,28 @@ def getremove(repo, mctx, overwrite, arg
yields tuples for progress updates
"""
+ verbose = repo.ui.verbose
+ unlink = util.unlinkpath
+ wjoin = repo.wjoin
+ fctx = mctx.filectx
+ wwrite = repo.wwrite
audit = repo.wopener.audit
i = 0
for arg in args:
f = arg[0]
if arg[1] == 'r':
- repo.ui.note(_("removing %s\n") % f)
+ if verbose:
+ repo.ui.note(_("removing %s\n") % f)
audit(f)
try:
- util.unlinkpath(repo.wjoin(f), ignoremissing=True)
+ unlink(wjoin(f), ignoremissing=True)
except OSError, inst:
repo.ui.warn(_("update failed to remove %s: %s!\n") %
(f, inst.strerror))
else:
- repo.ui.note(_("getting %s\n") % f)
- repo.wwrite(f, mctx.filectx(f).data(), arg[2][0])
+ if verbose:
+ repo.ui.note(_("getting %s\n") % f)
+ wwrite(f, fctx(f).data(), arg[2][0])
if i == 100:
yield i, f
i = 0
@@ -414,10 +421,13 @@ def applyupdates(repo, actions, wctx, mc
if hgsub and hgsub[0] == 'g':
subrepo.submerge(repo, wctx, mctx, wctx, overwrite)
+ _updating = _('updating')
+ _files = _('files')
+ progress = repo.ui.progress
+
for i, a in enumerate(actions):
f, m, args, msg = a
- repo.ui.progress(_('updating'), z + i + 1, item=f, total=numupdates,
- unit=_('files'))
+ progress(_updating, z + i + 1, item=f, total=numupdates, unit=_files)
if m == "m": # merge
if fd == '.hgsubstate': # subrepo states need updating
subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx),
@@ -462,7 +472,7 @@ def applyupdates(repo, actions, wctx, mc
util.setflags(repo.wjoin(f), 'l' in flags, 'x' in flags)
updated += 1
ms.commit()
- repo.ui.progress(_('updating'), None, total=numupdates, unit=_('files'))
+ progress(_updating, None, total=numupdates, unit=_files)
return updated, merged, removed, unresolved
More information about the Mercurial-devel
mailing list