Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/manifest.py @ 24146:dd8c891dd09a
manifest: make copy logic local to copy()
The optional arguments to the manfifestdict constructor are only used
by copy(), so assign the fields from that method instead so it's clear
that the arguments are not used for anything else.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 23 Feb 2015 13:41:02 -0800 |
parents | ed5e8a9598ce |
children | ba4fcd80079d |
comparison
equal
deleted
inserted
replaced
24145:28af978c8f13 | 24146:dd8c891dd09a |
---|---|
8 from i18n import _ | 8 from i18n import _ |
9 import mdiff, parsers, error, revlog, util | 9 import mdiff, parsers, error, revlog, util |
10 import array, struct | 10 import array, struct |
11 | 11 |
12 class manifestdict(dict): | 12 class manifestdict(dict): |
13 def __init__(self, mapping=None, flags=None): | 13 def __init__(self): |
14 if mapping is None: | 14 self._flags = {} |
15 mapping = {} | |
16 if flags is None: | |
17 flags = {} | |
18 dict.__init__(self, mapping) | |
19 self._flags = flags | |
20 def __setitem__(self, k, v): | 15 def __setitem__(self, k, v): |
21 assert v is not None | 16 assert v is not None |
22 dict.__setitem__(self, k, v) | 17 dict.__setitem__(self, k, v) |
23 def flags(self, f): | 18 def flags(self, f): |
24 return self._flags.get(f, "") | 19 return self._flags.get(f, "") |
25 def setflag(self, f, flags): | 20 def setflag(self, f, flags): |
26 """Set the flags (symlink, executable) for path f.""" | 21 """Set the flags (symlink, executable) for path f.""" |
27 self._flags[f] = flags | 22 self._flags[f] = flags |
28 def copy(self): | 23 def copy(self): |
29 return manifestdict(self, dict.copy(self._flags)) | 24 copy = manifestdict() |
25 dict.__init__(copy, self) | |
26 copy._flags = dict.copy(self._flags) | |
27 return copy | |
30 def intersectfiles(self, files): | 28 def intersectfiles(self, files): |
31 '''make a new manifestdict with the intersection of self with files | 29 '''make a new manifestdict with the intersection of self with files |
32 | 30 |
33 The algorithm assumes that files is much smaller than self.''' | 31 The algorithm assumes that files is much smaller than self.''' |
34 ret = manifestdict() | 32 ret = manifestdict() |