Show More
@@ -0,0 +1,60 b'' | |||||
|
1 | #!/usr/bin/env python | |||
|
2 | # Copyright 2010 Intevation GmbH | |||
|
3 | # Author(s): | |||
|
4 | # Thomas Arendsen Hein <thomas@intevation.de> | |||
|
5 | # | |||
|
6 | # This software may be used and distributed according to the terms of the | |||
|
7 | # GNU General Public License version 2 or any later version. | |||
|
8 | ||||
|
9 | """Create a Mercurial repository in revlog format 0 | |||
|
10 | ||||
|
11 | changeset: 0:a1ef0b125355 | |||
|
12 | tag: tip | |||
|
13 | user: user | |||
|
14 | date: Thu Jan 01 00:00:00 1970 +0000 | |||
|
15 | files: empty | |||
|
16 | description: | |||
|
17 | empty file | |||
|
18 | """ | |||
|
19 | ||||
|
20 | import os, sys | |||
|
21 | ||||
|
22 | files = [ | |||
|
23 | ('formatv0/.hg/00changelog.i', | |||
|
24 | '000000000000004400000000000000000000000000000000000000' | |||
|
25 | '000000000000000000000000000000000000000000000000000000' | |||
|
26 | '0000a1ef0b125355d27765928be600cfe85784284ab3'), | |||
|
27 | ('formatv0/.hg/00changelog.d', | |||
|
28 | '756163613935613961356635353036303562366138343738336237' | |||
|
29 | '61623536363738616436356635380a757365720a3020300a656d70' | |||
|
30 | '74790a0a656d7074792066696c65'), | |||
|
31 | ('formatv0/.hg/00manifest.i', | |||
|
32 | '000000000000003000000000000000000000000000000000000000' | |||
|
33 | '000000000000000000000000000000000000000000000000000000' | |||
|
34 | '0000aca95a9a5f550605b6a84783b7ab56678ad65f58'), | |||
|
35 | ('formatv0/.hg/00manifest.d', | |||
|
36 | '75656d707479006238306465356431333837353835343163356630' | |||
|
37 | '35323635616431343461623966613836643164620a'), | |||
|
38 | ('formatv0/.hg/data/empty.i', | |||
|
39 | '000000000000000000000000000000000000000000000000000000' | |||
|
40 | '000000000000000000000000000000000000000000000000000000' | |||
|
41 | '0000b80de5d138758541c5f05265ad144ab9fa86d1db'), | |||
|
42 | ('formatv0/.hg/data/empty.d', | |||
|
43 | ''), | |||
|
44 | ] | |||
|
45 | ||||
|
46 | def makedirs(name): | |||
|
47 | """recursive directory creation""" | |||
|
48 | parent = os.path.dirname(name) | |||
|
49 | if parent: | |||
|
50 | makedirs(parent) | |||
|
51 | os.mkdir(name) | |||
|
52 | ||||
|
53 | makedirs(os.path.join(*'formatv0/.hg/data'.split('/'))) | |||
|
54 | ||||
|
55 | for name, data in files: | |||
|
56 | f = open(name, 'wb') | |||
|
57 | f.write(data.decode('hex')) | |||
|
58 | f.close() | |||
|
59 | ||||
|
60 | sys.exit(0) |
@@ -1,301 +1,301 b'' | |||||
1 | # verify.py - repository integrity checking for Mercurial |
|
1 | # verify.py - repository integrity checking for Mercurial | |
2 | # |
|
2 | # | |
3 | # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com> |
|
3 | # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com> | |
4 | # |
|
4 | # | |
5 | # This software may be used and distributed according to the terms of the |
|
5 | # This software may be used and distributed according to the terms of the | |
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | from node import nullid, short |
|
8 | from node import nullid, short | |
9 | from i18n import _ |
|
9 | from i18n import _ | |
10 | import os |
|
10 | import os | |
11 | import revlog, util, error |
|
11 | import revlog, util, error | |
12 |
|
12 | |||
13 | def verify(repo): |
|
13 | def verify(repo): | |
14 | lock = repo.lock() |
|
14 | lock = repo.lock() | |
15 | try: |
|
15 | try: | |
16 | return _verify(repo) |
|
16 | return _verify(repo) | |
17 | finally: |
|
17 | finally: | |
18 | lock.release() |
|
18 | lock.release() | |
19 |
|
19 | |||
20 | def _verify(repo): |
|
20 | def _verify(repo): | |
21 | mflinkrevs = {} |
|
21 | mflinkrevs = {} | |
22 | filelinkrevs = {} |
|
22 | filelinkrevs = {} | |
23 | filenodes = {} |
|
23 | filenodes = {} | |
24 | revisions = 0 |
|
24 | revisions = 0 | |
25 | badrevs = set() |
|
25 | badrevs = set() | |
26 | errors = [0] |
|
26 | errors = [0] | |
27 | warnings = [0] |
|
27 | warnings = [0] | |
28 | ui = repo.ui |
|
28 | ui = repo.ui | |
29 | cl = repo.changelog |
|
29 | cl = repo.changelog | |
30 | mf = repo.manifest |
|
30 | mf = repo.manifest | |
31 | lrugetctx = util.lrucachefunc(repo.changectx) |
|
31 | lrugetctx = util.lrucachefunc(repo.changectx) | |
32 |
|
32 | |||
33 | if not repo.cancopy(): |
|
33 | if not repo.cancopy(): | |
34 | raise util.Abort(_("cannot verify bundle or remote repos")) |
|
34 | raise util.Abort(_("cannot verify bundle or remote repos")) | |
35 |
|
35 | |||
36 | def err(linkrev, msg, filename=None): |
|
36 | def err(linkrev, msg, filename=None): | |
37 | if linkrev != None: |
|
37 | if linkrev != None: | |
38 | badrevs.add(linkrev) |
|
38 | badrevs.add(linkrev) | |
39 | else: |
|
39 | else: | |
40 | linkrev = '?' |
|
40 | linkrev = '?' | |
41 | msg = "%s: %s" % (linkrev, msg) |
|
41 | msg = "%s: %s" % (linkrev, msg) | |
42 | if filename: |
|
42 | if filename: | |
43 | msg = "%s@%s" % (filename, msg) |
|
43 | msg = "%s@%s" % (filename, msg) | |
44 | ui.warn(" " + msg + "\n") |
|
44 | ui.warn(" " + msg + "\n") | |
45 | errors[0] += 1 |
|
45 | errors[0] += 1 | |
46 |
|
46 | |||
47 | def exc(linkrev, msg, inst, filename=None): |
|
47 | def exc(linkrev, msg, inst, filename=None): | |
48 | if isinstance(inst, KeyboardInterrupt): |
|
48 | if isinstance(inst, KeyboardInterrupt): | |
49 | ui.warn(_("interrupted")) |
|
49 | ui.warn(_("interrupted")) | |
50 | raise |
|
50 | raise | |
51 | if not str(inst): |
|
51 | if not str(inst): | |
52 | inst = repr(inst) |
|
52 | inst = repr(inst) | |
53 | err(linkrev, "%s: %s" % (msg, inst), filename) |
|
53 | err(linkrev, "%s: %s" % (msg, inst), filename) | |
54 |
|
54 | |||
55 | def warn(msg): |
|
55 | def warn(msg): | |
56 | ui.warn(msg + "\n") |
|
56 | ui.warn(msg + "\n") | |
57 | warnings[0] += 1 |
|
57 | warnings[0] += 1 | |
58 |
|
58 | |||
59 | def checklog(obj, name, linkrev): |
|
59 | def checklog(obj, name, linkrev): | |
60 | if not len(obj) and (havecl or havemf): |
|
60 | if not len(obj) and (havecl or havemf): | |
61 | err(linkrev, _("empty or missing %s") % name) |
|
61 | err(linkrev, _("empty or missing %s") % name) | |
62 | return |
|
62 | return | |
63 |
|
63 | |||
64 | d = obj.checksize() |
|
64 | d = obj.checksize() | |
65 | if d[0]: |
|
65 | if d[0]: | |
66 | err(None, _("data length off by %d bytes") % d[0], name) |
|
66 | err(None, _("data length off by %d bytes") % d[0], name) | |
67 | if d[1]: |
|
67 | if d[1]: | |
68 | err(None, _("index contains %d extra bytes") % d[1], name) |
|
68 | err(None, _("index contains %d extra bytes") % d[1], name) | |
69 |
|
69 | |||
70 | if obj.version != revlog.REVLOGV0: |
|
70 | if obj.version != revlog.REVLOGV0: | |
71 | if not revlogv1: |
|
71 | if not revlogv1: | |
72 | warn(_("warning: `%s' uses revlog format 1") % name) |
|
72 | warn(_("warning: `%s' uses revlog format 1") % name) | |
73 | elif revlogv1: |
|
73 | elif revlogv1: | |
74 | warn(_("warning: `%s' uses revlog format 0") % name) |
|
74 | warn(_("warning: `%s' uses revlog format 0") % name) | |
75 |
|
75 | |||
76 | def checkentry(obj, i, node, seen, linkrevs, f): |
|
76 | def checkentry(obj, i, node, seen, linkrevs, f): | |
77 | lr = obj.linkrev(obj.rev(node)) |
|
77 | lr = obj.linkrev(obj.rev(node)) | |
78 | if lr < 0 or (havecl and lr not in linkrevs): |
|
78 | if lr < 0 or (havecl and lr not in linkrevs): | |
79 | if lr < 0 or lr >= len(cl): |
|
79 | if lr < 0 or lr >= len(cl): | |
80 | msg = _("rev %d points to nonexistent changeset %d") |
|
80 | msg = _("rev %d points to nonexistent changeset %d") | |
81 | else: |
|
81 | else: | |
82 | msg = _("rev %d points to unexpected changeset %d") |
|
82 | msg = _("rev %d points to unexpected changeset %d") | |
83 | err(None, msg % (i, lr), f) |
|
83 | err(None, msg % (i, lr), f) | |
84 | if linkrevs: |
|
84 | if linkrevs: | |
85 | if f and len(linkrevs) > 1: |
|
85 | if f and len(linkrevs) > 1: | |
86 | try: |
|
86 | try: | |
87 | # attempt to filter down to real linkrevs |
|
87 | # attempt to filter down to real linkrevs | |
88 | linkrevs = [l for l in linkrevs |
|
88 | linkrevs = [l for l in linkrevs | |
89 | if lrugetctx(l)[f].filenode() == node] |
|
89 | if lrugetctx(l)[f].filenode() == node] | |
90 | except: |
|
90 | except: | |
91 | pass |
|
91 | pass | |
92 | warn(_(" (expected %s)") % " ".join(map(str, linkrevs))) |
|
92 | warn(_(" (expected %s)") % " ".join(map(str, linkrevs))) | |
93 | lr = None # can't be trusted |
|
93 | lr = None # can't be trusted | |
94 |
|
94 | |||
95 | try: |
|
95 | try: | |
96 | p1, p2 = obj.parents(node) |
|
96 | p1, p2 = obj.parents(node) | |
97 | if p1 not in seen and p1 != nullid: |
|
97 | if p1 not in seen and p1 != nullid: | |
98 | err(lr, _("unknown parent 1 %s of %s") % |
|
98 | err(lr, _("unknown parent 1 %s of %s") % | |
99 | (short(p1), short(n)), f) |
|
99 | (short(p1), short(n)), f) | |
100 | if p2 not in seen and p2 != nullid: |
|
100 | if p2 not in seen and p2 != nullid: | |
101 | err(lr, _("unknown parent 2 %s of %s") % |
|
101 | err(lr, _("unknown parent 2 %s of %s") % | |
102 | (short(p2), short(p1)), f) |
|
102 | (short(p2), short(p1)), f) | |
103 | except Exception, inst: |
|
103 | except Exception, inst: | |
104 | exc(lr, _("checking parents of %s") % short(node), inst, f) |
|
104 | exc(lr, _("checking parents of %s") % short(node), inst, f) | |
105 |
|
105 | |||
106 | if node in seen: |
|
106 | if node in seen: | |
107 | err(lr, _("duplicate revision %d (%d)") % (i, seen[n]), f) |
|
107 | err(lr, _("duplicate revision %d (%d)") % (i, seen[n]), f) | |
108 | seen[n] = i |
|
108 | seen[n] = i | |
109 | return lr |
|
109 | return lr | |
110 |
|
110 | |||
111 | if os.path.exists(repo.sjoin("journal")): |
|
111 | if os.path.exists(repo.sjoin("journal")): | |
112 | ui.warn(_("abandoned transaction found - run hg recover\n")) |
|
112 | ui.warn(_("abandoned transaction found - run hg recover\n")) | |
113 |
|
113 | |||
114 | revlogv1 = cl.version != revlog.REVLOGV0 |
|
114 | revlogv1 = cl.version != revlog.REVLOGV0 | |
115 | if ui.verbose or not revlogv1: |
|
115 | if ui.verbose or not revlogv1: | |
116 | ui.status(_("repository uses revlog format %d\n") % |
|
116 | ui.status(_("repository uses revlog format %d\n") % | |
117 | (revlogv1 and 1 or 0)) |
|
117 | (revlogv1 and 1 or 0)) | |
118 |
|
118 | |||
119 | havecl = len(cl) > 0 |
|
119 | havecl = len(cl) > 0 | |
120 | havemf = len(mf) > 0 |
|
120 | havemf = len(mf) > 0 | |
121 |
|
121 | |||
122 | ui.status(_("checking changesets\n")) |
|
122 | ui.status(_("checking changesets\n")) | |
123 | seen = {} |
|
123 | seen = {} | |
124 | checklog(cl, "changelog", 0) |
|
124 | checklog(cl, "changelog", 0) | |
125 | total = len(repo) |
|
125 | total = len(repo) | |
126 | for i in repo: |
|
126 | for i in repo: | |
127 | ui.progress(_('changesets'), i, total=total) |
|
127 | ui.progress(_('changesets'), i, total=total) | |
128 | n = cl.node(i) |
|
128 | n = cl.node(i) | |
129 | checkentry(cl, i, n, seen, [i], "changelog") |
|
129 | checkentry(cl, i, n, seen, [i], "changelog") | |
130 |
|
130 | |||
131 | try: |
|
131 | try: | |
132 | changes = cl.read(n) |
|
132 | changes = cl.read(n) | |
133 | mflinkrevs.setdefault(changes[0], []).append(i) |
|
133 | mflinkrevs.setdefault(changes[0], []).append(i) | |
134 | for f in changes[3]: |
|
134 | for f in changes[3]: | |
135 | filelinkrevs.setdefault(f, []).append(i) |
|
135 | filelinkrevs.setdefault(f, []).append(i) | |
136 | except Exception, inst: |
|
136 | except Exception, inst: | |
137 | exc(i, _("unpacking changeset %s") % short(n), inst) |
|
137 | exc(i, _("unpacking changeset %s") % short(n), inst) | |
138 | ui.progress(_('changesets'), None) |
|
138 | ui.progress(_('changesets'), None) | |
139 |
|
139 | |||
140 | ui.status(_("checking manifests\n")) |
|
140 | ui.status(_("checking manifests\n")) | |
141 | seen = {} |
|
141 | seen = {} | |
142 | checklog(mf, "manifest", 0) |
|
142 | checklog(mf, "manifest", 0) | |
143 | total = len(mf) |
|
143 | total = len(mf) | |
144 | for i in mf: |
|
144 | for i in mf: | |
145 | ui.progress(_('manifests'), i, total=total) |
|
145 | ui.progress(_('manifests'), i, total=total) | |
146 | n = mf.node(i) |
|
146 | n = mf.node(i) | |
147 | lr = checkentry(mf, i, n, seen, mflinkrevs.get(n, []), "manifest") |
|
147 | lr = checkentry(mf, i, n, seen, mflinkrevs.get(n, []), "manifest") | |
148 | if n in mflinkrevs: |
|
148 | if n in mflinkrevs: | |
149 | del mflinkrevs[n] |
|
149 | del mflinkrevs[n] | |
150 | else: |
|
150 | else: | |
151 | err(lr, _("%s not in changesets") % short(n), "manifest") |
|
151 | err(lr, _("%s not in changesets") % short(n), "manifest") | |
152 |
|
152 | |||
153 | try: |
|
153 | try: | |
154 | for f, fn in mf.readdelta(n).iteritems(): |
|
154 | for f, fn in mf.readdelta(n).iteritems(): | |
155 | if not f: |
|
155 | if not f: | |
156 | err(lr, _("file without name in manifest")) |
|
156 | err(lr, _("file without name in manifest")) | |
157 | elif f != "/dev/null": |
|
157 | elif f != "/dev/null": | |
158 | filenodes.setdefault(f, {}).setdefault(fn, lr) |
|
158 | filenodes.setdefault(f, {}).setdefault(fn, lr) | |
159 | except Exception, inst: |
|
159 | except Exception, inst: | |
160 | exc(lr, _("reading manifest delta %s") % short(n), inst) |
|
160 | exc(lr, _("reading manifest delta %s") % short(n), inst) | |
161 | ui.progress(_('manifests'), None) |
|
161 | ui.progress(_('manifests'), None) | |
162 |
|
162 | |||
163 | ui.status(_("crosschecking files in changesets and manifests\n")) |
|
163 | ui.status(_("crosschecking files in changesets and manifests\n")) | |
164 |
|
164 | |||
165 | total = len(mflinkrevs) + len(filelinkrevs) + len(filenodes) |
|
165 | total = len(mflinkrevs) + len(filelinkrevs) + len(filenodes) | |
166 | count = 0 |
|
166 | count = 0 | |
167 | if havemf: |
|
167 | if havemf: | |
168 | for c, m in sorted([(c, m) for m in mflinkrevs |
|
168 | for c, m in sorted([(c, m) for m in mflinkrevs | |
169 | for c in mflinkrevs[m]]): |
|
169 | for c in mflinkrevs[m]]): | |
170 | count += 1 |
|
170 | count += 1 | |
171 | ui.progress(_('crosschecking'), count, total=total) |
|
171 | ui.progress(_('crosschecking'), count, total=total) | |
172 | err(c, _("changeset refers to unknown manifest %s") % short(m)) |
|
172 | err(c, _("changeset refers to unknown manifest %s") % short(m)) | |
173 | mflinkrevs = None # del is bad here due to scope issues |
|
173 | mflinkrevs = None # del is bad here due to scope issues | |
174 |
|
174 | |||
175 | for f in sorted(filelinkrevs): |
|
175 | for f in sorted(filelinkrevs): | |
176 | count += 1 |
|
176 | count += 1 | |
177 | ui.progress(_('crosschecking'), count, total=total) |
|
177 | ui.progress(_('crosschecking'), count, total=total) | |
178 | if f not in filenodes: |
|
178 | if f not in filenodes: | |
179 | lr = filelinkrevs[f][0] |
|
179 | lr = filelinkrevs[f][0] | |
180 | err(lr, _("in changeset but not in manifest"), f) |
|
180 | err(lr, _("in changeset but not in manifest"), f) | |
181 |
|
181 | |||
182 | if havecl: |
|
182 | if havecl: | |
183 | for f in sorted(filenodes): |
|
183 | for f in sorted(filenodes): | |
184 | count += 1 |
|
184 | count += 1 | |
185 | ui.progress(_('crosschecking'), count, total=total) |
|
185 | ui.progress(_('crosschecking'), count, total=total) | |
186 | if f not in filelinkrevs: |
|
186 | if f not in filelinkrevs: | |
187 | try: |
|
187 | try: | |
188 | fl = repo.file(f) |
|
188 | fl = repo.file(f) | |
189 | lr = min([fl.linkrev(fl.rev(n)) for n in filenodes[f]]) |
|
189 | lr = min([fl.linkrev(fl.rev(n)) for n in filenodes[f]]) | |
190 | except: |
|
190 | except: | |
191 | lr = None |
|
191 | lr = None | |
192 | err(lr, _("in manifest but not in changeset"), f) |
|
192 | err(lr, _("in manifest but not in changeset"), f) | |
193 |
|
193 | |||
194 | ui.progress(_('crosschecking'), None) |
|
194 | ui.progress(_('crosschecking'), None) | |
195 |
|
195 | |||
196 | ui.status(_("checking files\n")) |
|
196 | ui.status(_("checking files\n")) | |
197 |
|
197 | |||
198 | storefiles = set() |
|
198 | storefiles = set() | |
199 | for f, f2, size in repo.store.datafiles(): |
|
199 | for f, f2, size in repo.store.datafiles(): | |
200 | if not f: |
|
200 | if not f: | |
201 | err(None, _("cannot decode filename '%s'") % f2) |
|
201 | err(None, _("cannot decode filename '%s'") % f2) | |
202 | elif size > 0: |
|
202 | elif size > 0 or not revlogv1: | |
203 | storefiles.add(f) |
|
203 | storefiles.add(f) | |
204 |
|
204 | |||
205 | files = sorted(set(filenodes) | set(filelinkrevs)) |
|
205 | files = sorted(set(filenodes) | set(filelinkrevs)) | |
206 | total = len(files) |
|
206 | total = len(files) | |
207 | for i, f in enumerate(files): |
|
207 | for i, f in enumerate(files): | |
208 | ui.progress(_('checking'), i, item=f, total=total) |
|
208 | ui.progress(_('checking'), i, item=f, total=total) | |
209 | try: |
|
209 | try: | |
210 | linkrevs = filelinkrevs[f] |
|
210 | linkrevs = filelinkrevs[f] | |
211 | except KeyError: |
|
211 | except KeyError: | |
212 | # in manifest but not in changelog |
|
212 | # in manifest but not in changelog | |
213 | linkrevs = [] |
|
213 | linkrevs = [] | |
214 |
|
214 | |||
215 | if linkrevs: |
|
215 | if linkrevs: | |
216 | lr = linkrevs[0] |
|
216 | lr = linkrevs[0] | |
217 | else: |
|
217 | else: | |
218 | lr = None |
|
218 | lr = None | |
219 |
|
219 | |||
220 | try: |
|
220 | try: | |
221 | fl = repo.file(f) |
|
221 | fl = repo.file(f) | |
222 | except error.RevlogError, e: |
|
222 | except error.RevlogError, e: | |
223 | err(lr, _("broken revlog! (%s)") % e, f) |
|
223 | err(lr, _("broken revlog! (%s)") % e, f) | |
224 | continue |
|
224 | continue | |
225 |
|
225 | |||
226 | for ff in fl.files(): |
|
226 | for ff in fl.files(): | |
227 | try: |
|
227 | try: | |
228 | storefiles.remove(ff) |
|
228 | storefiles.remove(ff) | |
229 | except KeyError: |
|
229 | except KeyError: | |
230 | err(lr, _("missing revlog!"), ff) |
|
230 | err(lr, _("missing revlog!"), ff) | |
231 |
|
231 | |||
232 | checklog(fl, f, lr) |
|
232 | checklog(fl, f, lr) | |
233 | seen = {} |
|
233 | seen = {} | |
234 | rp = None |
|
234 | rp = None | |
235 | for i in fl: |
|
235 | for i in fl: | |
236 | revisions += 1 |
|
236 | revisions += 1 | |
237 | n = fl.node(i) |
|
237 | n = fl.node(i) | |
238 | lr = checkentry(fl, i, n, seen, linkrevs, f) |
|
238 | lr = checkentry(fl, i, n, seen, linkrevs, f) | |
239 | if f in filenodes: |
|
239 | if f in filenodes: | |
240 | if havemf and n not in filenodes[f]: |
|
240 | if havemf and n not in filenodes[f]: | |
241 | err(lr, _("%s not in manifests") % (short(n)), f) |
|
241 | err(lr, _("%s not in manifests") % (short(n)), f) | |
242 | else: |
|
242 | else: | |
243 | del filenodes[f][n] |
|
243 | del filenodes[f][n] | |
244 |
|
244 | |||
245 | # verify contents |
|
245 | # verify contents | |
246 | try: |
|
246 | try: | |
247 | l = len(fl.read(n)) |
|
247 | l = len(fl.read(n)) | |
248 | rp = fl.renamed(n) |
|
248 | rp = fl.renamed(n) | |
249 | if l != fl.size(i): |
|
249 | if l != fl.size(i): | |
250 | if len(fl.revision(n)) != fl.size(i): |
|
250 | if len(fl.revision(n)) != fl.size(i): | |
251 | err(lr, _("unpacked size is %s, %s expected") % |
|
251 | err(lr, _("unpacked size is %s, %s expected") % | |
252 | (l, fl.size(i)), f) |
|
252 | (l, fl.size(i)), f) | |
253 | except Exception, inst: |
|
253 | except Exception, inst: | |
254 | exc(lr, _("unpacking %s") % short(n), inst, f) |
|
254 | exc(lr, _("unpacking %s") % short(n), inst, f) | |
255 |
|
255 | |||
256 | # check renames |
|
256 | # check renames | |
257 | try: |
|
257 | try: | |
258 | if rp: |
|
258 | if rp: | |
259 | if lr is not None and ui.verbose: |
|
259 | if lr is not None and ui.verbose: | |
260 | ctx = lrugetctx(lr) |
|
260 | ctx = lrugetctx(lr) | |
261 | found = False |
|
261 | found = False | |
262 | for pctx in ctx.parents(): |
|
262 | for pctx in ctx.parents(): | |
263 | if rp[0] in pctx: |
|
263 | if rp[0] in pctx: | |
264 | found = True |
|
264 | found = True | |
265 | break |
|
265 | break | |
266 | if not found: |
|
266 | if not found: | |
267 | warn(_("warning: copy source of '%s' not" |
|
267 | warn(_("warning: copy source of '%s' not" | |
268 | " in parents of %s") % (f, ctx)) |
|
268 | " in parents of %s") % (f, ctx)) | |
269 | fl2 = repo.file(rp[0]) |
|
269 | fl2 = repo.file(rp[0]) | |
270 | if not len(fl2): |
|
270 | if not len(fl2): | |
271 | err(lr, _("empty or missing copy source revlog %s:%s") |
|
271 | err(lr, _("empty or missing copy source revlog %s:%s") | |
272 | % (rp[0], short(rp[1])), f) |
|
272 | % (rp[0], short(rp[1])), f) | |
273 | elif rp[1] == nullid: |
|
273 | elif rp[1] == nullid: | |
274 | ui.note(_("warning: %s@%s: copy source" |
|
274 | ui.note(_("warning: %s@%s: copy source" | |
275 | " revision is nullid %s:%s\n") |
|
275 | " revision is nullid %s:%s\n") | |
276 | % (f, lr, rp[0], short(rp[1]))) |
|
276 | % (f, lr, rp[0], short(rp[1]))) | |
277 | else: |
|
277 | else: | |
278 | fl2.rev(rp[1]) |
|
278 | fl2.rev(rp[1]) | |
279 | except Exception, inst: |
|
279 | except Exception, inst: | |
280 | exc(lr, _("checking rename of %s") % short(n), inst, f) |
|
280 | exc(lr, _("checking rename of %s") % short(n), inst, f) | |
281 |
|
281 | |||
282 | # cross-check |
|
282 | # cross-check | |
283 | if f in filenodes: |
|
283 | if f in filenodes: | |
284 | fns = [(lr, n) for n, lr in filenodes[f].iteritems()] |
|
284 | fns = [(lr, n) for n, lr in filenodes[f].iteritems()] | |
285 | for lr, node in sorted(fns): |
|
285 | for lr, node in sorted(fns): | |
286 | err(lr, _("%s in manifests not found") % short(node), f) |
|
286 | err(lr, _("%s in manifests not found") % short(node), f) | |
287 | ui.progress(_('checking'), None) |
|
287 | ui.progress(_('checking'), None) | |
288 |
|
288 | |||
289 | for f in storefiles: |
|
289 | for f in storefiles: | |
290 | warn(_("warning: orphan revlog '%s'") % f) |
|
290 | warn(_("warning: orphan revlog '%s'") % f) | |
291 |
|
291 | |||
292 | ui.status(_("%d files, %d changesets, %d total revisions\n") % |
|
292 | ui.status(_("%d files, %d changesets, %d total revisions\n") % | |
293 | (len(files), len(cl), revisions)) |
|
293 | (len(files), len(cl), revisions)) | |
294 | if warnings[0]: |
|
294 | if warnings[0]: | |
295 | ui.warn(_("%d warnings encountered!\n") % warnings[0]) |
|
295 | ui.warn(_("%d warnings encountered!\n") % warnings[0]) | |
296 | if errors[0]: |
|
296 | if errors[0]: | |
297 | ui.warn(_("%d integrity errors encountered!\n") % errors[0]) |
|
297 | ui.warn(_("%d integrity errors encountered!\n") % errors[0]) | |
298 | if badrevs: |
|
298 | if badrevs: | |
299 | ui.warn(_("(first damaged changeset appears to be %d)\n") |
|
299 | ui.warn(_("(first damaged changeset appears to be %d)\n") | |
300 | % min(badrevs)) |
|
300 | % min(badrevs)) | |
301 | return 1 |
|
301 | return 1 |
@@ -1,87 +1,101 b'' | |||||
1 | prepare repo |
|
1 | prepare repo | |
2 |
|
2 | |||
3 | $ hg init a |
|
3 | $ hg init a | |
4 | $ cd a |
|
4 | $ cd a | |
5 | $ echo "some text" > FOO.txt |
|
5 | $ echo "some text" > FOO.txt | |
6 | $ echo "another text" > bar.txt |
|
6 | $ echo "another text" > bar.txt | |
7 | $ echo "more text" > QUICK.txt |
|
7 | $ echo "more text" > QUICK.txt | |
8 | $ hg add |
|
8 | $ hg add | |
9 | adding FOO.txt |
|
9 | adding FOO.txt | |
10 | adding QUICK.txt |
|
10 | adding QUICK.txt | |
11 | adding bar.txt |
|
11 | adding bar.txt | |
12 | $ hg ci -mtest1 |
|
12 | $ hg ci -mtest1 | |
13 |
|
13 | |||
14 | verify |
|
14 | verify | |
15 |
|
15 | |||
16 | $ hg verify |
|
16 | $ hg verify | |
17 | checking changesets |
|
17 | checking changesets | |
18 | checking manifests |
|
18 | checking manifests | |
19 | crosschecking files in changesets and manifests |
|
19 | crosschecking files in changesets and manifests | |
20 | checking files |
|
20 | checking files | |
21 | 3 files, 1 changesets, 3 total revisions |
|
21 | 3 files, 1 changesets, 3 total revisions | |
22 |
|
22 | |||
23 | verify with journal |
|
23 | verify with journal | |
24 |
|
24 | |||
25 | $ touch .hg/store/journal |
|
25 | $ touch .hg/store/journal | |
26 | $ hg verify |
|
26 | $ hg verify | |
27 | abandoned transaction found - run hg recover |
|
27 | abandoned transaction found - run hg recover | |
28 | checking changesets |
|
28 | checking changesets | |
29 | checking manifests |
|
29 | checking manifests | |
30 | crosschecking files in changesets and manifests |
|
30 | crosschecking files in changesets and manifests | |
31 | checking files |
|
31 | checking files | |
32 | 3 files, 1 changesets, 3 total revisions |
|
32 | 3 files, 1 changesets, 3 total revisions | |
33 | $ rm .hg/store/journal |
|
33 | $ rm .hg/store/journal | |
34 |
|
34 | |||
35 | introduce some bugs in repo |
|
35 | introduce some bugs in repo | |
36 |
|
36 | |||
37 | $ cd .hg/store/data |
|
37 | $ cd .hg/store/data | |
38 | $ mv _f_o_o.txt.i X_f_o_o.txt.i |
|
38 | $ mv _f_o_o.txt.i X_f_o_o.txt.i | |
39 | $ mv bar.txt.i xbar.txt.i |
|
39 | $ mv bar.txt.i xbar.txt.i | |
40 | $ rm _q_u_i_c_k.txt.i |
|
40 | $ rm _q_u_i_c_k.txt.i | |
41 |
|
41 | |||
42 | $ hg verify |
|
42 | $ hg verify | |
43 | checking changesets |
|
43 | checking changesets | |
44 | checking manifests |
|
44 | checking manifests | |
45 | crosschecking files in changesets and manifests |
|
45 | crosschecking files in changesets and manifests | |
46 | checking files |
|
46 | checking files | |
47 | data/FOO.txt.i@0: missing revlog! |
|
47 | data/FOO.txt.i@0: missing revlog! | |
48 | 0: empty or missing FOO.txt |
|
48 | 0: empty or missing FOO.txt | |
49 | FOO.txt@0: f62022d3d590 in manifests not found |
|
49 | FOO.txt@0: f62022d3d590 in manifests not found | |
50 | data/QUICK.txt.i@0: missing revlog! |
|
50 | data/QUICK.txt.i@0: missing revlog! | |
51 | 0: empty or missing QUICK.txt |
|
51 | 0: empty or missing QUICK.txt | |
52 | QUICK.txt@0: 88b857db8eba in manifests not found |
|
52 | QUICK.txt@0: 88b857db8eba in manifests not found | |
53 | data/bar.txt.i@0: missing revlog! |
|
53 | data/bar.txt.i@0: missing revlog! | |
54 | 0: empty or missing bar.txt |
|
54 | 0: empty or missing bar.txt | |
55 | bar.txt@0: 256559129457 in manifests not found |
|
55 | bar.txt@0: 256559129457 in manifests not found | |
56 | 3 files, 1 changesets, 0 total revisions |
|
56 | 3 files, 1 changesets, 0 total revisions | |
57 | 9 integrity errors encountered! |
|
57 | 9 integrity errors encountered! | |
58 | (first damaged changeset appears to be 0) |
|
58 | (first damaged changeset appears to be 0) | |
59 |
|
59 | |||
60 | $ cd .. |
|
60 | $ cd .. | |
61 |
|
61 | |||
62 | test revlog corruption |
|
62 | test revlog corruption | |
63 |
|
63 | |||
64 | $ hg init b |
|
64 | $ hg init b | |
65 | $ cd b |
|
65 | $ cd b | |
66 |
|
66 | |||
67 | $ touch a |
|
67 | $ touch a | |
68 | $ hg add a |
|
68 | $ hg add a | |
69 | $ hg ci -m a |
|
69 | $ hg ci -m a | |
70 |
|
70 | |||
71 | $ echo 'corrupted' > b |
|
71 | $ echo 'corrupted' > b | |
72 | $ dd if=.hg/store/data/a.i of=start bs=1 count=20 2>/dev/null |
|
72 | $ dd if=.hg/store/data/a.i of=start bs=1 count=20 2>/dev/null | |
73 | $ cat start b > .hg/store/data/a.i |
|
73 | $ cat start b > .hg/store/data/a.i | |
74 |
|
74 | |||
75 | $ hg verify |
|
75 | $ hg verify | |
76 | checking changesets |
|
76 | checking changesets | |
77 | checking manifests |
|
77 | checking manifests | |
78 | crosschecking files in changesets and manifests |
|
78 | crosschecking files in changesets and manifests | |
79 | checking files |
|
79 | checking files | |
80 | a@0: broken revlog! (index data/a.i is corrupted) |
|
80 | a@0: broken revlog! (index data/a.i is corrupted) | |
81 | warning: orphan revlog 'data/a.i' |
|
81 | warning: orphan revlog 'data/a.i' | |
82 | 1 files, 1 changesets, 0 total revisions |
|
82 | 1 files, 1 changesets, 0 total revisions | |
83 | 1 warnings encountered! |
|
83 | 1 warnings encountered! | |
84 | 1 integrity errors encountered! |
|
84 | 1 integrity errors encountered! | |
85 | (first damaged changeset appears to be 0) |
|
85 | (first damaged changeset appears to be 0) | |
86 |
|
86 | |||
|
87 | $ cd .. | |||
|
88 | ||||
|
89 | test revlog format 0 | |||
|
90 | ||||
|
91 | $ "$TESTDIR/revlog-formatv0.py" | |||
|
92 | $ cd formatv0 | |||
|
93 | $ hg verify | |||
|
94 | repository uses revlog format 0 | |||
|
95 | checking changesets | |||
|
96 | checking manifests | |||
|
97 | crosschecking files in changesets and manifests | |||
|
98 | checking files | |||
|
99 | 1 files, 1 changesets, 1 total revisions | |||
|
100 | ||||
87 |
$ |
|
101 | $ exit 0 |
General Comments 0
You need to be logged in to leave comments.
Login now