# HG changeset patch # User Siddharth Agarwal # Date 2014-07-13 00:57:25 # Node ID 090dcaaf3fffa126b161c7525354efbf240043e7 # Parent e2530d4a47c10670409c4166b1b567f20af11089 manifestdict: add a new method to intersect with a set of files This is meant to be used when the set of files is known in advance, e.g. with a match object with no patterns. diff --git a/mercurial/manifest.py b/mercurial/manifest.py --- a/mercurial/manifest.py +++ b/mercurial/manifest.py @@ -25,6 +25,18 @@ class manifestdict(dict): self._flags[f] = flags def copy(self): return manifestdict(self, dict.copy(self._flags)) + def intersectfiles(self, files): + '''make a new manifestdict with the intersection of self with files + + The algorithm assumes that files is much smaller than self.''' + ret = manifestdict() + for fn in files: + if fn in self: + ret[fn] = self[fn] + flags = self._flags.get(fn, None) + if flags: + ret._flags[fn] = flags + return ret def flagsdiff(self, d2): return dicthelpers.diff(self._flags, d2._flags, "")