match: some minimal pycompat fixes guided by test-hgignore.t
authorAugie Fackler <augie@google.com>
Fri, 02 Mar 2018 00:37:55 -0500
changeset 43257 9adfa48792a7bdced8936d8bc8830d27c267f1a5
parent 43256 5a3f8da663e52adaf54061750bb75b8dbefb8278
child 43258 9b6b02a5b589e09e47d82a61374ad9ada93471d6
push id715
push usergszorc@mozilla.com
push dateFri, 02 Mar 2018 22:25:31 +0000
match: some minimal pycompat fixes guided by test-hgignore.t Differential Revision: https://phab.mercurial-scm.org/D2551
mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -11,16 +11,17 @@ import copy
 import os
 import re
 
 from .i18n import _
 from . import (
     encoding,
     error,
     pathutil,
+    pycompat,
     util,
 )
 
 allpatternkinds = ('re', 'glob', 'path', 'relglob', 'relpath', 'relre',
                    'listfile', 'listfile0', 'set', 'include', 'subinclude',
                    'rootfilesin')
 cwdrelativepatternkinds = ('relpath', 'glob')
 
@@ -221,17 +222,17 @@ def _donormalize(patterns, default, root
                 for k, p, source in _donormalize(includepats, default,
                                                  root, cwd, auditor, warn):
                     kindpats.append((k, p, source or pat))
             except error.Abort as inst:
                 raise error.Abort('%s: %s' % (pat, inst[0]))
             except IOError as inst:
                 if warn:
                     warn(_("skipping unreadable pattern file '%s': %s\n") %
-                         (pat, inst.strerror))
+                         (pat, util.forcebytestr(inst.strerror)))
             continue
         # else: re or relre - which cannot be normalized
         kindpats.append((kind, pat, ''))
     return kindpats
 
 class basematcher(object):
 
     def __init__(self, root, cwd, badfn=None, relativeuipath=True):
@@ -423,17 +424,17 @@ class includematcher(basematcher):
         return ('.' in self._roots or
                 dir in self._roots or
                 dir in self._dirs or
                 any(parentdir in self._roots
                     for parentdir in util.finddirs(dir)))
 
     @encoding.strmethod
     def __repr__(self):
-        return ('<includematcher includes=%r>' % self._pats)
+        return ('<includematcher includes=%r>' % pycompat.bytestr(self._pats))
 
 class exactmatcher(basematcher):
     '''Matches the input files exactly. They are interpreted as paths, not
     patterns (so no kind-prefixes).
     '''
 
     def __init__(self, root, cwd, files, badfn=None):
         super(exactmatcher, self).__init__(root, cwd, badfn)