Mercurial > public > mercurial-scm > hg
comparison mercurial/verify.py @ 38396:0ddbe03c5aaa
verify: use progress helper for subdirectory progress
I also reworded a variable to make it clearer that it's only used for
subdirectories.
Differential Revision: https://phab.mercurial-scm.org/D3797
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Sun, 17 Jun 2018 23:35:49 -0700 |
parents | 76d2115cb817 |
children | 1249475f0bd6 |
comparison
equal
deleted
inserted
replaced
38395:59c9d3cc810f | 38396:0ddbe03c5aaa |
---|---|
197 self.exc(i, _("unpacking changeset %s") % short(n), inst) | 197 self.exc(i, _("unpacking changeset %s") % short(n), inst) |
198 ui.progress(_('checking'), None) | 198 ui.progress(_('checking'), None) |
199 return mflinkrevs, filelinkrevs | 199 return mflinkrevs, filelinkrevs |
200 | 200 |
201 def _verifymanifest(self, mflinkrevs, dir="", storefiles=None, | 201 def _verifymanifest(self, mflinkrevs, dir="", storefiles=None, |
202 progress=None): | 202 subdirprogress=None): |
203 repo = self.repo | 203 repo = self.repo |
204 ui = self.ui | 204 ui = self.ui |
205 match = self.match | 205 match = self.match |
206 mfl = self.repo.manifestlog | 206 mfl = self.repo.manifestlog |
207 mf = mfl._revlog.dirlog(dir) | 207 mf = mfl._revlog.dirlog(dir) |
215 label = "manifest" | 215 label = "manifest" |
216 if dir: | 216 if dir: |
217 label = dir | 217 label = dir |
218 revlogfiles = mf.files() | 218 revlogfiles = mf.files() |
219 storefiles.difference_update(revlogfiles) | 219 storefiles.difference_update(revlogfiles) |
220 if progress: # should be true since we're in a subdirectory | 220 if subdirprogress: # should be true since we're in a subdirectory |
221 progress() | 221 subdirprogress.increment() |
222 if self.refersmf: | 222 if self.refersmf: |
223 # Do not check manifest if there are only changelog entries with | 223 # Do not check manifest if there are only changelog entries with |
224 # null manifests. | 224 # null manifests. |
225 self.checklog(mf, label, 0) | 225 self.checklog(mf, label, 0) |
226 total = len(mf) | 226 total = len(mf) |
278 if not f: | 278 if not f: |
279 self.err(None, _("cannot decode filename '%s'") % f2) | 279 self.err(None, _("cannot decode filename '%s'") % f2) |
280 elif (size > 0 or not revlogv1) and f.startswith('meta/'): | 280 elif (size > 0 or not revlogv1) and f.startswith('meta/'): |
281 storefiles.add(_normpath(f)) | 281 storefiles.add(_normpath(f)) |
282 subdirs.add(os.path.dirname(f)) | 282 subdirs.add(os.path.dirname(f)) |
283 subdircount = len(subdirs) | 283 subdirprogress = ui.makeprogress(_('checking'), unit=_('manifests'), |
284 currentsubdir = [0] | 284 total=len(subdirs)) |
285 def progress(): | |
286 currentsubdir[0] += 1 | |
287 ui.progress(_('checking'), currentsubdir[0], total=subdircount, | |
288 unit=_('manifests')) | |
289 | 285 |
290 for subdir, linkrevs in subdirnodes.iteritems(): | 286 for subdir, linkrevs in subdirnodes.iteritems(): |
291 subdirfilenodes = self._verifymanifest(linkrevs, subdir, storefiles, | 287 subdirfilenodes = self._verifymanifest(linkrevs, subdir, storefiles, |
292 progress) | 288 subdirprogress) |
293 for f, onefilenodes in subdirfilenodes.iteritems(): | 289 for f, onefilenodes in subdirfilenodes.iteritems(): |
294 filenodes.setdefault(f, {}).update(onefilenodes) | 290 filenodes.setdefault(f, {}).update(onefilenodes) |
295 | 291 |
296 if not dir and subdirnodes: | 292 if not dir and subdirnodes: |
297 ui.progress(_('checking'), None) | 293 subdirprogress.complete() |
298 if self.warnorphanstorefiles: | 294 if self.warnorphanstorefiles: |
299 for f in sorted(storefiles): | 295 for f in sorted(storefiles): |
300 self.warn(_("warning: orphan data file '%s'") % f) | 296 self.warn(_("warning: orphan data file '%s'") % f) |
301 | 297 |
302 return filenodes | 298 return filenodes |