Mercurial > public > mercurial-scm > hg
comparison mercurial/context.py @ 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 | 870ddcf24291 |
children | ef9b2bea9709 |
comparison
equal
deleted
inserted
replaced
21470:1af854808a3c | 21471:90aff492dc4a |
---|---|
75 return mf | 75 return mf |
76 for fn in mf.keys(): | 76 for fn in mf.keys(): |
77 if not match(fn): | 77 if not match(fn): |
78 del mf[fn] | 78 del mf[fn] |
79 return mf | 79 return mf |
80 | |
81 def _buildstatus(self, other, s, match, listignored, listclean, | |
82 listunknown): | |
83 """build a status with respect to another context""" | |
84 mf1 = other._manifestmatches(match, s) | |
85 mf2 = self._manifestmatches(match, s) | |
86 | |
87 modified, added, clean = [], [], [] | |
88 deleted, unknown, ignored = s[3], [], [] | |
89 withflags = mf1.withflags() | mf2.withflags() | |
90 for fn, mf2node in mf2.iteritems(): | |
91 if fn in mf1: | |
92 if (fn not in deleted and | |
93 ((fn in withflags and mf1.flags(fn) != mf2.flags(fn)) or | |
94 (mf1[fn] != mf2node and | |
95 (mf2node or self[fn].cmp(other[fn]))))): | |
96 modified.append(fn) | |
97 elif listclean: | |
98 clean.append(fn) | |
99 del mf1[fn] | |
100 elif fn not in deleted: | |
101 added.append(fn) | |
102 removed = mf1.keys() | |
103 | |
104 return [modified, added, removed, deleted, unknown, ignored, clean] | |
80 | 105 |
81 @propertycache | 106 @propertycache |
82 def substate(self): | 107 def substate(self): |
83 return subrepo.state(self, self._repo.ui) | 108 return subrepo.state(self, self._repo.ui) |
84 | 109 |