[PATCH 3 of 4 status-via-diff] context: use new manifest.diff(clean=True) support

Augie Fackler raf at durin42.com
Wed Jan 7 15:10:25 CST 2015


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1418677564 18000
#      Mon Dec 15 16:06:04 2014 -0500
# Node ID 99e32de01320401b28d66ad804a9de8b89c02eef
# Parent  e3478ceadf3216a60c88b0be7c5bd4cfc6ec6e2d
context: use new manifest.diff(clean=True) support

This further simplifies the status code.

This simplification comes at a slight performance cost for `hg
export`. Before, on mozilla-central:

perfmanifest tip
! wall 0.265977 comb 0.260000 user 0.240000 sys 0.020000 (best of 38)
perftags
! result: 162
! wall 0.007172 comb 0.010000 user 0.000000 sys 0.010000 (best of 403)
perfstatus
! wall 0.422302 comb 0.420000 user 0.260000 sys 0.160000 (best of 24)
hgperf export tip
! wall 0.148706 comb 0.150000 user 0.150000 sys 0.000000 (best of 65)

after, same repo:
perfmanifest tip
! wall 0.267143 comb 0.270000 user 0.250000 sys 0.020000 (best of 37)
perftags
! result: 162
! wall 0.006943 comb 0.010000 user 0.000000 sys 0.010000 (best of 397)
perfstatus
! wall 0.411198 comb 0.410000 user 0.260000 sys 0.150000 (best of 24)
hgperf export tip
! wall 0.173229 comb 0.170000 user 0.170000 sys 0.000000 (best of 55)

The next set of patches introduces a new manifest type implemented
almost entirely in C, and more than makes up for the performance hit
incurred in this change.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -137,13 +137,17 @@ class basectx(object):
 
         modified, added = [], []
         removed = []
-        clean = set()
+        clean = []
         deleted, unknown, ignored = s.deleted, s.unknown, s.ignored
         deletedset = set(deleted)
-        d = mf1.diff(mf2)
-        for fn, ((node1, flag1), (node2, flag2)) in d.iteritems():
+        d = mf1.diff(mf2, clean=listclean)
+        for fn, value in d.iteritems():
             if fn in deletedset:
                 continue
+            if value is None:
+                clean.append(fn)
+                continue
+            (node1, flag1), (node2, flag2) = value
             if node1 is None:
                 added.append(fn)
             elif node2 is None:
@@ -157,12 +161,7 @@ class basectx(object):
                 # match the one in mf1.
                 modified.append(fn)
             else:
-                clean.add(fn)
-        if listclean:
-            nondiff = (set(mf1) | set(mf2)) - set(d)
-            clean = list((clean | nondiff) - deletedset)
-        else:
-            clean = []
+                clean.append(fn)
 
         if removed:
             # need to filter files if they are already reported as removed


More information about the Mercurial-devel mailing list