Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
pulkit |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/verify.py (31 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Martin von Zweigbergk | Jun 18 2018, 2:28 AM |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
match = self.match | match = self.match | ||||
cl = repo.changelog | cl = repo.changelog | ||||
ui.status(_("checking changesets\n")) | ui.status(_("checking changesets\n")) | ||||
mflinkrevs = {} | mflinkrevs = {} | ||||
filelinkrevs = {} | filelinkrevs = {} | ||||
seen = {} | seen = {} | ||||
self.checklog(cl, "changelog", 0) | self.checklog(cl, "changelog", 0) | ||||
total = len(repo) | progress = ui.makeprogress(_('checking'), unit=_('changesets'), | ||||
total=len(repo)) | |||||
for i in repo: | for i in repo: | ||||
ui.progress(_('checking'), i, total=total, unit=_('changesets')) | progress.update(i) | ||||
n = cl.node(i) | n = cl.node(i) | ||||
self.checkentry(cl, i, n, seen, [i], "changelog") | self.checkentry(cl, i, n, seen, [i], "changelog") | ||||
try: | try: | ||||
changes = cl.read(n) | changes = cl.read(n) | ||||
if changes[0] != nullid: | if changes[0] != nullid: | ||||
mflinkrevs.setdefault(changes[0], []).append(i) | mflinkrevs.setdefault(changes[0], []).append(i) | ||||
self.refersmf = True | self.refersmf = True | ||||
for f in changes[3]: | for f in changes[3]: | ||||
if match(f): | if match(f): | ||||
filelinkrevs.setdefault(_normpath(f), []).append(i) | filelinkrevs.setdefault(_normpath(f), []).append(i) | ||||
except Exception as inst: | except Exception as inst: | ||||
self.refersmf = True | self.refersmf = True | ||||
self.exc(i, _("unpacking changeset %s") % short(n), inst) | self.exc(i, _("unpacking changeset %s") % short(n), inst) | ||||
ui.progress(_('checking'), None) | progress.complete() | ||||
return mflinkrevs, filelinkrevs | return mflinkrevs, filelinkrevs | ||||
def _verifymanifest(self, mflinkrevs, dir="", storefiles=None, | def _verifymanifest(self, mflinkrevs, dir="", storefiles=None, | ||||
subdirprogress=None): | subdirprogress=None): | ||||
repo = self.repo | repo = self.repo | ||||
ui = self.ui | ui = self.ui | ||||
match = self.match | match = self.match | ||||
mfl = self.repo.manifestlog | mfl = self.repo.manifestlog | ||||
revlogfiles = mf.files() | revlogfiles = mf.files() | ||||
storefiles.difference_update(revlogfiles) | storefiles.difference_update(revlogfiles) | ||||
if subdirprogress: # should be true since we're in a subdirectory | if subdirprogress: # should be true since we're in a subdirectory | ||||
subdirprogress.increment() | subdirprogress.increment() | ||||
if self.refersmf: | if self.refersmf: | ||||
# Do not check manifest if there are only changelog entries with | # Do not check manifest if there are only changelog entries with | ||||
# null manifests. | # null manifests. | ||||
self.checklog(mf, label, 0) | self.checklog(mf, label, 0) | ||||
total = len(mf) | progress = ui.makeprogress(_('checking'), unit=_('manifests'), | ||||
total=len(mf)) | |||||
for i in mf: | for i in mf: | ||||
if not dir: | if not dir: | ||||
ui.progress(_('checking'), i, total=total, unit=_('manifests')) | progress.update(i) | ||||
n = mf.node(i) | n = mf.node(i) | ||||
lr = self.checkentry(mf, i, n, seen, mflinkrevs.get(n, []), label) | lr = self.checkentry(mf, i, n, seen, mflinkrevs.get(n, []), label) | ||||
if n in mflinkrevs: | if n in mflinkrevs: | ||||
del mflinkrevs[n] | del mflinkrevs[n] | ||||
elif dir: | elif dir: | ||||
self.err(lr, _("%s not in parent-directory manifest") % | self.err(lr, _("%s not in parent-directory manifest") % | ||||
short(n), label) | short(n), label) | ||||
else: | else: | ||||
fn, []).append(lr) | fn, []).append(lr) | ||||
else: | else: | ||||
if not match(fullpath): | if not match(fullpath): | ||||
continue | continue | ||||
filenodes.setdefault(fullpath, {}).setdefault(fn, lr) | filenodes.setdefault(fullpath, {}).setdefault(fn, lr) | ||||
except Exception as inst: | except Exception as inst: | ||||
self.exc(lr, _("reading delta %s") % short(n), inst, label) | self.exc(lr, _("reading delta %s") % short(n), inst, label) | ||||
if not dir: | if not dir: | ||||
ui.progress(_('checking'), None) | progress.complete() | ||||
if self.havemf: | if self.havemf: | ||||
for c, m in sorted([(c, m) for m in mflinkrevs | for c, m in sorted([(c, m) for m in mflinkrevs | ||||
for c in mflinkrevs[m]]): | for c in mflinkrevs[m]]): | ||||
if dir: | if dir: | ||||
self.err(c, _("parent-directory manifest refers to unknown " | self.err(c, _("parent-directory manifest refers to unknown " | ||||
"revision %s") % short(m), label) | "revision %s") % short(m), label) | ||||
else: | else: | ||||
return filenodes | return filenodes | ||||
def _crosscheckfiles(self, filelinkrevs, filenodes): | def _crosscheckfiles(self, filelinkrevs, filenodes): | ||||
repo = self.repo | repo = self.repo | ||||
ui = self.ui | ui = self.ui | ||||
ui.status(_("crosschecking files in changesets and manifests\n")) | ui.status(_("crosschecking files in changesets and manifests\n")) | ||||
total = len(filelinkrevs) + len(filenodes) | total = len(filelinkrevs) + len(filenodes) | ||||
count = 0 | progress = ui.makeprogress(_('crosschecking'), total=total) | ||||
if self.havemf: | if self.havemf: | ||||
for f in sorted(filelinkrevs): | for f in sorted(filelinkrevs): | ||||
count += 1 | progress.increment() | ||||
ui.progress(_('crosschecking'), count, total=total) | |||||
if f not in filenodes: | if f not in filenodes: | ||||
lr = filelinkrevs[f][0] | lr = filelinkrevs[f][0] | ||||
self.err(lr, _("in changeset but not in manifest"), f) | self.err(lr, _("in changeset but not in manifest"), f) | ||||
if self.havecl: | if self.havecl: | ||||
for f in sorted(filenodes): | for f in sorted(filenodes): | ||||
count += 1 | progress.increment() | ||||
ui.progress(_('crosschecking'), count, total=total) | |||||
if f not in filelinkrevs: | if f not in filelinkrevs: | ||||
try: | try: | ||||
fl = repo.file(f) | fl = repo.file(f) | ||||
lr = min([fl.linkrev(fl.rev(n)) for n in filenodes[f]]) | lr = min([fl.linkrev(fl.rev(n)) for n in filenodes[f]]) | ||||
except Exception: | except Exception: | ||||
lr = None | lr = None | ||||
self.err(lr, _("in manifest but not in changeset"), f) | self.err(lr, _("in manifest but not in changeset"), f) | ||||
ui.progress(_('crosschecking'), None) | progress.complete() | ||||
def _verifyfiles(self, filenodes, filelinkrevs): | def _verifyfiles(self, filenodes, filelinkrevs): | ||||
repo = self.repo | repo = self.repo | ||||
ui = self.ui | ui = self.ui | ||||
lrugetctx = self.lrugetctx | lrugetctx = self.lrugetctx | ||||
revlogv1 = self.revlogv1 | revlogv1 = self.revlogv1 | ||||
havemf = self.havemf | havemf = self.havemf | ||||
ui.status(_("checking files\n")) | ui.status(_("checking files\n")) | ||||
storefiles = set() | storefiles = set() | ||||
for f, f2, size in repo.store.datafiles(): | for f, f2, size in repo.store.datafiles(): | ||||
if not f: | if not f: | ||||
self.err(None, _("cannot decode filename '%s'") % f2) | self.err(None, _("cannot decode filename '%s'") % f2) | ||||
elif (size > 0 or not revlogv1) and f.startswith('data/'): | elif (size > 0 or not revlogv1) and f.startswith('data/'): | ||||
storefiles.add(_normpath(f)) | storefiles.add(_normpath(f)) | ||||
files = sorted(set(filenodes) | set(filelinkrevs)) | files = sorted(set(filenodes) | set(filelinkrevs)) | ||||
total = len(files) | |||||
revisions = 0 | revisions = 0 | ||||
progress = ui.makeprogress(_('checking'), unit=_('files'), | |||||
total=len(files)) | |||||
for i, f in enumerate(files): | for i, f in enumerate(files): | ||||
ui.progress(_('checking'), i, item=f, total=total, unit=_('files')) | progress.update(i, item=f) | ||||
try: | try: | ||||
linkrevs = filelinkrevs[f] | linkrevs = filelinkrevs[f] | ||||
except KeyError: | except KeyError: | ||||
# in manifest but not in changelog | # in manifest but not in changelog | ||||
linkrevs = [] | linkrevs = [] | ||||
if linkrevs: | if linkrevs: | ||||
lr = linkrevs[0] | lr = linkrevs[0] | ||||
self.exc(lr, _("checking rename of %s") % short(n), inst, f) | self.exc(lr, _("checking rename of %s") % short(n), inst, f) | ||||
# cross-check | # cross-check | ||||
if f in filenodes: | if f in filenodes: | ||||
fns = [(v, k) for k, v in filenodes[f].iteritems()] | fns = [(v, k) for k, v in filenodes[f].iteritems()] | ||||
for lr, node in sorted(fns): | for lr, node in sorted(fns): | ||||
self.err(lr, _("manifest refers to unknown revision %s") % | self.err(lr, _("manifest refers to unknown revision %s") % | ||||
short(node), f) | short(node), f) | ||||
ui.progress(_('checking'), None) | progress.complete() | ||||
if self.warnorphanstorefiles: | if self.warnorphanstorefiles: | ||||
for f in sorted(storefiles): | for f in sorted(storefiles): | ||||
self.warn(_("warning: orphan data file '%s'") % f) | self.warn(_("warning: orphan data file '%s'") % f) | ||||
return len(files), revisions | return len(files), revisions |