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.
#!/bin/sh
# Script to get stable diff output on any platform.
#
# Output of this script is almost equivalent to GNU diff with "-Nru".
#
# Use this script as "hg pdiff" via extdiff extension with preparation
# below in test scripts:
#
# $ cat >> $HGRCPATH <<EOF
# > [extdiff]
# > pdiff = sh "$RUNTESTDIR/pdiff"
# > EOF
filediff(){
# USAGE: filediff file1 file2 [header]
# compare with /dev/null if file doesn't exist (as "-N" option)
file1="$1"
if test ! -f "$file1"; then
file1=/dev/null
fi
file2="$2"
if test ! -f "$file2"; then
file2=/dev/null
fi
if cmp -s "$file1" "$file2"; then
# Return immediately, because comparison isn't needed. This
# also avoids redundant message of diff like "No differences
# encountered" (on Solaris)
return
fi
if test -n "$3"; then
# show header only in recursive case
echo "$3"
fi
# replace "/dev/null" by corresponded filename (as "-N" option)
diff -u "$file1" "$file2" |
sed "s@^--- /dev/null\(.*\)\$@--- $1\1@" |
sed "s@^\+\+\+ /dev/null\(.*\)\$@+++ $2\1@"
}
if test -d "$1" -o -d "$2"; then
# ensure comparison in dictionary order
(
if test -d "$1"; then (cd "$1" && find . -type f); fi
if test -d "$2"; then (cd "$2" && find . -type f); fi
) |
sed 's@^\./@@g' | sort | uniq |
while read file; do
filediff "$1/$file" "$2/$file" "diff -Nru $1/$file $2/$file"
done
else
filediff "$1" "$2"
fi