Patchwork D3471: minifileset: fix on Python 3

login
register
mail settings
Submitter phabricator
Date May 8, 2018, 4:27 a.m.
Message ID <differential-rev-PHID-DREV-nbzhhbsr2w5aahfbnq3v-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/31324/
State Superseded
Headers show

Comments

phabricator - May 8, 2018, 4:27 a.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Found by porting test-minifileset.py to Python 3.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3471

AFFECTED FILES
  mercurial/minifileset.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/minifileset.py b/mercurial/minifileset.py
--- a/mercurial/minifileset.py
+++ b/mercurial/minifileset.py
@@ -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:"'))