Mercurial > hg
annotate mercurial/verify.py @ 26918:0438df737fb7
test: enable generaldelta in 'test-debugcommand.t'
The test logic is not affected by generaldelta, so we move it to
generaldelta early. Some of the fuzzy matching had to be extended to
cover "delta".
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Sun, 18 Oct 2015 19:04:29 +0200 |
parents | d1c741644d25 |
children | 937e73a6e4ff |
rev | line source |
---|---|
2778 | 1 # verify.py - repository integrity checking for Mercurial |
2 # | |
4635
63b9d2deed48
Updated copyright notices and add "and others" to "hg version"
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4395
diff
changeset
|
3 # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com> |
2778 | 4 # |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8209
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
10263 | 6 # GNU General Public License version 2 or any later version. |
2778 | 7 |
25991
d21d1774c73b
verify: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25846
diff
changeset
|
8 from __future__ import absolute_import |
d21d1774c73b
verify: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25846
diff
changeset
|
9 |
17860
a45b33f12627
verify: fix all doubled-slash sites (issue3665)
Bryan O'Sullivan <bryano@fb.com>
parents:
17851
diff
changeset
|
10 import os |
25991
d21d1774c73b
verify: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25846
diff
changeset
|
11 |
d21d1774c73b
verify: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25846
diff
changeset
|
12 from .i18n import _ |
d21d1774c73b
verify: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25846
diff
changeset
|
13 from .node import ( |
d21d1774c73b
verify: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25846
diff
changeset
|
14 nullid, |
d21d1774c73b
verify: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25846
diff
changeset
|
15 short, |
d21d1774c73b
verify: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25846
diff
changeset
|
16 ) |
d21d1774c73b
verify: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25846
diff
changeset
|
17 |
d21d1774c73b
verify: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25846
diff
changeset
|
18 from . import ( |
d21d1774c73b
verify: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25846
diff
changeset
|
19 error, |
d21d1774c73b
verify: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25846
diff
changeset
|
20 revlog, |
d21d1774c73b
verify: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25846
diff
changeset
|
21 util, |
d21d1774c73b
verify: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25846
diff
changeset
|
22 ) |
2778 | 23 |
24 def verify(repo): | |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4635
diff
changeset
|
25 lock = repo.lock() |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4635
diff
changeset
|
26 try: |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4635
diff
changeset
|
27 return _verify(repo) |
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4635
diff
changeset
|
28 finally: |
8109
496ae1ea4698
switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
7926
diff
changeset
|
29 lock.release() |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4635
diff
changeset
|
30 |
17860
a45b33f12627
verify: fix all doubled-slash sites (issue3665)
Bryan O'Sullivan <bryano@fb.com>
parents:
17851
diff
changeset
|
31 def _normpath(f): |
a45b33f12627
verify: fix all doubled-slash sites (issue3665)
Bryan O'Sullivan <bryano@fb.com>
parents:
17851
diff
changeset
|
32 # under hg < 2.4, convert didn't sanitize paths properly, so a |
a45b33f12627
verify: fix all doubled-slash sites (issue3665)
Bryan O'Sullivan <bryano@fb.com>
parents:
17851
diff
changeset
|
33 # converted repo may contain repeated slashes |
a45b33f12627
verify: fix all doubled-slash sites (issue3665)
Bryan O'Sullivan <bryano@fb.com>
parents:
17851
diff
changeset
|
34 while '//' in f: |
a45b33f12627
verify: fix all doubled-slash sites (issue3665)
Bryan O'Sullivan <bryano@fb.com>
parents:
17851
diff
changeset
|
35 f = f.replace('//', '/') |
a45b33f12627
verify: fix all doubled-slash sites (issue3665)
Bryan O'Sullivan <bryano@fb.com>
parents:
17851
diff
changeset
|
36 return f |
a45b33f12627
verify: fix all doubled-slash sites (issue3665)
Bryan O'Sullivan <bryano@fb.com>
parents:
17851
diff
changeset
|
37 |
26900
d1c741644d25
verify: add a hook that can let extensions manipulate file lists
Augie Fackler <augie@google.com>
parents:
26587
diff
changeset
|
38 def _validpath(repo, path): |
d1c741644d25
verify: add a hook that can let extensions manipulate file lists
Augie Fackler <augie@google.com>
parents:
26587
diff
changeset
|
39 """Returns False if a path should NOT be treated as part of a repo. |
d1c741644d25
verify: add a hook that can let extensions manipulate file lists
Augie Fackler <augie@google.com>
parents:
26587
diff
changeset
|
40 |
d1c741644d25
verify: add a hook that can let extensions manipulate file lists
Augie Fackler <augie@google.com>
parents:
26587
diff
changeset
|
41 For all in-core cases, this returns True, as we have no way for a |
d1c741644d25
verify: add a hook that can let extensions manipulate file lists
Augie Fackler <augie@google.com>
parents:
26587
diff
changeset
|
42 path to be mentioned in the history but not actually be |
d1c741644d25
verify: add a hook that can let extensions manipulate file lists
Augie Fackler <augie@google.com>
parents:
26587
diff
changeset
|
43 relevant. For narrow clones, this is important because many |
d1c741644d25
verify: add a hook that can let extensions manipulate file lists
Augie Fackler <augie@google.com>
parents:
26587
diff
changeset
|
44 filelogs will be missing, and changelog entries may mention |
d1c741644d25
verify: add a hook that can let extensions manipulate file lists
Augie Fackler <augie@google.com>
parents:
26587
diff
changeset
|
45 modified files that are outside the narrow scope. |
d1c741644d25
verify: add a hook that can let extensions manipulate file lists
Augie Fackler <augie@google.com>
parents:
26587
diff
changeset
|
46 """ |
d1c741644d25
verify: add a hook that can let extensions manipulate file lists
Augie Fackler <augie@google.com>
parents:
26587
diff
changeset
|
47 return True |
d1c741644d25
verify: add a hook that can let extensions manipulate file lists
Augie Fackler <augie@google.com>
parents:
26587
diff
changeset
|
48 |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4635
diff
changeset
|
49 def _verify(repo): |
18003
e1e181a64de7
clfilter: verify logic should be unfiltered
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17860
diff
changeset
|
50 repo = repo.unfiltered() |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
51 mflinkrevs = {} |
2778 | 52 filelinkrevs = {} |
53 filenodes = {} | |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
54 revisions = 0 |
8466
afb3e504b558
verify: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8394
diff
changeset
|
55 badrevs = set() |
2778 | 56 errors = [0] |
57 warnings = [0] | |
6751
7424a75f919a
verify: add some local variables
Matt Mackall <mpm@selenic.com>
parents:
6750
diff
changeset
|
58 ui = repo.ui |
7424a75f919a
verify: add some local variables
Matt Mackall <mpm@selenic.com>
parents:
6750
diff
changeset
|
59 cl = repo.changelog |
7424a75f919a
verify: add some local variables
Matt Mackall <mpm@selenic.com>
parents:
6750
diff
changeset
|
60 mf = repo.manifest |
9657
96c803e9018f
verify: filter the candidate list for broken linkrevs
Matt Mackall <mpm@selenic.com>
parents:
9545
diff
changeset
|
61 lrugetctx = util.lrucachefunc(repo.changectx) |
2778 | 62 |
20530
78f547cdc362
verify: do not prevent verify repository containing hidden changesets
Yuya Nishihara <yuya@tcha.org>
parents:
18003
diff
changeset
|
63 if not repo.url().startswith('file:'): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25991
diff
changeset
|
64 raise error.Abort(_("cannot verify bundle or remote repos")) |
7141
8d1bdaf842de
issue 1144: prevent traceback on verify of bundles
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
7004
diff
changeset
|
65 |
5313
29be4228303b
verify: report first bad changeset
Matt Mackall <mpm@selenic.com>
parents:
5179
diff
changeset
|
66 def err(linkrev, msg, filename=None): |
13031
3da456d0c885
code style: prefer 'is' and 'is not' tests with singletons
Martin Geisler <mg@aragost.com>
parents:
12745
diff
changeset
|
67 if linkrev is not None: |
8466
afb3e504b558
verify: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8394
diff
changeset
|
68 badrevs.add(linkrev) |
5313
29be4228303b
verify: report first bad changeset
Matt Mackall <mpm@selenic.com>
parents:
5179
diff
changeset
|
69 else: |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
70 linkrev = '?' |
5313
29be4228303b
verify: report first bad changeset
Matt Mackall <mpm@selenic.com>
parents:
5179
diff
changeset
|
71 msg = "%s: %s" % (linkrev, msg) |
29be4228303b
verify: report first bad changeset
Matt Mackall <mpm@selenic.com>
parents:
5179
diff
changeset
|
72 if filename: |
29be4228303b
verify: report first bad changeset
Matt Mackall <mpm@selenic.com>
parents:
5179
diff
changeset
|
73 msg = "%s@%s" % (filename, msg) |
6751
7424a75f919a
verify: add some local variables
Matt Mackall <mpm@selenic.com>
parents:
6750
diff
changeset
|
74 ui.warn(" " + msg + "\n") |
2778 | 75 errors[0] += 1 |
76 | |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
77 def exc(linkrev, msg, inst, filename=None): |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
78 if isinstance(inst, KeyboardInterrupt): |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
79 ui.warn(_("interrupted")) |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
80 raise |
11752
12998fd17fbc
verify: report exceptions that don't have a str() method
Matt Mackall <mpm@selenic.com>
parents:
10906
diff
changeset
|
81 if not str(inst): |
12998fd17fbc
verify: report exceptions that don't have a str() method
Matt Mackall <mpm@selenic.com>
parents:
10906
diff
changeset
|
82 inst = repr(inst) |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
83 err(linkrev, "%s: %s" % (msg, inst), filename) |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
84 |
2778 | 85 def warn(msg): |
6751
7424a75f919a
verify: add some local variables
Matt Mackall <mpm@selenic.com>
parents:
6750
diff
changeset
|
86 ui.warn(msg + "\n") |
2778 | 87 warnings[0] += 1 |
88 | |
8292
29540554def8
verify: reference the correct linkrev when a filelog is missing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8291
diff
changeset
|
89 def checklog(obj, name, linkrev): |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
90 if not len(obj) and (havecl or havemf): |
8292
29540554def8
verify: reference the correct linkrev when a filelog is missing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8291
diff
changeset
|
91 err(linkrev, _("empty or missing %s") % name) |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
92 return |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
93 |
2778 | 94 d = obj.checksize() |
95 if d[0]: | |
5313
29be4228303b
verify: report first bad changeset
Matt Mackall <mpm@selenic.com>
parents:
5179
diff
changeset
|
96 err(None, _("data length off by %d bytes") % d[0], name) |
2778 | 97 if d[1]: |
5313
29be4228303b
verify: report first bad changeset
Matt Mackall <mpm@selenic.com>
parents:
5179
diff
changeset
|
98 err(None, _("index contains %d extra bytes") % d[1], name) |
2778 | 99 |
100 if obj.version != revlog.REVLOGV0: | |
101 if not revlogv1: | |
102 warn(_("warning: `%s' uses revlog format 1") % name) | |
103 elif revlogv1: | |
104 warn(_("warning: `%s' uses revlog format 0") % name) | |
105 | |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
106 def checkentry(obj, i, node, seen, linkrevs, f): |
7361
9fe97eea5510
linkrev: take a revision number rather than a hash
Matt Mackall <mpm@selenic.com>
parents:
7141
diff
changeset
|
107 lr = obj.linkrev(obj.rev(node)) |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
108 if lr < 0 or (havecl and lr not in linkrevs): |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
109 if lr < 0 or lr >= len(cl): |
7926
edf2d83a11aa
verify, i18n: fix unmarked strings
Wagner Bruna <wbruna@yahoo.com>
parents:
7874
diff
changeset
|
110 msg = _("rev %d points to nonexistent changeset %d") |
edf2d83a11aa
verify, i18n: fix unmarked strings
Wagner Bruna <wbruna@yahoo.com>
parents:
7874
diff
changeset
|
111 else: |
edf2d83a11aa
verify, i18n: fix unmarked strings
Wagner Bruna <wbruna@yahoo.com>
parents:
7874
diff
changeset
|
112 msg = _("rev %d points to unexpected changeset %d") |
edf2d83a11aa
verify, i18n: fix unmarked strings
Wagner Bruna <wbruna@yahoo.com>
parents:
7874
diff
changeset
|
113 err(None, msg % (i, lr), f) |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
114 if linkrevs: |
9657
96c803e9018f
verify: filter the candidate list for broken linkrevs
Matt Mackall <mpm@selenic.com>
parents:
9545
diff
changeset
|
115 if f and len(linkrevs) > 1: |
96c803e9018f
verify: filter the candidate list for broken linkrevs
Matt Mackall <mpm@selenic.com>
parents:
9545
diff
changeset
|
116 try: |
96c803e9018f
verify: filter the candidate list for broken linkrevs
Matt Mackall <mpm@selenic.com>
parents:
9545
diff
changeset
|
117 # attempt to filter down to real linkrevs |
96c803e9018f
verify: filter the candidate list for broken linkrevs
Matt Mackall <mpm@selenic.com>
parents:
9545
diff
changeset
|
118 linkrevs = [l for l in linkrevs |
96c803e9018f
verify: filter the candidate list for broken linkrevs
Matt Mackall <mpm@selenic.com>
parents:
9545
diff
changeset
|
119 if lrugetctx(l)[f].filenode() == node] |
16689
f366d4c2ff34
cleanup: replace naked excepts with except Exception: ...
Brodie Rao <brodie@sf.io>
parents:
14879
diff
changeset
|
120 except Exception: |
9657
96c803e9018f
verify: filter the candidate list for broken linkrevs
Matt Mackall <mpm@selenic.com>
parents:
9545
diff
changeset
|
121 pass |
9198
061eeb602354
coding style: use a space after comma
Martin Geisler <mg@lazybytes.net>
parents:
9033
diff
changeset
|
122 warn(_(" (expected %s)") % " ".join(map(str, linkrevs))) |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
123 lr = None # can't be trusted |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
124 |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
125 try: |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
126 p1, p2 = obj.parents(node) |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
127 if p1 not in seen and p1 != nullid: |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
128 err(lr, _("unknown parent 1 %s of %s") % |
17719
2e3ceb59c312
verify: use appropriate local variable in "checkentry()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17718
diff
changeset
|
129 (short(p1), short(node)), f) |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
130 if p2 not in seen and p2 != nullid: |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
131 err(lr, _("unknown parent 2 %s of %s") % |
17719
2e3ceb59c312
verify: use appropriate local variable in "checkentry()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17718
diff
changeset
|
132 (short(p2), short(node)), f) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25653
diff
changeset
|
133 except Exception as inst: |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
134 exc(lr, _("checking parents of %s") % short(node), inst, f) |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
135 |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
136 if node in seen: |
17719
2e3ceb59c312
verify: use appropriate local variable in "checkentry()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17718
diff
changeset
|
137 err(lr, _("duplicate revision %d (%d)") % (i, seen[node]), f) |
2e3ceb59c312
verify: use appropriate local variable in "checkentry()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17718
diff
changeset
|
138 seen[node] = i |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
139 return lr |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
140 |
9690
b33d70849a20
verify: report existence of journal
Sune Foldager <cryo@cyanite.org>
parents:
9657
diff
changeset
|
141 if os.path.exists(repo.sjoin("journal")): |
b33d70849a20
verify: report existence of journal
Sune Foldager <cryo@cyanite.org>
parents:
9657
diff
changeset
|
142 ui.warn(_("abandoned transaction found - run hg recover\n")) |
b33d70849a20
verify: report existence of journal
Sune Foldager <cryo@cyanite.org>
parents:
9657
diff
changeset
|
143 |
6751
7424a75f919a
verify: add some local variables
Matt Mackall <mpm@selenic.com>
parents:
6750
diff
changeset
|
144 revlogv1 = cl.version != revlog.REVLOGV0 |
7424a75f919a
verify: add some local variables
Matt Mackall <mpm@selenic.com>
parents:
6750
diff
changeset
|
145 if ui.verbose or not revlogv1: |
7424a75f919a
verify: add some local variables
Matt Mackall <mpm@selenic.com>
parents:
6750
diff
changeset
|
146 ui.status(_("repository uses revlog format %d\n") % |
2778 | 147 (revlogv1 and 1 or 0)) |
148 | |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
149 havecl = len(cl) > 0 |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
150 havemf = len(mf) > 0 |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
151 |
6751
7424a75f919a
verify: add some local variables
Matt Mackall <mpm@selenic.com>
parents:
6750
diff
changeset
|
152 ui.status(_("checking changesets\n")) |
17720
9a1796af4f8d
verify: rename "hasmanifest" variable for source code readability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17719
diff
changeset
|
153 refersmf = False |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
154 seen = {} |
8292
29540554def8
verify: reference the correct linkrev when a filelog is missing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8291
diff
changeset
|
155 checklog(cl, "changelog", 0) |
10433
767fbacb3ddc
verify: call ui.progress()
Augie Fackler <durin42@gmail.com>
parents:
10282
diff
changeset
|
156 total = len(repo) |
6750
fb42030d79d6
add __len__ and __iter__ methods to repo and revlog
Matt Mackall <mpm@selenic.com>
parents:
6534
diff
changeset
|
157 for i in repo: |
12745
5a1912b5aa42
verify/progress: using gerund to indicate action and adding units
timeless <timeless@gmail.com>
parents:
12170
diff
changeset
|
158 ui.progress(_('checking'), i, total=total, unit=_('changesets')) |
6751
7424a75f919a
verify: add some local variables
Matt Mackall <mpm@selenic.com>
parents:
6750
diff
changeset
|
159 n = cl.node(i) |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
160 checkentry(cl, i, n, seen, [i], "changelog") |
2778 | 161 |
162 try: | |
6751
7424a75f919a
verify: add some local variables
Matt Mackall <mpm@selenic.com>
parents:
6750
diff
changeset
|
163 changes = cl.read(n) |
17385
b32a30da608d
verify: do not choke on valid changelog without manifest
Patrick Mezard <patrick@mezard.eu>
parents:
16689
diff
changeset
|
164 if changes[0] != nullid: |
b32a30da608d
verify: do not choke on valid changelog without manifest
Patrick Mezard <patrick@mezard.eu>
parents:
16689
diff
changeset
|
165 mflinkrevs.setdefault(changes[0], []).append(i) |
17720
9a1796af4f8d
verify: rename "hasmanifest" variable for source code readability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17719
diff
changeset
|
166 refersmf = True |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
167 for f in changes[3]: |
26900
d1c741644d25
verify: add a hook that can let extensions manipulate file lists
Augie Fackler <augie@google.com>
parents:
26587
diff
changeset
|
168 if _validpath(repo, f): |
d1c741644d25
verify: add a hook that can let extensions manipulate file lists
Augie Fackler <augie@google.com>
parents:
26587
diff
changeset
|
169 filelinkrevs.setdefault(_normpath(f), []).append(i) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25653
diff
changeset
|
170 except Exception as inst: |
17720
9a1796af4f8d
verify: rename "hasmanifest" variable for source code readability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17719
diff
changeset
|
171 refersmf = True |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
172 exc(i, _("unpacking changeset %s") % short(n), inst) |
12745
5a1912b5aa42
verify/progress: using gerund to indicate action and adding units
timeless <timeless@gmail.com>
parents:
12170
diff
changeset
|
173 ui.progress(_('checking'), None) |
2778 | 174 |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
175 ui.status(_("checking manifests\n")) |
2778 | 176 seen = {} |
17720
9a1796af4f8d
verify: rename "hasmanifest" variable for source code readability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17719
diff
changeset
|
177 if refersmf: |
17385
b32a30da608d
verify: do not choke on valid changelog without manifest
Patrick Mezard <patrick@mezard.eu>
parents:
16689
diff
changeset
|
178 # Do not check manifest if there are only changelog entries with |
b32a30da608d
verify: do not choke on valid changelog without manifest
Patrick Mezard <patrick@mezard.eu>
parents:
16689
diff
changeset
|
179 # null manifests. |
b32a30da608d
verify: do not choke on valid changelog without manifest
Patrick Mezard <patrick@mezard.eu>
parents:
16689
diff
changeset
|
180 checklog(mf, "manifest", 0) |
10433
767fbacb3ddc
verify: call ui.progress()
Augie Fackler <durin42@gmail.com>
parents:
10282
diff
changeset
|
181 total = len(mf) |
6751
7424a75f919a
verify: add some local variables
Matt Mackall <mpm@selenic.com>
parents:
6750
diff
changeset
|
182 for i in mf: |
12745
5a1912b5aa42
verify/progress: using gerund to indicate action and adding units
timeless <timeless@gmail.com>
parents:
12170
diff
changeset
|
183 ui.progress(_('checking'), i, total=total, unit=_('manifests')) |
6751
7424a75f919a
verify: add some local variables
Matt Mackall <mpm@selenic.com>
parents:
6750
diff
changeset
|
184 n = mf.node(i) |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
185 lr = checkentry(mf, i, n, seen, mflinkrevs.get(n, []), "manifest") |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
186 if n in mflinkrevs: |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
187 del mflinkrevs[n] |
8394
850b5a7c210d
verify: detect manifest revs not in any changeset
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
8292
diff
changeset
|
188 else: |
850b5a7c210d
verify: detect manifest revs not in any changeset
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
8292
diff
changeset
|
189 err(lr, _("%s not in changesets") % short(n), "manifest") |
2778 | 190 |
191 try: | |
6751
7424a75f919a
verify: add some local variables
Matt Mackall <mpm@selenic.com>
parents:
6750
diff
changeset
|
192 for f, fn in mf.readdelta(n).iteritems(): |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
193 if not f: |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
194 err(lr, _("file without name in manifest")) |
24481
dded1eeeff64
verify: add a note about a paleo-bug
Matt Mackall <mpm@selenic.com>
parents:
22933
diff
changeset
|
195 elif f != "/dev/null": # ignore this in very old repos |
26900
d1c741644d25
verify: add a hook that can let extensions manipulate file lists
Augie Fackler <augie@google.com>
parents:
26587
diff
changeset
|
196 if _validpath(repo, f): |
d1c741644d25
verify: add a hook that can let extensions manipulate file lists
Augie Fackler <augie@google.com>
parents:
26587
diff
changeset
|
197 filenodes.setdefault( |
d1c741644d25
verify: add a hook that can let extensions manipulate file lists
Augie Fackler <augie@google.com>
parents:
26587
diff
changeset
|
198 _normpath(f), {}).setdefault(fn, lr) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25653
diff
changeset
|
199 except Exception as inst: |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
200 exc(lr, _("reading manifest delta %s") % short(n), inst) |
12745
5a1912b5aa42
verify/progress: using gerund to indicate action and adding units
timeless <timeless@gmail.com>
parents:
12170
diff
changeset
|
201 ui.progress(_('checking'), None) |
2778 | 202 |
6751
7424a75f919a
verify: add some local variables
Matt Mackall <mpm@selenic.com>
parents:
6750
diff
changeset
|
203 ui.status(_("crosschecking files in changesets and manifests\n")) |
2778 | 204 |
10433
767fbacb3ddc
verify: call ui.progress()
Augie Fackler <durin42@gmail.com>
parents:
10282
diff
changeset
|
205 total = len(mflinkrevs) + len(filelinkrevs) + len(filenodes) |
767fbacb3ddc
verify: call ui.progress()
Augie Fackler <durin42@gmail.com>
parents:
10282
diff
changeset
|
206 count = 0 |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
207 if havemf: |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
208 for c, m in sorted([(c, m) for m in mflinkrevs |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
209 for c in mflinkrevs[m]]): |
10433
767fbacb3ddc
verify: call ui.progress()
Augie Fackler <durin42@gmail.com>
parents:
10282
diff
changeset
|
210 count += 1 |
14865
eb914541a950
verify: filter messages about missing null manifests (issue2900)
Matt Mackall <mpm@selenic.com>
parents:
13031
diff
changeset
|
211 if m == nullid: |
eb914541a950
verify: filter messages about missing null manifests (issue2900)
Matt Mackall <mpm@selenic.com>
parents:
13031
diff
changeset
|
212 continue |
10698
e930017f9e2a
progress: use a verb (+noun) in present participle
Martin Geisler <mg@lazybytes.net>
parents:
10496
diff
changeset
|
213 ui.progress(_('crosschecking'), count, total=total) |
5541
ceaa752fa316
verify: improve handling of empty or missing files
Matt Mackall <mpm@selenic.com>
parents:
5313
diff
changeset
|
214 err(c, _("changeset refers to unknown manifest %s") % short(m)) |
9033
98a5652bfed9
verify: fix scope issues with del statement
Alejandro Santos <alejolp@alejolp.com>
parents:
8993
diff
changeset
|
215 mflinkrevs = None # del is bad here due to scope issues |
2778 | 216 |
8209
a1a5a57efe90
replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents:
8164
diff
changeset
|
217 for f in sorted(filelinkrevs): |
10433
767fbacb3ddc
verify: call ui.progress()
Augie Fackler <durin42@gmail.com>
parents:
10282
diff
changeset
|
218 count += 1 |
10698
e930017f9e2a
progress: use a verb (+noun) in present participle
Martin Geisler <mg@lazybytes.net>
parents:
10496
diff
changeset
|
219 ui.progress(_('crosschecking'), count, total=total) |
5541
ceaa752fa316
verify: improve handling of empty or missing files
Matt Mackall <mpm@selenic.com>
parents:
5313
diff
changeset
|
220 if f not in filenodes: |
ceaa752fa316
verify: improve handling of empty or missing files
Matt Mackall <mpm@selenic.com>
parents:
5313
diff
changeset
|
221 lr = filelinkrevs[f][0] |
ceaa752fa316
verify: improve handling of empty or missing files
Matt Mackall <mpm@selenic.com>
parents:
5313
diff
changeset
|
222 err(lr, _("in changeset but not in manifest"), f) |
2778 | 223 |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
224 if havecl: |
8209
a1a5a57efe90
replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents:
8164
diff
changeset
|
225 for f in sorted(filenodes): |
10433
767fbacb3ddc
verify: call ui.progress()
Augie Fackler <durin42@gmail.com>
parents:
10282
diff
changeset
|
226 count += 1 |
10698
e930017f9e2a
progress: use a verb (+noun) in present participle
Martin Geisler <mg@lazybytes.net>
parents:
10496
diff
changeset
|
227 ui.progress(_('crosschecking'), count, total=total) |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
228 if f not in filelinkrevs: |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
229 try: |
7361
9fe97eea5510
linkrev: take a revision number rather than a hash
Matt Mackall <mpm@selenic.com>
parents:
7141
diff
changeset
|
230 fl = repo.file(f) |
9fe97eea5510
linkrev: take a revision number rather than a hash
Matt Mackall <mpm@selenic.com>
parents:
7141
diff
changeset
|
231 lr = min([fl.linkrev(fl.rev(n)) for n in filenodes[f]]) |
16689
f366d4c2ff34
cleanup: replace naked excepts with except Exception: ...
Brodie Rao <brodie@sf.io>
parents:
14879
diff
changeset
|
232 except Exception: |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
233 lr = None |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
234 err(lr, _("in manifest but not in changeset"), f) |
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
235 |
10698
e930017f9e2a
progress: use a verb (+noun) in present participle
Martin Geisler <mg@lazybytes.net>
parents:
10496
diff
changeset
|
236 ui.progress(_('crosschecking'), None) |
10433
767fbacb3ddc
verify: call ui.progress()
Augie Fackler <durin42@gmail.com>
parents:
10282
diff
changeset
|
237 |
6751
7424a75f919a
verify: add some local variables
Matt Mackall <mpm@selenic.com>
parents:
6750
diff
changeset
|
238 ui.status(_("checking files\n")) |
6892
dab95717058d
verify: check repo.store
Adrian Buehlmann <adrian@cadifra.com>
parents:
6889
diff
changeset
|
239 |
8466
afb3e504b558
verify: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8394
diff
changeset
|
240 storefiles = set() |
6900
def492d1b592
store: change handling of decoding errors
Matt Mackall <mpm@selenic.com>
parents:
6892
diff
changeset
|
241 for f, f2, size in repo.store.datafiles(): |
def492d1b592
store: change handling of decoding errors
Matt Mackall <mpm@selenic.com>
parents:
6892
diff
changeset
|
242 if not f: |
def492d1b592
store: change handling of decoding errors
Matt Mackall <mpm@selenic.com>
parents:
6892
diff
changeset
|
243 err(None, _("cannot decode filename '%s'") % f2) |
12170
581066a319e5
verify: fix "missing revlog!" errors for revlog format v0 and add test
Thomas Arendsen Hein <thomas@intevation.de>
parents:
11756
diff
changeset
|
244 elif size > 0 or not revlogv1: |
17860
a45b33f12627
verify: fix all doubled-slash sites (issue3665)
Bryan O'Sullivan <bryano@fb.com>
parents:
17851
diff
changeset
|
245 storefiles.add(_normpath(f)) |
6892
dab95717058d
verify: check repo.store
Adrian Buehlmann <adrian@cadifra.com>
parents:
6889
diff
changeset
|
246 |
25653
9d1e04f5dca7
verify: print hint to run debugrebuildfncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25627
diff
changeset
|
247 fncachewarned = False |
8209
a1a5a57efe90
replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents:
8164
diff
changeset
|
248 files = sorted(set(filenodes) | set(filelinkrevs)) |
10433
767fbacb3ddc
verify: call ui.progress()
Augie Fackler <durin42@gmail.com>
parents:
10282
diff
changeset
|
249 total = len(files) |
767fbacb3ddc
verify: call ui.progress()
Augie Fackler <durin42@gmail.com>
parents:
10282
diff
changeset
|
250 for i, f in enumerate(files): |
10698
e930017f9e2a
progress: use a verb (+noun) in present participle
Martin Geisler <mg@lazybytes.net>
parents:
10496
diff
changeset
|
251 ui.progress(_('checking'), i, item=f, total=total) |
8291
f5c1a9094e41
verify: avoid exception on missing file revlog
Henrik Stuart <hg@hstuart.dk>
parents:
8225
diff
changeset
|
252 try: |
f5c1a9094e41
verify: avoid exception on missing file revlog
Henrik Stuart <hg@hstuart.dk>
parents:
8225
diff
changeset
|
253 linkrevs = filelinkrevs[f] |
f5c1a9094e41
verify: avoid exception on missing file revlog
Henrik Stuart <hg@hstuart.dk>
parents:
8225
diff
changeset
|
254 except KeyError: |
f5c1a9094e41
verify: avoid exception on missing file revlog
Henrik Stuart <hg@hstuart.dk>
parents:
8225
diff
changeset
|
255 # in manifest but not in changelog |
f5c1a9094e41
verify: avoid exception on missing file revlog
Henrik Stuart <hg@hstuart.dk>
parents:
8225
diff
changeset
|
256 linkrevs = [] |
f5c1a9094e41
verify: avoid exception on missing file revlog
Henrik Stuart <hg@hstuart.dk>
parents:
8225
diff
changeset
|
257 |
f5c1a9094e41
verify: avoid exception on missing file revlog
Henrik Stuart <hg@hstuart.dk>
parents:
8225
diff
changeset
|
258 if linkrevs: |
f5c1a9094e41
verify: avoid exception on missing file revlog
Henrik Stuart <hg@hstuart.dk>
parents:
8225
diff
changeset
|
259 lr = linkrevs[0] |
f5c1a9094e41
verify: avoid exception on missing file revlog
Henrik Stuart <hg@hstuart.dk>
parents:
8225
diff
changeset
|
260 else: |
f5c1a9094e41
verify: avoid exception on missing file revlog
Henrik Stuart <hg@hstuart.dk>
parents:
8225
diff
changeset
|
261 lr = None |
f5c1a9094e41
verify: avoid exception on missing file revlog
Henrik Stuart <hg@hstuart.dk>
parents:
8225
diff
changeset
|
262 |
7832
1fce19b9b011
verify: do not abort on fully corrupted revlog
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7676
diff
changeset
|
263 try: |
1fce19b9b011
verify: do not abort on fully corrupted revlog
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7676
diff
changeset
|
264 fl = repo.file(f) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25653
diff
changeset
|
265 except error.RevlogError as e: |
7833
794def2fe232
verify: find correct first corrupted cset for missing/corrupted revlogs
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7832
diff
changeset
|
266 err(lr, _("broken revlog! (%s)") % e, f) |
7832
1fce19b9b011
verify: do not abort on fully corrupted revlog
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7676
diff
changeset
|
267 continue |
6892
dab95717058d
verify: check repo.store
Adrian Buehlmann <adrian@cadifra.com>
parents:
6889
diff
changeset
|
268 |
6900
def492d1b592
store: change handling of decoding errors
Matt Mackall <mpm@selenic.com>
parents:
6892
diff
changeset
|
269 for ff in fl.files(): |
6892
dab95717058d
verify: check repo.store
Adrian Buehlmann <adrian@cadifra.com>
parents:
6889
diff
changeset
|
270 try: |
8466
afb3e504b558
verify: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8394
diff
changeset
|
271 storefiles.remove(ff) |
6892
dab95717058d
verify: check repo.store
Adrian Buehlmann <adrian@cadifra.com>
parents:
6889
diff
changeset
|
272 except KeyError: |
25627
9573d8f346f1
verify: clarify misleading fncache message
Matt Mackall <mpm@selenic.com>
parents:
24481
diff
changeset
|
273 warn(_(" warning: revlog '%s' not in fncache!") % ff) |
25653
9d1e04f5dca7
verify: print hint to run debugrebuildfncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25627
diff
changeset
|
274 fncachewarned = True |
6892
dab95717058d
verify: check repo.store
Adrian Buehlmann <adrian@cadifra.com>
parents:
6889
diff
changeset
|
275 |
8292
29540554def8
verify: reference the correct linkrev when a filelog is missing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8291
diff
changeset
|
276 checklog(fl, f, lr) |
5313
29be4228303b
verify: report first bad changeset
Matt Mackall <mpm@selenic.com>
parents:
5179
diff
changeset
|
277 seen = {} |
11756
0299240b849b
verify: initialize rp variable in case we hit out of memory
Matt Mackall <mpm@selenic.com>
parents:
11753
diff
changeset
|
278 rp = None |
6750
fb42030d79d6
add __len__ and __iter__ methods to repo and revlog
Matt Mackall <mpm@selenic.com>
parents:
6534
diff
changeset
|
279 for i in fl: |
2778 | 280 revisions += 1 |
281 n = fl.node(i) | |
8291
f5c1a9094e41
verify: avoid exception on missing file revlog
Henrik Stuart <hg@hstuart.dk>
parents:
8225
diff
changeset
|
282 lr = checkentry(fl, i, n, seen, linkrevs, f) |
5541
ceaa752fa316
verify: improve handling of empty or missing files
Matt Mackall <mpm@selenic.com>
parents:
5313
diff
changeset
|
283 if f in filenodes: |
ceaa752fa316
verify: improve handling of empty or missing files
Matt Mackall <mpm@selenic.com>
parents:
5313
diff
changeset
|
284 if havemf and n not in filenodes[f]: |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
285 err(lr, _("%s not in manifests") % (short(n)), f) |
5541
ceaa752fa316
verify: improve handling of empty or missing files
Matt Mackall <mpm@selenic.com>
parents:
5313
diff
changeset
|
286 else: |
ceaa752fa316
verify: improve handling of empty or missing files
Matt Mackall <mpm@selenic.com>
parents:
5313
diff
changeset
|
287 del filenodes[f][n] |
2778 | 288 |
289 # verify contents | |
290 try: | |
11753
eb7b04657dae
verify: reduce memory footprint when unpacking files
Matt Mackall <mpm@selenic.com>
parents:
11752
diff
changeset
|
291 l = len(fl.read(n)) |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
292 rp = fl.renamed(n) |
11753
eb7b04657dae
verify: reduce memory footprint when unpacking files
Matt Mackall <mpm@selenic.com>
parents:
11752
diff
changeset
|
293 if l != fl.size(i): |
7675
011e69b96c69
verify: don't trip over binary files starting with 01 0a
Matt Mackall <mpm@selenic.com>
parents:
7361
diff
changeset
|
294 if len(fl.revision(n)) != fl.size(i): |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
295 err(lr, _("unpacked size is %s, %s expected") % |
11753
eb7b04657dae
verify: reduce memory footprint when unpacking files
Matt Mackall <mpm@selenic.com>
parents:
11752
diff
changeset
|
296 (l, fl.size(i)), f) |
22933
3a60cd44e619
verify: report censored nodes if configured policy is abort
Mike Edgar <adgar@google.com>
parents:
20530
diff
changeset
|
297 except error.CensoredNodeError: |
25846
c55eac3f388d
censor: mark experimental option
Matt Mackall <mpm@selenic.com>
parents:
25660
diff
changeset
|
298 # experimental config: censor.policy |
22933
3a60cd44e619
verify: report censored nodes if configured policy is abort
Mike Edgar <adgar@google.com>
parents:
20530
diff
changeset
|
299 if ui.config("censor", "policy", "abort") == "abort": |
3a60cd44e619
verify: report censored nodes if configured policy is abort
Mike Edgar <adgar@google.com>
parents:
20530
diff
changeset
|
300 err(lr, _("censored file data"), f) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25653
diff
changeset
|
301 except Exception as inst: |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
302 exc(lr, _("unpacking %s") % short(n), inst, f) |
2778 | 303 |
3744
d626fc9e3985
verify: add rename link checking
Matt Mackall <mpm@selenic.com>
parents:
3473
diff
changeset
|
304 # check renames |
d626fc9e3985
verify: add rename link checking
Matt Mackall <mpm@selenic.com>
parents:
3473
diff
changeset
|
305 try: |
d626fc9e3985
verify: add rename link checking
Matt Mackall <mpm@selenic.com>
parents:
3473
diff
changeset
|
306 if rp: |
9545
98feea5659d9
verify: detect file copy sources not in parents with --verbose
Patrick Mezard <pmezard@gmail.com>
parents:
9198
diff
changeset
|
307 if lr is not None and ui.verbose: |
98feea5659d9
verify: detect file copy sources not in parents with --verbose
Patrick Mezard <pmezard@gmail.com>
parents:
9198
diff
changeset
|
308 ctx = lrugetctx(lr) |
98feea5659d9
verify: detect file copy sources not in parents with --verbose
Patrick Mezard <pmezard@gmail.com>
parents:
9198
diff
changeset
|
309 found = False |
98feea5659d9
verify: detect file copy sources not in parents with --verbose
Patrick Mezard <pmezard@gmail.com>
parents:
9198
diff
changeset
|
310 for pctx in ctx.parents(): |
98feea5659d9
verify: detect file copy sources not in parents with --verbose
Patrick Mezard <pmezard@gmail.com>
parents:
9198
diff
changeset
|
311 if rp[0] in pctx: |
98feea5659d9
verify: detect file copy sources not in parents with --verbose
Patrick Mezard <pmezard@gmail.com>
parents:
9198
diff
changeset
|
312 found = True |
98feea5659d9
verify: detect file copy sources not in parents with --verbose
Patrick Mezard <pmezard@gmail.com>
parents:
9198
diff
changeset
|
313 break |
98feea5659d9
verify: detect file copy sources not in parents with --verbose
Patrick Mezard <pmezard@gmail.com>
parents:
9198
diff
changeset
|
314 if not found: |
98feea5659d9
verify: detect file copy sources not in parents with --verbose
Patrick Mezard <pmezard@gmail.com>
parents:
9198
diff
changeset
|
315 warn(_("warning: copy source of '%s' not" |
98feea5659d9
verify: detect file copy sources not in parents with --verbose
Patrick Mezard <pmezard@gmail.com>
parents:
9198
diff
changeset
|
316 " in parents of %s") % (f, ctx)) |
3744
d626fc9e3985
verify: add rename link checking
Matt Mackall <mpm@selenic.com>
parents:
3473
diff
changeset
|
317 fl2 = repo.file(rp[0]) |
6750
fb42030d79d6
add __len__ and __iter__ methods to repo and revlog
Matt Mackall <mpm@selenic.com>
parents:
6534
diff
changeset
|
318 if not len(fl2): |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
319 err(lr, _("empty or missing copy source revlog %s:%s") |
6534
9b35a9f34675
verify: check copy source revlog and nodeid
Patrick Mezard <pmezard@gmail.com>
parents:
6211
diff
changeset
|
320 % (rp[0], short(rp[1])), f) |
9b35a9f34675
verify: check copy source revlog and nodeid
Patrick Mezard <pmezard@gmail.com>
parents:
6211
diff
changeset
|
321 elif rp[1] == nullid: |
8993
46441934c585
verify: demote warning about nullid in copy to note
Matt Mackall <mpm@selenic.com>
parents:
8466
diff
changeset
|
322 ui.note(_("warning: %s@%s: copy source" |
46441934c585
verify: demote warning about nullid in copy to note
Matt Mackall <mpm@selenic.com>
parents:
8466
diff
changeset
|
323 " revision is nullid %s:%s\n") |
7004
90227c42b5f6
c0bd7d8b69ef uses err() instead of warn() but prototype doesn't match
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6900
diff
changeset
|
324 % (f, lr, rp[0], short(rp[1]))) |
6534
9b35a9f34675
verify: check copy source revlog and nodeid
Patrick Mezard <pmezard@gmail.com>
parents:
6211
diff
changeset
|
325 else: |
7874
d812029cda85
cleanup: drop variables for unused return values
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7833
diff
changeset
|
326 fl2.rev(rp[1]) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25653
diff
changeset
|
327 except Exception as inst: |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
328 exc(lr, _("checking rename of %s") % short(n), inst, f) |
3744
d626fc9e3985
verify: add rename link checking
Matt Mackall <mpm@selenic.com>
parents:
3473
diff
changeset
|
329 |
2778 | 330 # cross-check |
5541
ceaa752fa316
verify: improve handling of empty or missing files
Matt Mackall <mpm@selenic.com>
parents:
5313
diff
changeset
|
331 if f in filenodes: |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
332 fns = [(lr, n) for n, lr in filenodes[f].iteritems()] |
8209
a1a5a57efe90
replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents:
8164
diff
changeset
|
333 for lr, node in sorted(fns): |
5541
ceaa752fa316
verify: improve handling of empty or missing files
Matt Mackall <mpm@selenic.com>
parents:
5313
diff
changeset
|
334 err(lr, _("%s in manifests not found") % short(node), f) |
10698
e930017f9e2a
progress: use a verb (+noun) in present participle
Martin Geisler <mg@lazybytes.net>
parents:
10496
diff
changeset
|
335 ui.progress(_('checking'), None) |
2778 | 336 |
6892
dab95717058d
verify: check repo.store
Adrian Buehlmann <adrian@cadifra.com>
parents:
6889
diff
changeset
|
337 for f in storefiles: |
dab95717058d
verify: check repo.store
Adrian Buehlmann <adrian@cadifra.com>
parents:
6889
diff
changeset
|
338 warn(_("warning: orphan revlog '%s'") % f) |
dab95717058d
verify: check repo.store
Adrian Buehlmann <adrian@cadifra.com>
parents:
6889
diff
changeset
|
339 |
6751
7424a75f919a
verify: add some local variables
Matt Mackall <mpm@selenic.com>
parents:
6750
diff
changeset
|
340 ui.status(_("%d files, %d changesets, %d total revisions\n") % |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
341 (len(files), len(cl), revisions)) |
2778 | 342 if warnings[0]: |
6751
7424a75f919a
verify: add some local variables
Matt Mackall <mpm@selenic.com>
parents:
6750
diff
changeset
|
343 ui.warn(_("%d warnings encountered!\n") % warnings[0]) |
25653
9d1e04f5dca7
verify: print hint to run debugrebuildfncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25627
diff
changeset
|
344 if fncachewarned: |
9d1e04f5dca7
verify: print hint to run debugrebuildfncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25627
diff
changeset
|
345 ui.warn(_('hint: run "hg debugrebuildfncache" to recover from ' |
9d1e04f5dca7
verify: print hint to run debugrebuildfncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25627
diff
changeset
|
346 'corrupt fncache\n')) |
2778 | 347 if errors[0]: |
6751
7424a75f919a
verify: add some local variables
Matt Mackall <mpm@selenic.com>
parents:
6750
diff
changeset
|
348 ui.warn(_("%d integrity errors encountered!\n") % errors[0]) |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
349 if badrevs: |
6751
7424a75f919a
verify: add some local variables
Matt Mackall <mpm@selenic.com>
parents:
6750
diff
changeset
|
350 ui.warn(_("(first damaged changeset appears to be %d)\n") |
6752
e79a8f36c2a5
verify: lots of refactoring
Matt Mackall <mpm@selenic.com>
parents:
6751
diff
changeset
|
351 % min(badrevs)) |
2778 | 352 return 1 |