Mercurial > public > mercurial-scm > hg
diff mercurial/manifest.py @ 28203:7297e9e13a8a
verify: check directory manifests
In repos with treemanifests, there is no specific verification of
directory manifest revlogs. It simply collects all file nodes by
reading each manifest delta. With treemanifests, that's means calling
the manifest._slowreaddelta(). If there are missing revlog entries in
a subdirectory revlog, 'hg verify' will simply report the exception
that occurred while trying to read the root manifest:
manifest@0: reading delta 1700e2e92882: meta/b/00manifest.i@67688a370455: no node
This patch changes the verify code to load only the root manifest at
first and verify all revisions of it, then verify all revisions of
each direct subdirectory, and so on, recursively. The above message
becomes
b/@0: parent-directory manifest refers to unknown revision 67688a370455
Since the new algorithm reads a single revlog at a time and in order,
'hg verify' on a treemanifest version of the hg core repo goes from
~50s to ~14s. As expected, there is no significant difference on a
repo with flat manifests.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Sun, 07 Feb 2016 21:13:24 -0800 |
parents | 2df7f5c09c34 |
children | 8ab91d9290ce |
line wrap: on
line diff
--- a/mercurial/manifest.py Sat Feb 20 17:44:29 2016 -0800 +++ b/mercurial/manifest.py Sun Feb 07 21:13:24 2016 -0800 @@ -325,6 +325,9 @@ def iteritems(self): return (x[:2] for x in self._lm.iterentries()) + def iterentries(self): + return self._lm.iterentries() + def text(self, usemanifestv2=False): if usemanifestv2: return _textv2(self._lm.iterentries()) @@ -920,7 +923,8 @@ return manifestdict(data) def dirlog(self, dir): - assert self._treeondisk + if dir: + assert self._treeondisk if dir not in self._dirlogcache: self._dirlogcache[dir] = manifest(self.opener, dir, self._dirlogcache) @@ -945,6 +949,22 @@ d = mdiff.patchtext(self.revdiff(self.deltaparent(r), r)) return self._newmanifest(d) + def readshallowdelta(self, node): + '''For flat manifests, this is the same as readdelta(). For + treemanifests, this will read the delta for this revlog's directory, + without recursively reading subdirectory manifests. Instead, any + subdirectory entry will be reported as it appears in the manifests, i.e. + the subdirectory will be reported among files and distinguished only by + its 't' flag.''' + if not self._treeondisk: + return self.readdelta(node) + if self._usemanifestv2: + raise error.Abort( + "readshallowdelta() not implemented for manifestv2") + r = self.rev(node) + d = mdiff.patchtext(self.revdiff(self.deltaparent(r), r)) + return manifestdict(d) + def readfast(self, node): '''use the faster of readdelta or read