Mercurial > public > mercurial-scm > hg
comparison mercurial/context.py @ 23305:0cc283f44655
manifest: add matches() method
Move the code in context._manifestmatches() into a new
manifest.matches(). It's a natural place for the code to live and it
allows other callers to easily use it. It should also make it easier
to optimize the new method in alternative implementations of the
manifest (same reasoning as with manifest.diff()).
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 22 Oct 2014 21:38:30 -0700 |
parents | dd3f857598a0 |
children | b913c394386f |
comparison
equal
deleted
inserted
replaced
23304:dd3f857598a0 | 23305:0cc283f44655 |
---|---|
69 | 69 |
70 This method is for internal use only and mainly exists to provide an | 70 This method is for internal use only and mainly exists to provide an |
71 object oriented way for other contexts to customize the manifest | 71 object oriented way for other contexts to customize the manifest |
72 generation. | 72 generation. |
73 """ | 73 """ |
74 if match.always(): | 74 return self.manifest().matches(match) |
75 return self.manifest().copy() | |
76 | |
77 files = match.files() | |
78 if (match.matchfn == match.exact or | |
79 (not match.anypats() and util.all(fn in self for fn in files))): | |
80 return self.manifest().intersectfiles(files) | |
81 | |
82 mf = self.manifest().copy() | |
83 for fn in mf.keys(): | |
84 if not match(fn): | |
85 del mf[fn] | |
86 return mf | |
87 | 75 |
88 def _matchstatus(self, other, match): | 76 def _matchstatus(self, other, match): |
89 """return match.always if match is none | 77 """return match.always if match is none |
90 | 78 |
91 This internal method provides a way for child objects to override the | 79 This internal method provides a way for child objects to override the |