##// END OF EJS Templates
Abstract manifest block parsing.
Brendan Cully -
r3196:f3b93944 default
parent child Browse files
Show More
@@ -9,6 +9,7 b' 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):
@@ -42,16 +43,25 b' class manifest(revlog):'
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
@@ -102,21 +102,15 b' def verify(repo):'
102 (short(n), short(p)))
102 (short(n), short(p)))
103
103
104 try:
104 try:
105 delta = mdiff.patchtext(repo.manifest.delta(n))
105 for f, fn in repo.manifest.readdelta(n).iteritems():
106 filenodes.setdefault(f, {})[fn] = 1
106 except KeyboardInterrupt:
107 except KeyboardInterrupt:
107 repo.ui.warn(_("interrupted"))
108 repo.ui.warn(_("interrupted"))
108 raise
109 raise
109 except Exception, inst:
110 except Exception, inst:
110 err(_("unpacking manifest %s: %s") % (short(n), inst))
111 err(_("reading delta for manifest %s: %s") % (short(n), inst))
111 continue
112 continue
112
113
113 try:
114 ff = [ l.split('\0') for l in delta.splitlines() ]
115 for f, fn in ff:
116 filenodes.setdefault(f, {})[bin(fn[:40])] = 1
117 except (ValueError, TypeError), inst:
118 err(_("broken delta in manifest %s: %s") % (short(n), inst))
119
120 repo.ui.status(_("crosschecking files in changesets and manifests\n"))
114 repo.ui.status(_("crosschecking files in changesets and manifests\n"))
121
115
122 for m, c in neededmanifests.items():
116 for m, c in neededmanifests.items():
General Comments 0
You need to be logged in to leave comments. Login now