Mercurial > public > mercurial-scm > hg
comparison mercurial/manifest.py @ 2834:35af2e56f15a
manifestflags: eliminate remaining users of direct dict access
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 19 Jul 2006 19:11:50 -0500 |
parents | d0159c5f18bf |
children | a9f5d4149123 |
comparison
equal
deleted
inserted
replaced
2833:d0159c5f18bf | 2834:35af2e56f15a |
---|---|
11 demandload(globals(), "array bisect struct") | 11 demandload(globals(), "array bisect struct") |
12 | 12 |
13 class manifestflags(dict): | 13 class manifestflags(dict): |
14 def __init__(self, mapping={}): | 14 def __init__(self, mapping={}): |
15 dict.__init__(self, mapping) | 15 dict.__init__(self, mapping) |
16 def __getitem__(self, f): | |
17 raise "oops" | |
18 def flags(self, f): | |
19 return dict.__getitem__(self, f) | |
16 def execf(self, f): | 20 def execf(self, f): |
17 "test for executable in manifest flags" | 21 "test for executable in manifest flags" |
18 return "x" in self.get(f, "") | 22 return "x" in self.get(f, "") |
19 def linkf(self, f): | 23 def linkf(self, f): |
20 "test for symlink in manifest flags" | 24 "test for symlink in manifest flags" |
138 files = map.keys() | 142 files = map.keys() |
139 files.sort() | 143 files.sort() |
140 | 144 |
141 # if this is changed to support newlines in filenames, | 145 # if this is changed to support newlines in filenames, |
142 # be sure to check the templates/ dir again (especially *-raw.tmpl) | 146 # be sure to check the templates/ dir again (especially *-raw.tmpl) |
143 text = ["%s\000%s%s\n" % (f, hex(map[f]), flags[f]) for f in files] | 147 text = ["%s\000%s%s\n" % (f, hex(map[f]), flags.flags(f)) for f in files] |
144 self.listcache = array.array('c', "".join(text)) | 148 self.listcache = array.array('c', "".join(text)) |
145 cachedelta = None | 149 cachedelta = None |
146 else: | 150 else: |
147 addlist = self.listcache | 151 addlist = self.listcache |
148 | 152 |
164 for w in work: | 168 for w in work: |
165 f = w[0] | 169 f = w[0] |
166 # bs will either be the index of the item or the insert point | 170 # bs will either be the index of the item or the insert point |
167 start, end = self._search(addbuf, f, start) | 171 start, end = self._search(addbuf, f, start) |
168 if w[1] == 0: | 172 if w[1] == 0: |
169 l = "%s\000%s%s\n" % (f, hex(map[f]), flags[f]) | 173 l = "%s\000%s%s\n" % (f, hex(map[f]), flags.flags(f)) |
170 else: | 174 else: |
171 l = "" | 175 l = "" |
172 if start == end and w[1] == 1: | 176 if start == end and w[1] == 1: |
173 # item we want to delete was not found, error out | 177 # item we want to delete was not found, error out |
174 raise AssertionError( | 178 raise AssertionError( |