Patchwork [04,of,18,"] verify: make `err` a private method

login
register
mail settings
Submitter Pierre-Yves David
Date March 6, 2019, 4:29 p.m.
Message ID <d6124b30caf951800f61.1551889760@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/39097/
State Accepted
Headers show

Comments

Pierre-Yves David - March 6, 2019, 4:29 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1551868057 -3600
#      Wed Mar 06 11:27:37 2019 +0100
# Node ID d6124b30caf951800f61a53a72792c2e6a98e393
# Parent  0124906dffd713a436215ab35ae56fd55b8ac77f
# EXP-Topic verify
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r d6124b30caf9
verify: make `err` a private method

The method is for internal use only.

Patch

diff --git a/mercurial/verify.py b/mercurial/verify.py
--- a/mercurial/verify.py
+++ b/mercurial/verify.py
@@ -56,7 +56,7 @@  class verifier(object):
         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 @@  class verifier(object):
         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 @@  class verifier(object):
                 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 @@  class verifier(object):
         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 @@  class verifier(object):
             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 @@  class verifier(object):
             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 @@  class verifier(object):
             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 @@  class verifier(object):
                 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 @@  class verifier(object):
                         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 @@  class verifier(object):
         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 @@  class verifier(object):
             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 @@  class verifier(object):
                         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 @@  class verifier(object):
                     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 @@  class verifier(object):
                 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 @@  class verifier(object):
                                             " 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 @@  class verifier(object):
             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: