Mercurial > public > mercurial-scm > hg
comparison mercurial/verify.py @ 6750:fb42030d79d6
add __len__ and __iter__ methods to repo and revlog
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 26 Jun 2008 14:35:50 -0500 |
parents | 9b35a9f34675 |
children | 7424a75f919a |
comparison
equal
deleted
inserted
replaced
6749:51b0e799352f | 6750:fb42030d79d6 |
---|---|
63 (revlogv1 and 1 or 0)) | 63 (revlogv1 and 1 or 0)) |
64 | 64 |
65 havecl = havemf = 1 | 65 havecl = havemf = 1 |
66 seen = {} | 66 seen = {} |
67 repo.ui.status(_("checking changesets\n")) | 67 repo.ui.status(_("checking changesets\n")) |
68 if repo.changelog.count() == 0 and repo.manifest.count() > 1: | 68 if not len(repo) and len(repo.manifest): |
69 havecl = 0 | 69 havecl = 0 |
70 err(0, _("empty or missing 00changelog.i")) | 70 err(0, _("empty or missing 00changelog.i")) |
71 else: | 71 else: |
72 checksize(repo.changelog, "changelog") | 72 checksize(repo.changelog, "changelog") |
73 | 73 |
74 for i in xrange(repo.changelog.count()): | 74 for i in repo: |
75 changesets += 1 | 75 changesets += 1 |
76 n = repo.changelog.node(i) | 76 n = repo.changelog.node(i) |
77 l = repo.changelog.linkrev(n) | 77 l = repo.changelog.linkrev(n) |
78 if l != i: | 78 if l != i: |
79 err(i, _("incorrect link (%d) for changeset") %(l)) | 79 err(i, _("incorrect link (%d) for changeset") %(l)) |
99 for f in changes[3]: | 99 for f in changes[3]: |
100 filelinkrevs.setdefault(f, []).append(i) | 100 filelinkrevs.setdefault(f, []).append(i) |
101 | 101 |
102 seen = {} | 102 seen = {} |
103 repo.ui.status(_("checking manifests\n")) | 103 repo.ui.status(_("checking manifests\n")) |
104 if repo.changelog.count() > 0 and repo.manifest.count() == 0: | 104 if len(repo) and not len(repo.manifest): |
105 havemf = 0 | 105 havemf = 0 |
106 err(0, _("empty or missing 00manifest.i")) | 106 err(0, _("empty or missing 00manifest.i")) |
107 else: | 107 else: |
108 checkversion(repo.manifest, "manifest") | 108 checkversion(repo.manifest, "manifest") |
109 checksize(repo.manifest, "manifest") | 109 checksize(repo.manifest, "manifest") |
110 | 110 |
111 for i in xrange(repo.manifest.count()): | 111 for i in repo.manifest: |
112 n = repo.manifest.node(i) | 112 n = repo.manifest.node(i) |
113 l = repo.manifest.linkrev(n) | 113 l = repo.manifest.linkrev(n) |
114 | 114 |
115 if l < 0 or (havecl and l >= repo.changelog.count()): | 115 if l < 0 or (havecl and l >= len(repo)): |
116 err(None, _("bad link (%d) at manifest revision %d") % (l, i)) | 116 err(None, _("bad link (%d) at manifest revision %d") % (l, i)) |
117 | 117 |
118 if n in neededmanifests: | 118 if n in neededmanifests: |
119 del neededmanifests[n] | 119 del neededmanifests[n] |
120 | 120 |
180 continue | 180 continue |
181 fl = repo.file(f) | 181 fl = repo.file(f) |
182 checkversion(fl, f) | 182 checkversion(fl, f) |
183 checksize(fl, f) | 183 checksize(fl, f) |
184 | 184 |
185 if fl.count() == 0: | 185 if not len(fl): |
186 err(filelinkrevs[f][0], _("empty or missing revlog"), f) | 186 err(filelinkrevs[f][0], _("empty or missing revlog"), f) |
187 continue | 187 continue |
188 | 188 |
189 seen = {} | 189 seen = {} |
190 nodes = {nullid: 1} | 190 nodes = {nullid: 1} |
191 for i in xrange(fl.count()): | 191 for i in fl: |
192 revisions += 1 | 192 revisions += 1 |
193 n = fl.node(i) | 193 n = fl.node(i) |
194 flr = fl.linkrev(n) | 194 flr = fl.linkrev(n) |
195 | 195 |
196 if flr < 0 or (havecl and flr not in filelinkrevs.get(f, [])): | 196 if flr < 0 or (havecl and flr not in filelinkrevs.get(f, [])): |
197 if flr < 0 or flr >= repo.changelog.count(): | 197 if flr < 0 or flr >= len(repo): |
198 err(None, _("rev %d point to nonexistent changeset %d") | 198 err(None, _("rev %d point to nonexistent changeset %d") |
199 % (i, flr), f) | 199 % (i, flr), f) |
200 else: | 200 else: |
201 err(None, _("rev %d points to unexpected changeset %d") | 201 err(None, _("rev %d points to unexpected changeset %d") |
202 % (i, flr), f) | 202 % (i, flr), f) |
243 # check renames | 243 # check renames |
244 try: | 244 try: |
245 rp = fl.renamed(n) | 245 rp = fl.renamed(n) |
246 if rp: | 246 if rp: |
247 fl2 = repo.file(rp[0]) | 247 fl2 = repo.file(rp[0]) |
248 if fl2.count() == 0: | 248 if not len(fl2): |
249 err(flr, _("empty or missing copy source revlog %s:%s") | 249 err(flr, _("empty or missing copy source revlog %s:%s") |
250 % (rp[0], short(rp[1])), f) | 250 % (rp[0], short(rp[1])), f) |
251 elif rp[1] == nullid: | 251 elif rp[1] == nullid: |
252 err(flr, _("copy source revision is nullid %s:%s") | 252 err(flr, _("copy source revision is nullid %s:%s") |
253 % (rp[0], short(rp[1])), f) | 253 % (rp[0], short(rp[1])), f) |