Mercurial > hg
comparison mercurial/manifest.py @ 2833:d0159c5f18bf
Use strings for manifestflags to allow storing multiple flags
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 16 Jul 2006 03:22:05 -0500 |
parents | e196aa1df169 |
children | 35af2e56f15a |
comparison
equal
deleted
inserted
replaced
2832:e196aa1df169 | 2833:d0159c5f18bf |
---|---|
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 execf(self, f): | 16 def execf(self, f): |
17 "test for executable in manifest flags" | 17 "test for executable in manifest flags" |
18 return self.get(f, False) | 18 return "x" in self.get(f, "") |
19 def linkf(self, f): | 19 def linkf(self, f): |
20 "test for symlink in manifest flags" | 20 "test for symlink in manifest flags" |
21 return False | 21 return "l" in self.get(f, "") |
22 def set(self, f, execf=False, linkf=False): | 22 def set(self, f, execf=False, linkf=False): |
23 self[f] = execf | 23 fl = "" |
24 if execf: fl = "x" | |
25 if linkf: fl = "l" | |
26 self[f] = fl | |
24 def copy(self): | 27 def copy(self): |
25 return manifestflags(dict.copy(self)) | 28 return manifestflags(dict.copy(self)) |
26 | 29 |
27 class manifest(revlog): | 30 class manifest(revlog): |
28 def __init__(self, opener, defversion=REVLOGV0): | 31 def __init__(self, opener, defversion=REVLOGV0): |
41 self.listcache = array.array('c', text) | 44 self.listcache = array.array('c', text) |
42 lines = text.splitlines(1) | 45 lines = text.splitlines(1) |
43 for l in lines: | 46 for l in lines: |
44 (f, n) = l.split('\0') | 47 (f, n) = l.split('\0') |
45 map[f] = bin(n[:40]) | 48 map[f] = bin(n[:40]) |
46 flag[f] = (n[40:-1] == "x") | 49 flag[f] = n[40:-1] |
47 self.mapcache = (node, map, flag) | 50 self.mapcache = (node, map, flag) |
48 return map | 51 return map |
49 | 52 |
50 def readflags(self, node): | 53 def readflags(self, node): |
51 if node == nullid: return manifestflags() # don't upset local cache | 54 if node == nullid: return manifestflags() # don't upset local cache |
135 files = map.keys() | 138 files = map.keys() |
136 files.sort() | 139 files.sort() |
137 | 140 |
138 # if this is changed to support newlines in filenames, | 141 # if this is changed to support newlines in filenames, |
139 # be sure to check the templates/ dir again (especially *-raw.tmpl) | 142 # be sure to check the templates/ dir again (especially *-raw.tmpl) |
140 text = ["%s\000%s%s\n" % | 143 text = ["%s\000%s%s\n" % (f, hex(map[f]), flags[f]) for f in files] |
141 (f, hex(map[f]), flags[f] and "x" or '') | |
142 for f in files] | |
143 self.listcache = array.array('c', "".join(text)) | 144 self.listcache = array.array('c', "".join(text)) |
144 cachedelta = None | 145 cachedelta = None |
145 else: | 146 else: |
146 addlist = self.listcache | 147 addlist = self.listcache |
147 | 148 |
163 for w in work: | 164 for w in work: |
164 f = w[0] | 165 f = w[0] |
165 # bs will either be the index of the item or the insert point | 166 # bs will either be the index of the item or the insert point |
166 start, end = self._search(addbuf, f, start) | 167 start, end = self._search(addbuf, f, start) |
167 if w[1] == 0: | 168 if w[1] == 0: |
168 l = "%s\000%s%s\n" % (f, hex(map[f]), | 169 l = "%s\000%s%s\n" % (f, hex(map[f]), flags[f]) |
169 flags[f] and "x" or '') | |
170 else: | 170 else: |
171 l = "" | 171 l = "" |
172 if start == end and w[1] == 1: | 172 if start == end and w[1] == 1: |
173 # item we want to delete was not found, error out | 173 # item we want to delete was not found, error out |
174 raise AssertionError( | 174 raise AssertionError( |