[PATCH 1 of 2] Abstract manifest block parsing
Brendan Cully
brendan at kublai.com
Fri Sep 22 23:55:58 UTC 2006
# HG changeset patch
# User Brendan Cully <brendan at kublai.com>
# Date 1158968928 25200
# Node ID 994d2702b2b4bb2ba6a36e9bf7740e5f0d2f26e5
# Parent 6719b3dd7d504606725ae172afccce93864aca68
Abstract manifest block parsing.
diff -r 6719b3dd7d50 -r 994d2702b2b4 mercurial/manifest.py
--- a/mercurial/manifest.py Fri Sep 22 16:12:39 2006 -0500
+++ b/mercurial/manifest.py Fri Sep 22 16:48:48 2006 -0700
@@ -9,6 +9,7 @@ from i18n import gettext as _
from i18n import gettext as _
from demandload import *
demandload(globals(), "array bisect struct")
+demandload(globals(), "mdiff")
class manifestdict(dict):
def __init__(self, mapping=None, flags=None):
@@ -42,16 +43,25 @@ class manifest(revlog):
revlog.__init__(self, opener, "00manifest.i", "00manifest.d",
defversion)
+ def parselines(self, lines):
+ for l in lines.splitlines(1):
+ yield l.split('\0')
+
+ def readdelta(self, node):
+ delta = mdiff.patchtext(self.delta(node))
+ deltamap = manifestdict()
+ for f, n in self.parselines(delta):
+ deltamap.rawset(f, n)
+ return deltamap
+
def read(self, node):
if node == nullid: return manifestdict() # don't upset local cache
if self.mapcache and self.mapcache[0] == node:
return self.mapcache[1]
text = self.revision(node)
self.listcache = array.array('c', text)
- lines = text.splitlines(1)
mapping = manifestdict()
- for l in lines:
- (f, n) = l.split('\0')
+ for f, n in self.parselines(text):
mapping.rawset(f, n)
self.mapcache = (node, mapping)
return mapping
diff -r 6719b3dd7d50 -r 994d2702b2b4 mercurial/verify.py
--- a/mercurial/verify.py Fri Sep 22 16:12:39 2006 -0500
+++ b/mercurial/verify.py Fri Sep 22 16:48:48 2006 -0700
@@ -102,20 +102,14 @@ def verify(repo):
(short(n), short(p)))
try:
- delta = mdiff.patchtext(repo.manifest.delta(n))
+ for f, fn in repo.manifest.readdelta(n).iteritems():
+ filenodes.setdefault(f, {})[fn] = 1
except KeyboardInterrupt:
repo.ui.warn(_("interrupted"))
raise
except Exception, inst:
- err(_("unpacking manifest %s: %s") % (short(n), inst))
+ err(_("reading delta for manifest %s: %s") % (short(n), inst))
continue
-
- try:
- ff = [ l.split('\0') for l in delta.splitlines() ]
- for f, fn in ff:
- filenodes.setdefault(f, {})[bin(fn[:40])] = 1
- except (ValueError, TypeError), inst:
- err(_("broken delta in manifest %s: %s") % (short(n), inst))
repo.ui.status(_("crosschecking files in changesets and manifests\n"))
More information about the Mercurial
mailing list