Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/manifest.py @ 3189:f3b939444c72
Abstract manifest block parsing.
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Fri, 29 Sep 2006 13:00:54 -0700 |
parents | adb246ce6736 |
children | 53e843840349 |
comparison
equal
deleted
inserted
replaced
3188:705e30c0a230 | 3189:f3b939444c72 |
---|---|
7 | 7 |
8 from revlog import * | 8 from revlog import * |
9 from i18n import gettext as _ | 9 from i18n import gettext as _ |
10 from demandload import * | 10 from demandload import * |
11 demandload(globals(), "array bisect struct") | 11 demandload(globals(), "array bisect struct") |
12 demandload(globals(), "mdiff") | |
12 | 13 |
13 class manifestdict(dict): | 14 class manifestdict(dict): |
14 def __init__(self, mapping=None, flags=None): | 15 def __init__(self, mapping=None, flags=None): |
15 if mapping is None: mapping = {} | 16 if mapping is None: mapping = {} |
16 if flags is None: flags = {} | 17 if flags is None: flags = {} |
40 self.mapcache = None | 41 self.mapcache = None |
41 self.listcache = None | 42 self.listcache = None |
42 revlog.__init__(self, opener, "00manifest.i", "00manifest.d", | 43 revlog.__init__(self, opener, "00manifest.i", "00manifest.d", |
43 defversion) | 44 defversion) |
44 | 45 |
46 def parselines(self, lines): | |
47 for l in lines.splitlines(1): | |
48 yield l.split('\0') | |
49 | |
50 def readdelta(self, node): | |
51 delta = mdiff.patchtext(self.delta(node)) | |
52 deltamap = manifestdict() | |
53 for f, n in self.parselines(delta): | |
54 deltamap.rawset(f, n) | |
55 return deltamap | |
56 | |
45 def read(self, node): | 57 def read(self, node): |
46 if node == nullid: return manifestdict() # don't upset local cache | 58 if node == nullid: return manifestdict() # don't upset local cache |
47 if self.mapcache and self.mapcache[0] == node: | 59 if self.mapcache and self.mapcache[0] == node: |
48 return self.mapcache[1] | 60 return self.mapcache[1] |
49 text = self.revision(node) | 61 text = self.revision(node) |
50 self.listcache = array.array('c', text) | 62 self.listcache = array.array('c', text) |
51 lines = text.splitlines(1) | |
52 mapping = manifestdict() | 63 mapping = manifestdict() |
53 for l in lines: | 64 for f, n in self.parselines(text): |
54 (f, n) = l.split('\0') | |
55 mapping.rawset(f, n) | 65 mapping.rawset(f, n) |
56 self.mapcache = (node, mapping) | 66 self.mapcache = (node, mapping) |
57 return mapping | 67 return mapping |
58 | 68 |
59 def _search(self, m, s, lo=0, hi=None): | 69 def _search(self, m, s, lo=0, hi=None): |