Mercurial > hg
comparison mercurial/dirstate.py @ 4607:49dcac6ede26
dirstate: fold parse into read
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 18 Jun 2007 13:24:33 -0500 |
parents | 2651099c5018 |
children | 220211b88656 |
comparison
equal
deleted
inserted
replaced
4606:2651099c5018 | 4607:49dcac6ede26 |
---|---|
202 try: | 202 try: |
203 return self[key][0] | 203 return self[key][0] |
204 except KeyError: | 204 except KeyError: |
205 return "?" | 205 return "?" |
206 | 206 |
207 def parse(self, st): | 207 def read(self): |
208 self.map = {} | |
209 self.copymap = {} | |
210 self.pl = [nullid, nullid] | |
211 try: | |
212 st = self.opener("dirstate").read() | |
213 except IOError, err: | |
214 if err.errno != errno.ENOENT: raise | |
215 return | |
216 if not st: | |
217 return | |
218 | |
208 self.pl = [st[:20], st[20: 40]] | 219 self.pl = [st[:20], st[20: 40]] |
209 | 220 |
210 # deref fields so they will be local in loop | 221 # deref fields so they will be local in loop |
211 map = self.map | 222 dmap = self.map |
212 copymap = self.copymap | 223 copymap = self.copymap |
213 format = self.format | 224 format = self.format |
214 unpack = struct.unpack | 225 unpack = struct.unpack |
215 | 226 |
216 pos = 40 | 227 pos = 40 |
224 newpos = pos + l | 235 newpos = pos + l |
225 f = st[pos:newpos] | 236 f = st[pos:newpos] |
226 if '\0' in f: | 237 if '\0' in f: |
227 f, c = f.split('\0') | 238 f, c = f.split('\0') |
228 copymap[f] = c | 239 copymap[f] = c |
229 map[f] = e[:4] | 240 dmap[f] = e[:4] |
230 pos = newpos | 241 pos = newpos |
231 | |
232 def read(self): | |
233 self.map = {} | |
234 self.copymap = {} | |
235 self.pl = [nullid, nullid] | |
236 try: | |
237 st = self.opener("dirstate").read() | |
238 if st: | |
239 self.parse(st) | |
240 except IOError, err: | |
241 if err.errno != errno.ENOENT: raise | |
242 | 242 |
243 def reload(self): | 243 def reload(self): |
244 for a in "map copymap _branch pl dirs".split(): | 244 for a in "map copymap _branch pl dirs".split(): |
245 if hasattr(self, a): | 245 if hasattr(self, a): |
246 self.__delattr__(a) | 246 self.__delattr__(a) |