Mercurial > hg
comparison mercurial/verify.py @ 28205:53f42c8d5f71
verify: show progress while verifying dirlogs
In repos with treemanifests, the non-root-directory dirlogs often have
many more total revisions than the root manifest log has. This change
adds progress out to that part of 'hg verify'. Since the verification
is recursive along the directory tree, we don't know how many total
revisions there are at the beginning of the command, so instead we
report progress in units of directories, much like we report progress
for verification of files today.
I'm not very happy with passing both 'storefiles' and 'progress' into
the recursive calls. I tried passing in just a 'visitdir(dir)'
callback, but the results did not seem better overall. I'm happy to
update if anyone has better ideas.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 11 Feb 2016 15:38:56 -0800 |
parents | 962921c330b0 |
children | bd37f0d53a49 |
comparison
equal
deleted
inserted
replaced
28204:962921c330b0 | 28205:53f42c8d5f71 |
---|---|
195 self.refersmf = True | 195 self.refersmf = True |
196 self.exc(i, _("unpacking changeset %s") % short(n), inst) | 196 self.exc(i, _("unpacking changeset %s") % short(n), inst) |
197 ui.progress(_('checking'), None) | 197 ui.progress(_('checking'), None) |
198 return mflinkrevs, filelinkrevs | 198 return mflinkrevs, filelinkrevs |
199 | 199 |
200 def _verifymanifest(self, mflinkrevs, dir="", storefiles=None): | 200 def _verifymanifest(self, mflinkrevs, dir="", storefiles=None, |
201 progress=None): | |
201 repo = self.repo | 202 repo = self.repo |
202 ui = self.ui | 203 ui = self.ui |
203 mf = self.repo.manifest.dirlog(dir) | 204 mf = self.repo.manifest.dirlog(dir) |
204 | 205 |
205 if not dir: | 206 if not dir: |
211 label = "manifest" | 212 label = "manifest" |
212 if dir: | 213 if dir: |
213 label = dir | 214 label = dir |
214 revlogfiles = mf.files() | 215 revlogfiles = mf.files() |
215 storefiles.difference_update(revlogfiles) | 216 storefiles.difference_update(revlogfiles) |
217 if progress: # should be true since we're in a subdirectory | |
218 progress() | |
216 if self.refersmf: | 219 if self.refersmf: |
217 # Do not check manifest if there are only changelog entries with | 220 # Do not check manifest if there are only changelog entries with |
218 # null manifests. | 221 # null manifests. |
219 self.checklog(mf, label, 0) | 222 self.checklog(mf, label, 0) |
220 total = len(mf) | 223 total = len(mf) |
261 short(m), label) | 264 short(m), label) |
262 | 265 |
263 if not dir and subdirnodes: | 266 if not dir and subdirnodes: |
264 self.ui.status(_("checking directory manifests\n")) | 267 self.ui.status(_("checking directory manifests\n")) |
265 storefiles = set() | 268 storefiles = set() |
269 subdirs = set() | |
266 revlogv1 = self.revlogv1 | 270 revlogv1 = self.revlogv1 |
267 for f, f2, size in repo.store.datafiles(): | 271 for f, f2, size in repo.store.datafiles(): |
268 if not f: | 272 if not f: |
269 self.err(None, _("cannot decode filename '%s'") % f2) | 273 self.err(None, _("cannot decode filename '%s'") % f2) |
270 elif (size > 0 or not revlogv1) and f.startswith('meta/'): | 274 elif (size > 0 or not revlogv1) and f.startswith('meta/'): |
271 storefiles.add(_normpath(f)) | 275 storefiles.add(_normpath(f)) |
276 subdirs.add(os.path.dirname(f)) | |
277 subdircount = len(subdirs) | |
278 currentsubdir = [0] | |
279 def progress(): | |
280 currentsubdir[0] += 1 | |
281 ui.progress(_('checking'), currentsubdir[0], total=subdircount, | |
282 unit=_('manifests')) | |
272 | 283 |
273 for subdir, linkrevs in subdirnodes.iteritems(): | 284 for subdir, linkrevs in subdirnodes.iteritems(): |
274 subdirfilenodes = self._verifymanifest(linkrevs, subdir, storefiles) | 285 subdirfilenodes = self._verifymanifest(linkrevs, subdir, storefiles, |
286 progress) | |
275 for f, onefilenodes in subdirfilenodes.iteritems(): | 287 for f, onefilenodes in subdirfilenodes.iteritems(): |
276 filenodes.setdefault(f, {}).update(onefilenodes) | 288 filenodes.setdefault(f, {}).update(onefilenodes) |
277 | 289 |
278 if not dir and subdirnodes: | 290 if not dir and subdirnodes: |
291 ui.progress(_('checking'), None) | |
279 for f in sorted(storefiles): | 292 for f in sorted(storefiles): |
280 self.warn(_("warning: orphan revlog '%s'") % f) | 293 self.warn(_("warning: orphan revlog '%s'") % f) |
281 | 294 |
282 return filenodes | 295 return filenodes |
283 | 296 |