changeset 21471:90aff492dc4a

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.
author Sean Farley <sean.michael.farley@gmail.com>
date Mon, 21 Apr 2014 21:35:36 -0500
parents 1af854808a3c
children 77dbd05471cd
files mercurial/context.py
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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)