context: add _buildstatus method
authorSean Farley <sean.michael.farley@gmail.com>
Mon, 21 Apr 2014 21:35:36 -0500
changeset 21471 90aff492dc4a
parent 21470 1af854808a3c
child 21472 77dbd05471cd
context: add _buildstatus method This method is a copy of localstatus.status's core logic. Later patches will clean up some of the dense coditionals in the for loop.
mercurial/context.py
--- a/mercurial/context.py	Mon Apr 21 20:42:42 2014 -0500
+++ b/mercurial/context.py	Mon Apr 21 21:35:36 2014 -0500
@@ -78,6 +78,31 @@
                 del mf[fn]
         return mf
 
+    def _buildstatus(self, other, s, match, listignored, listclean,
+                        listunknown):
+        """build a status with respect to another context"""
+        mf1 = other._manifestmatches(match, s)
+        mf2 = self._manifestmatches(match, s)
+
+        modified, added, clean = [], [], []
+        deleted, unknown, ignored = s[3], [], []
+        withflags = mf1.withflags() | mf2.withflags()
+        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] != mf2node and
+                      (mf2node or self[fn].cmp(other[fn]))))):
+                    modified.append(fn)
+                elif listclean:
+                    clean.append(fn)
+                del mf1[fn]
+            elif fn not in deleted:
+                added.append(fn)
+        removed = mf1.keys()
+
+        return [modified, added, removed, deleted, unknown, ignored, clean]
+
     @propertycache
     def substate(self):
         return subrepo.state(self, self._repo.ui)