Backed out changeset 4dd462c5c1c3

This commit is contained in:
Zhihui Huang 2018-01-03 05:35:56 -08:00
parent 274bc5fb01
commit 5518fa1a0b
4 changed files with 38 additions and 211 deletions

View File

@ -4182,7 +4182,7 @@ def recover(ui, repo):
Returns 0 if successful, 1 if nothing to recover or verify fails.
"""
if repo.recover():
return hg.verify(repo, None)
return hg.verify(repo)
return 1
@command('^remove|rm',
@ -5515,10 +5515,8 @@ def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False,
return hg.updatetotally(ui, repo, rev, brev, clean=clean,
updatecheck=updatecheck)
@command('verify',
[('r', 'rev', [], _('verify only the specified revision or revset'), _('REV')),
])
def verify(ui, repo, **opts):
@command('verify', [])
def verify(ui, repo):
"""verify the integrity of the repository
Verify the integrity of the current repository.
@ -5534,13 +5532,7 @@ def verify(ui, repo, **opts):
Returns 0 on success, 1 if errors are encountered.
"""
revrange = opts.get('rev')
if revrange:
revs = scmutil.revrange(repo, revrange)
else:
revs = None
return hg.verify(repo, revs)
return hg.verify(repo)
@command('version', [] + formatteropts, norepo=True, cmdtype=readonly)
def version_(ui, **opts):

View File

@ -970,13 +970,9 @@ def outgoing(ui, repo, dest, opts):
recurse()
return 0 # exit code is zero since we found outgoing changes
def verify(repo, revs=None):
"""verify the consistency of a repository
If revs is None, verify everything in the repository.
Otherwise, revs is a smartset that specifies revisions to verify
and some checks requiring knowledge about the entire repo will be skipped.
"""
ret = verifymod.verify(repo, revs)
def verify(repo):
"""verify the consistency of a repository"""
ret = verifymod.verify(repo)
# Broken subrepo references in hidden csets don't seem worth worrying about,
# since they can't be pushed/pulled, and --hidden can be used if they are a

View File

@ -22,9 +22,9 @@ from . import (
util,
)
def verify(repo, revs=None):
def verify(repo):
with repo.lock():
return verifier(repo, revs=revs).verify()
return verifier(repo).verify()
def _normpath(f):
# under hg < 2.4, convert didn't sanitize paths properly, so a
@ -36,7 +36,7 @@ def _normpath(f):
class verifier(object):
# The match argument is always None in hg core, but e.g. the narrowhg
# extension will pass in a matcher here.
def __init__(self, repo, match=None, revs=None):
def __init__(self, repo, match=None):
self.repo = repo.unfiltered()
self.ui = repo.ui
self.match = match or scmutil.matchall(repo)
@ -51,7 +51,6 @@ class verifier(object):
self.fncachewarned = False
# developer config: verify.skipflags
self.skipflags = repo.ui.configint('verify', 'skipflags')
self.revs = revs
def warn(self, msg):
self.ui.warn(msg + "\n")
@ -109,17 +108,16 @@ class verifier(object):
self.warn(_(" (expected %s)") % " ".join(map(str, linkrevs)))
lr = None # can't be trusted
if self.revs is None:
try:
p1, p2 = obj.parents(node)
if p1 not in seen and p1 != nullid:
self.err(lr, _("unknown parent 1 %s of %s") %
(short(p1), short(node)), f)
if p2 not in seen and p2 != nullid:
self.err(lr, _("unknown parent 2 %s of %s") %
(short(p2), short(node)), f)
except Exception as inst:
self.exc(lr, _("checking parents of %s") % short(node), inst, f)
try:
p1, p2 = obj.parents(node)
if p1 not in seen and p1 != nullid:
self.err(lr, _("unknown parent 1 %s of %s") %
(short(p1), short(node)), f)
if p2 not in seen and p2 != nullid:
self.err(lr, _("unknown parent 2 %s of %s") %
(short(p2), short(node)), f)
except Exception as inst:
self.exc(lr, _("checking parents of %s") % short(node), inst, f)
if node in seen:
self.err(lr, _("duplicate revision %d (%d)") % (i, seen[node]), f)
@ -150,12 +148,8 @@ class verifier(object):
totalfiles, filerevisions = self._verifyfiles(filenodes, filelinkrevs)
if self.revs is not None:
totalchangesets = len(self.revs)
else:
totalchangesets = len(repo.changelog)
ui.status(_("%d files, %d changesets, %d total revisions\n") %
(totalfiles, totalchangesets, filerevisions))
(totalfiles, len(repo.changelog), filerevisions))
if self.warnings:
ui.warn(_("%d warnings encountered!\n") % self.warnings)
if self.fncachewarned:
@ -178,15 +172,9 @@ class verifier(object):
mflinkrevs = {}
filelinkrevs = {}
seen = {}
if self.revs is not None:
revs = self.revs
else:
revs = repo
self.checklog(cl, "changelog", 0)
total = len(revs)
for i in revs:
total = len(repo)
for i in repo:
ui.progress(_('checking'), i, total=total, unit=_('changesets'))
n = cl.node(i)
self.checkentry(cl, i, n, seen, [i], "changelog")
@ -232,8 +220,6 @@ class verifier(object):
self.checklog(mf, label, 0)
total = len(mf)
for i in mf:
if self.revs is not None and mf.linkrev(i) not in self.revs:
continue
if not dir:
ui.progress(_('checking'), i, total=total, unit=_('manifests'))
n = mf.node(i)
@ -347,13 +333,12 @@ class verifier(object):
ui.status(_("checking files\n"))
storefiles = set()
if self.revs is None:
# only check store files when verifying the entire repo
for f, f2, size in repo.store.datafiles():
if not f:
self.err(None, _("cannot decode filename '%s'") % f2)
elif (size > 0 or not revlogv1) and f.startswith('data/'):
storefiles.add(_normpath(f))
for f, f2, size in repo.store.datafiles():
if not f:
self.err(None, _("cannot decode filename '%s'") % f2)
elif (size > 0 or not revlogv1) and f.startswith('data/'):
storefiles.add(_normpath(f))
files = sorted(set(filenodes) | set(filelinkrevs))
total = len(files)
revisions = 0
@ -376,20 +361,17 @@ class verifier(object):
self.err(lr, _("broken revlog! (%s)") % e, f)
continue
if self.revs is None:
for ff in fl.files():
try:
storefiles.remove(ff)
except KeyError:
self.warn(_(" warning: revlog '%s' not in fncache!") % ff)
self.fncachewarned = True
for ff in fl.files():
try:
storefiles.remove(ff)
except KeyError:
self.warn(_(" warning: revlog '%s' not in fncache!") % ff)
self.fncachewarned = True
self.checklog(fl, f, lr)
seen = {}
rp = None
for i in fl:
if self.revs is not None and fl.linkrev(i) not in self.revs:
continue
revisions += 1
n = fl.node(i)
lr = self.checkentry(fl, i, n, seen, linkrevs, f)
@ -500,8 +482,7 @@ class verifier(object):
short(node), f)
ui.progress(_('checking'), None)
if self.revs is None:
for f in sorted(storefiles):
self.warn(_("warning: orphan revlog '%s'") % f)
for f in sorted(storefiles):
self.warn(_("warning: orphan revlog '%s'") % f)
return len(files), revisions

View File

@ -20,24 +20,6 @@ verify
checking files
3 files, 1 changesets, 3 total revisions
verify current commit
$ hg verify -r '.'
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
3 files, 1 changesets, 3 total revisions
verify all commits using rev range
$ hg verify -r ':'
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
3 files, 1 changesets, 3 total revisions
verify with journal
$ touch .hg/store/journal
@ -78,22 +60,6 @@ introduce some bugs in repo
(first damaged changeset appears to be 0)
[1]
$ hg verify -r '.'
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
0: empty or missing FOO.txt
FOO.txt@0: manifest refers to unknown revision f62022d3d590
0: empty or missing QUICK.txt
QUICK.txt@0: manifest refers to unknown revision 88b857db8eba
0: empty or missing bar.txt
bar.txt@0: manifest refers to unknown revision 256559129457
3 files, 1 changesets, 0 total revisions
6 integrity errors encountered!
(first damaged changeset appears to be 0)
[1]
$ cd ../../..
$ cd ..
@ -111,7 +77,7 @@ Set up a repo for testing missing revlog entries
Entire changelog missing
$ rm .hg/store/00changelog.*
$ hg verify -q
$ hg verify -q
0: empty or missing changelog
manifest@0: d0b6632564d4 not in changesets
manifest@1: 941fc4534185 not in changesets
@ -128,16 +94,6 @@ Entire manifest log missing
1 integrity errors encountered!
(first damaged changeset appears to be 0)
[1]
$ hg verify -q -r '.'
0: empty or missing manifest
1 integrity errors encountered!
(first damaged changeset appears to be 0)
[1]
$ hg verify -q -r '.^'
0: empty or missing manifest
1 integrity errors encountered!
(first damaged changeset appears to be 0)
[1]
$ cp -R .hg/store-full/. .hg/store
Entire filelog missing
@ -153,19 +109,6 @@ Entire filelog missing
3 integrity errors encountered!
(first damaged changeset appears to be 0)
[1]
$ hg verify -q -r '.'
1: empty or missing file
file@1: manifest refers to unknown revision c10f2164107d
2 integrity errors encountered!
(first damaged changeset appears to be 1)
[1]
$ hg verify -q -r ':tip'
0: empty or missing file
file@0: manifest refers to unknown revision 362fef284ce2
file@1: manifest refers to unknown revision c10f2164107d
3 integrity errors encountered!
(first damaged changeset appears to be 0)
[1]
$ cp -R .hg/store-full/. .hg/store
Entire changelog and manifest log missing
@ -209,12 +152,6 @@ Entire manifest log and filelog missing
2 integrity errors encountered!
(first damaged changeset appears to be 0)
[1]
$ hg verify -q -r '.'
0: empty or missing manifest
1: empty or missing file
2 integrity errors encountered!
(first damaged changeset appears to be 0)
[1]
$ cp -R .hg/store-full/. .hg/store
Changelog missing entry
@ -228,12 +165,6 @@ Changelog missing entry
1 warnings encountered!
3 integrity errors encountered!
[1]
$ hg verify -q -r 0
warning: ignoring unknown working parent c5ddb05ab828!
$ hg verify -q -r 1
warning: ignoring unknown working parent c5ddb05ab828!
abort: unknown revision '1'!
[255]
$ cp -R .hg/store-full/. .hg/store
Manifest log missing entry
@ -245,13 +176,6 @@ Manifest log missing entry
2 integrity errors encountered!
(first damaged changeset appears to be 1)
[1]
$ hg verify -q -r '.'
manifest@1: changeset refers to unknown revision 941fc4534185
file@1: in changeset but not in manifest
2 integrity errors encountered!
(first damaged changeset appears to be 1)
[1]
$ hg verify -q -r '.^'
$ cp -R .hg/store-full/. .hg/store
Filelog missing entry
@ -262,12 +186,6 @@ Filelog missing entry
1 integrity errors encountered!
(first damaged changeset appears to be 1)
[1]
$ hg verify -q -r'.'
file@1: manifest refers to unknown revision c10f2164107d
1 integrity errors encountered!
(first damaged changeset appears to be 1)
[1]
$ hg verify -q -r'.^'
$ cp -R .hg/store-full/. .hg/store
Changelog and manifest log missing entry
@ -281,12 +199,6 @@ Changelog and manifest log missing entry
1 warnings encountered!
2 integrity errors encountered!
[1]
$ hg verify -q -r 0
warning: ignoring unknown working parent c5ddb05ab828!
$ hg verify -q -r 1
warning: ignoring unknown working parent c5ddb05ab828!
abort: unknown revision '1'!
[255]
$ cp -R .hg/store-full/. .hg/store
Changelog and filelog missing entry
@ -299,12 +211,6 @@ Changelog and filelog missing entry
file@?: manifest refers to unknown revision c10f2164107d
3 integrity errors encountered!
[1]
$ hg verify -q -r 0
warning: ignoring unknown working parent c5ddb05ab828!
$ hg verify -q -r 1
warning: ignoring unknown working parent c5ddb05ab828!
abort: unknown revision '1'!
[255]
$ cp -R .hg/store-full/. .hg/store
Manifest and filelog missing entry
@ -316,13 +222,6 @@ Manifest and filelog missing entry
1 integrity errors encountered!
(first damaged changeset appears to be 1)
[1]
$ hg verify -q -r '.'
manifest@1: changeset refers to unknown revision 941fc4534185
file@1: in changeset but not in manifest
2 integrity errors encountered!
(first damaged changeset appears to be 1)
[1]
$ hg verify -q -r '.^'
$ cp -R .hg/store-full/. .hg/store
Corrupt changelog base node to cause failure to read revision
@ -339,16 +238,6 @@ Corrupt changelog base node to cause failure to read revision
4 integrity errors encountered!
(first damaged changeset appears to be 0)
[1]
$ hg verify -q -r '.'
$ hg verify -q -r '.^'
0: unpacking changeset 08b1860757c2: * (glob)
manifest@?: rev 0 points to unexpected changeset 0
manifest@?: d0b6632564d4 not in changesets
file@0: in manifest but not in changeset
file@?: rev 0 points to unexpected changeset 0
5 integrity errors encountered!
(first damaged changeset appears to be 0)
[1]
$ cp -R .hg/store-full/. .hg/store
Corrupt manifest log base node to cause failure to read revision
@ -361,13 +250,6 @@ Corrupt manifest log base node to cause failure to read revision
2 integrity errors encountered!
(first damaged changeset appears to be 0)
[1]
$ hg verify -q -r '.'
$ hg verify -q -r '.^'
manifest@0: reading delta d0b6632564d4: * (glob)
file@0: in changeset but not in manifest
2 integrity errors encountered!
(first damaged changeset appears to be 0)
[1]
$ cp -R .hg/store-full/. .hg/store
Corrupt filelog base node to cause failure to read revision
@ -379,12 +261,6 @@ Corrupt filelog base node to cause failure to read revision
1 integrity errors encountered!
(first damaged changeset appears to be 0)
[1]
$ hg verify -q -r '.'
$ hg verify -q -r '.^'
file@0: unpacking 362fef284ce2: * (glob)
1 integrity errors encountered!
(first damaged changeset appears to be 0)
[1]
$ cp -R .hg/store-full/. .hg/store
$ cd ..
@ -427,24 +303,6 @@ test revlog corruption
(first damaged changeset appears to be 1)
[1]
$ hg verify -r '.'
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
a@1: broken revlog! (index data/a.i is corrupted)
1 files, 1 changesets, 0 total revisions
1 integrity errors encountered!
(first damaged changeset appears to be 1)
[1]
$ hg verify -r '.^'
checking changesets
checking manifests
crosschecking files in changesets and manifests
checking files
0 files, 1 changesets, 0 total revisions
$ cd ..
test revlog format 0