minifileset: fix on Python 3
authorAugie Fackler <augie@google.com>
Fri, 27 Apr 2018 00:13:56 -0400
changeset 37876 9c98cb30f4de
parent 37875 078c3eec2d5c
child 37877 2cdae2582d8a
minifileset: fix on Python 3 Found by porting test-minifileset.py to Python 3. Differential Revision: https://phab.mercurial-scm.org/D3471
mercurial/minifileset.py
--- a/mercurial/minifileset.py	Fri Apr 27 00:08:48 2018 -0400
+++ b/mercurial/minifileset.py	Fri Apr 27 00:13:56 2018 -0400
@@ -11,6 +11,7 @@
 from . import (
     error,
     fileset,
+    pycompat,
 )
 
 def _compile(tree):
@@ -21,14 +22,15 @@
         name = fileset.getpattern(tree, {'path'}, _('invalid file pattern'))
         if name.startswith('**'): # file extension test, ex. "**.tar.gz"
             ext = name[2:]
-            for c in ext:
+            for c in pycompat.bytestr(ext):
                 if c in '*{}[]?/\\':
                     raise error.ParseError(_('reserved character: %s') % c)
             return lambda n, s: n.endswith(ext)
         elif name.startswith('path:'): # directory or full path test
             p = name[5:] # prefix
             pl = len(p)
-            f = lambda n, s: n.startswith(p) and (len(n) == pl or n[pl] == '/')
+            f = lambda n, s: n.startswith(p) and (len(n) == pl
+                                                  or n[pl:pl + 1] == '/')
             return f
         raise error.ParseError(_("unsupported file pattern: %s") % name,
                                hint=_('paths must be prefixed with "path:"'))