##// END OF EJS Templates
verify: move widely used variables into class members...
Durham Goode -
r27444:66474018 default
parent child Browse files
Show More
@@ -24,7 +24,7 b' from . import ('
24 def verify(repo):
24 def verify(repo):
25 lock = repo.lock()
25 lock = repo.lock()
26 try:
26 try:
27 return verifier().verify(repo)
27 return verifier(repo).verify()
28 finally:
28 finally:
29 lock.release()
29 lock.release()
30
30
@@ -47,19 +47,31 b' def _validpath(repo, path):'
47 return True
47 return True
48
48
49 class verifier(object):
49 class verifier(object):
50 def verify(self, repo):
50 def __init__(self, repo):
51 repo = repo.unfiltered()
51 self.repo = repo.unfiltered()
52 self.ui = repo.ui
53 self.badrevs = set()
54 self.errors = [0]
55 self.warnings = [0]
56 self.havecl = len(repo.changelog) > 0
57 self.havemf = len(repo.manifest) > 0
58 self.revlogv1 = repo.changelog.version != revlog.REVLOGV0
59 self.lrugetctx = util.lrucachefunc(repo.changectx)
60 self.refersmf = False
61
62 def verify(self):
63 repo = self.repo
52 mflinkrevs = {}
64 mflinkrevs = {}
53 filelinkrevs = {}
65 filelinkrevs = {}
54 filenodes = {}
66 filenodes = {}
55 revisions = 0
67 revisions = 0
56 badrevs = set()
68 badrevs = self.badrevs
57 errors = [0]
69 errors = self.errors
58 warnings = [0]
70 warnings = self.warnings
59 ui = repo.ui
71 ui = repo.ui
60 cl = repo.changelog
72 cl = repo.changelog
61 mf = repo.manifest
73 mf = repo.manifest
62 lrugetctx = util.lrucachefunc(repo.changectx)
74 lrugetctx = self.lrugetctx
63
75
64 if not repo.url().startswith('file:'):
76 if not repo.url().startswith('file:'):
65 raise error.Abort(_("cannot verify bundle or remote repos"))
77 raise error.Abort(_("cannot verify bundle or remote repos"))
@@ -142,16 +154,15 b' class verifier(object):'
142 if os.path.exists(repo.sjoin("journal")):
154 if os.path.exists(repo.sjoin("journal")):
143 ui.warn(_("abandoned transaction found - run hg recover\n"))
155 ui.warn(_("abandoned transaction found - run hg recover\n"))
144
156
145 revlogv1 = cl.version != revlog.REVLOGV0
157 revlogv1 = self.revlogv1
146 if ui.verbose or not revlogv1:
158 if ui.verbose or not revlogv1:
147 ui.status(_("repository uses revlog format %d\n") %
159 ui.status(_("repository uses revlog format %d\n") %
148 (revlogv1 and 1 or 0))
160 (revlogv1 and 1 or 0))
149
161
150 havecl = len(cl) > 0
162 havecl = self.havecl
151 havemf = len(mf) > 0
163 havemf = self.havemf
152
164
153 ui.status(_("checking changesets\n"))
165 ui.status(_("checking changesets\n"))
154 refersmf = False
155 seen = {}
166 seen = {}
156 checklog(cl, "changelog", 0)
167 checklog(cl, "changelog", 0)
157 total = len(repo)
168 total = len(repo)
@@ -164,18 +175,18 b' class verifier(object):'
164 changes = cl.read(n)
175 changes = cl.read(n)
165 if changes[0] != nullid:
176 if changes[0] != nullid:
166 mflinkrevs.setdefault(changes[0], []).append(i)
177 mflinkrevs.setdefault(changes[0], []).append(i)
167 refersmf = True
178 self.refersmf = True
168 for f in changes[3]:
179 for f in changes[3]:
169 if _validpath(repo, f):
180 if _validpath(repo, f):
170 filelinkrevs.setdefault(_normpath(f), []).append(i)
181 filelinkrevs.setdefault(_normpath(f), []).append(i)
171 except Exception as inst:
182 except Exception as inst:
172 refersmf = True
183 self.refersmf = True
173 exc(i, _("unpacking changeset %s") % short(n), inst)
184 exc(i, _("unpacking changeset %s") % short(n), inst)
174 ui.progress(_('checking'), None)
185 ui.progress(_('checking'), None)
175
186
176 ui.status(_("checking manifests\n"))
187 ui.status(_("checking manifests\n"))
177 seen = {}
188 seen = {}
178 if refersmf:
189 if self.refersmf:
179 # Do not check manifest if there are only changelog entries with
190 # Do not check manifest if there are only changelog entries with
180 # null manifests.
191 # null manifests.
181 checklog(mf, "manifest", 0)
192 checklog(mf, "manifest", 0)
General Comments 0
You need to be logged in to leave comments. Login now