verify: make `err` a private method
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 06 Mar 2019 11:27:37 +0100
changeset 41864 7eaf4b1ac2a3
parent 41863 9534f3cb6b6c
child 41865 5df8475c5343
verify: make `err` a private method The method is for internal use only.
mercurial/verify.py
--- a/mercurial/verify.py	Wed Mar 06 11:25:16 2019 +0100
+++ b/mercurial/verify.py	Wed Mar 06 11:27:37 2019 +0100
@@ -56,7 +56,7 @@
         self.ui.warn(msg + "\n")
         self.warnings += 1
 
-    def err(self, linkrev, msg, filename=None):
+    def _err(self, linkrev, msg, filename=None):
         """record a "error" level issue"""
         if linkrev is not None:
             self.badrevs.add(linkrev)
@@ -73,11 +73,11 @@
         fmsg = pycompat.bytestr(inst)
         if not fmsg:
             fmsg = pycompat.byterepr(inst)
-        self.err(linkrev, "%s: %s" % (msg, fmsg), filename)
+        self._err(linkrev, "%s: %s" % (msg, fmsg), filename)
 
     def checklog(self, obj, name, linkrev):
         if not len(obj) and (self.havecl or self.havemf):
-            self.err(linkrev, _("empty or missing %s") % name)
+            self._err(linkrev, _("empty or missing %s") % name)
             return
 
         d = obj.checksize()
@@ -99,7 +99,7 @@
                 msg = _("rev %d points to nonexistent changeset %d")
             else:
                 msg = _("rev %d points to unexpected changeset %d")
-            self.err(None, msg % (i, lr), f)
+            self._err(None, msg % (i, lr), f)
             if linkrevs:
                 if f and len(linkrevs) > 1:
                     try:
@@ -115,16 +115,16 @@
         try:
             p1, p2 = obj.parents(node)
             if p1 not in seen and p1 != nullid:
-                self.err(lr, _("unknown parent 1 %s of %s") %
+                self._err(lr, _("unknown parent 1 %s of %s") %
                     (short(p1), short(node)), f)
             if p2 not in seen and p2 != nullid:
-                self.err(lr, _("unknown parent 2 %s of %s") %
+                self._err(lr, _("unknown parent 2 %s of %s") %
                     (short(p2), short(node)), f)
         except Exception as inst:
             self.exc(lr, _("checking parents of %s") % short(node), inst, f)
 
         if node in seen:
-            self.err(lr, _("duplicate revision %d (%d)") % (i, seen[node]), f)
+            self._err(lr, _("duplicate revision %d (%d)") % (i, seen[node]), f)
         seen[node] = i
         return lr
 
@@ -233,16 +233,16 @@
             if n in mflinkrevs:
                 del mflinkrevs[n]
             elif dir:
-                self.err(lr, _("%s not in parent-directory manifest") %
+                self._err(lr, _("%s not in parent-directory manifest") %
                          short(n), label)
             else:
-                self.err(lr, _("%s not in changesets") % short(n), label)
+                self._err(lr, _("%s not in changesets") % short(n), label)
 
             try:
                 mfdelta = mfl.get(dir, n).readdelta(shallow=True)
                 for f, fn, fl in mfdelta.iterentries():
                     if not f:
-                        self.err(lr, _("entry without name in manifest"))
+                        self._err(lr, _("entry without name in manifest"))
                     elif f == "/dev/null":  # ignore this in very old repos
                         continue
                     fullpath = dir + _normpath(f)
@@ -264,11 +264,11 @@
             for c, m in sorted([(c, m) for m in mflinkrevs
                         for c in mflinkrevs[m]]):
                 if dir:
-                    self.err(c, _("parent-directory manifest refers to unknown "
-                                  "revision %s") % short(m), label)
+                    self._err(c, _("parent-directory manifest refers to unknown"
+                                   " revision %s") % short(m), label)
                 else:
-                    self.err(c, _("changeset refers to unknown revision %s") %
-                             short(m), label)
+                    self._err(c, _("changeset refers to unknown revision %s") %
+                              short(m), label)
 
         if not dir and subdirnodes:
             self.ui.status(_("checking directory manifests\n"))
@@ -277,7 +277,7 @@
             revlogv1 = self.revlogv1
             for f, f2, size in repo.store.datafiles():
                 if not f:
-                    self.err(None, _("cannot decode filename '%s'") % f2)
+                    self._err(None, _("cannot decode filename '%s'") % f2)
                 elif (size > 0 or not revlogv1) and f.startswith('meta/'):
                     storefiles.add(_normpath(f))
                     subdirs.add(os.path.dirname(f))
@@ -311,7 +311,7 @@
                 progress.increment()
                 if f not in filenodes:
                     lr = filelinkrevs[f][0]
-                    self.err(lr, _("in changeset but not in manifest"), f)
+                    self._err(lr, _("in changeset but not in manifest"), f)
 
         if self.havecl:
             for f in sorted(filenodes):
@@ -322,7 +322,7 @@
                         lr = min([fl.linkrev(fl.rev(n)) for n in filenodes[f]])
                     except Exception:
                         lr = None
-                    self.err(lr, _("in manifest but not in changeset"), f)
+                    self._err(lr, _("in manifest but not in changeset"), f)
 
         progress.complete()
 
@@ -337,7 +337,7 @@
         storefiles = set()
         for f, f2, size in repo.store.datafiles():
             if not f:
-                self.err(None, _("cannot decode filename '%s'") % f2)
+                self._err(None, _("cannot decode filename '%s'") % f2)
             elif (size > 0 or not revlogv1) and f.startswith('data/'):
                 storefiles.add(_normpath(f))
 
@@ -369,7 +369,7 @@
             try:
                 fl = repo.file(f)
             except error.StorageError as e:
-                self.err(lr, _("broken revlog! (%s)") % e, f)
+                self._err(lr, _("broken revlog! (%s)") % e, f)
                 continue
 
             for ff in fl.files():
@@ -382,7 +382,7 @@
                         self.fncachewarned = True
 
             if not len(fl) and (self.havecl or self.havemf):
-                self.err(lr, _("empty or missing %s") % f)
+                self._err(lr, _("empty or missing %s") % f)
             else:
                 # Guard against implementations not setting this.
                 state['skipread'] = set()
@@ -395,8 +395,8 @@
                     if problem.warning:
                         self._warn(problem.warning)
                     elif problem.error:
-                        self.err(linkrev if linkrev is not None else lr,
-                                 problem.error, f)
+                        self._err(linkrev if linkrev is not None else lr,
+                                  problem.error, f)
                     else:
                         raise error.ProgrammingError(
                             'problem instance does not set warning or error '
@@ -409,7 +409,7 @@
                 lr = self.checkentry(fl, i, n, seen, linkrevs, f)
                 if f in filenodes:
                     if havemf and n not in filenodes[f]:
-                        self.err(lr, _("%s not in manifests") % (short(n)), f)
+                        self._err(lr, _("%s not in manifests") % (short(n)), f)
                     else:
                         del filenodes[f][n]
 
@@ -430,8 +430,11 @@
                                             " in parents of %s") % (f, ctx))
                         fl2 = repo.file(rp[0])
                         if not len(fl2):
-                            self.err(lr, _("empty or missing copy source "
-                                     "revlog %s:%s") % (rp[0], short(rp[1])), f)
+                            self._err(lr,
+                                      _("empty or missing copy source revlog "
+                                        "%s:%s") % (rp[0],
+                                      short(rp[1])),
+                                      f)
                         elif rp[1] == nullid:
                             ui.note(_("warning: %s@%s: copy source"
                                       " revision is nullid %s:%s\n")
@@ -445,8 +448,8 @@
             if f in filenodes:
                 fns = [(v, k) for k, v in filenodes[f].iteritems()]
                 for lr, node in sorted(fns):
-                    self.err(lr, _("manifest refers to unknown revision %s") %
-                             short(node), f)
+                    self._err(lr, _("manifest refers to unknown revision %s") %
+                              short(node), f)
         progress.complete()
 
         if self.warnorphanstorefiles: