Patchwork localrepo: iterate over manifest key/value pairs in status

login
register
mail settings
Submitter Bryan O'Sullivan
Date Feb. 21, 2013, 9:45 p.m.
Message ID <8fa59ad66baa06631baf.1361483154@australite.local>
Download mbox | patch
Permalink /patch/1043/
State Accepted
Commit 7790d69af6d6bd72b4d5495c6a75abdc75cbeb33
Headers show

Comments

Bryan O'Sullivan - Feb. 21, 2013, 9:45 p.m.
# HG changeset patch
# User Bryan O'Sullivan <bryano@fb.com>
# Date 1361483151 28800
# Node ID 8fa59ad66baa06631baf4b6c3eb2ec8c5d85786d
# Parent  95cb8d7754a7a28f52f82a332bf1163eb6dea202
localrepo: iterate over manifest key/value pairs in status

This saves us a couple of dict lookups in the common case, and improves
the performance of the status method by 5% (measured with util.timed)
in a repo with a large manifest.
Bryan O'Sullivan - Feb. 22, 2013, 7:20 p.m.
On Thu, Feb 21, 2013 at 1:45 PM, Bryan O'Sullivan <bos@serpentine.com>wrote:

> localrepo: iterate over manifest key/value pairs in status
>

Pushed to crew because dead simple.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1532,12 +1532,12 @@  class localrepository(object):
 
             modified, added, clean = [], [], []
             withflags = mf1.withflags() | mf2.withflags()
-            for fn in mf2:
+            for fn, mf2node in mf2.iteritems():
                 if fn in mf1:
                     if (fn not in deleted and
                         ((fn in withflags and mf1.flags(fn) != mf2.flags(fn)) or
-                         (mf1[fn] != mf2[fn] and
-                          (mf2[fn] or ctx1[fn].cmp(ctx2[fn]))))):
+                         (mf1[fn] != mf2node and
+                          (mf2node or ctx1[fn].cmp(ctx2[fn]))))):
                         modified.append(fn)
                     elif listclean:
                         clean.append(fn)