diff mercurial/pathutil.py @ 43077:687b865b95ad

formatting: byteify all mercurial/ and hgext/ string literals Done with python3.7 contrib/byteify-strings.py -i $(hg files 'set:mercurial/**.py - mercurial/thirdparty/** + hgext/**.py - hgext/fsmonitor/pywatchman/** - mercurial/__init__.py') black -l 80 -t py33 -S $(hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**" - hgext/fsmonitor/pywatchman/**') # skip-blame mass-reformatting only Differential Revision: https://phab.mercurial-scm.org/D6972
author Augie Fackler <augie@google.com>
date Sun, 06 Oct 2019 09:48:39 -0400
parents 2372284d9457
children c21aca51b392
line wrap: on
line diff
--- a/mercurial/pathutil.py	Sun Oct 06 09:45:02 2019 -0400
+++ b/mercurial/pathutil.py	Sun Oct 06 09:48:39 2019 -0400
@@ -63,30 +63,30 @@
             return
         # AIX ignores "/" at end of path, others raise EISDIR.
         if util.endswithsep(path):
-            raise error.Abort(_("path ends in directory separator: %s") % path)
+            raise error.Abort(_(b"path ends in directory separator: %s") % path)
         parts = util.splitpath(path)
         if (
             os.path.splitdrive(path)[0]
-            or _lowerclean(parts[0]) in ('.hg', '.hg.', '')
+            or _lowerclean(parts[0]) in (b'.hg', b'.hg.', b'')
             or pycompat.ospardir in parts
         ):
-            raise error.Abort(_("path contains illegal component: %s") % path)
+            raise error.Abort(_(b"path contains illegal component: %s") % path)
         # Windows shortname aliases
         for p in parts:
-            if "~" in p:
-                first, last = p.split("~", 1)
-                if last.isdigit() and first.upper() in ["HG", "HG8B6C"]:
+            if b"~" in p:
+                first, last = p.split(b"~", 1)
+                if last.isdigit() and first.upper() in [b"HG", b"HG8B6C"]:
                     raise error.Abort(
-                        _("path contains illegal component: %s") % path
+                        _(b"path contains illegal component: %s") % path
                     )
-        if '.hg' in _lowerclean(path):
+        if b'.hg' in _lowerclean(path):
             lparts = [_lowerclean(p.lower()) for p in parts]
-            for p in '.hg', '.hg.':
+            for p in b'.hg', b'.hg.':
                 if p in lparts[1:]:
                     pos = lparts.index(p)
                     base = os.path.join(*parts[:pos])
                     raise error.Abort(
-                        _("path '%s' is inside nested repo %r")
+                        _(b"path '%s' is inside nested repo %r")
                         % (path, pycompat.bytestr(base))
                     )
 
@@ -126,16 +126,16 @@
                 raise
         else:
             if stat.S_ISLNK(st.st_mode):
-                msg = _('path %r traverses symbolic link %r') % (
+                msg = _(b'path %r traverses symbolic link %r') % (
                     pycompat.bytestr(path),
                     pycompat.bytestr(prefix),
                 )
                 raise error.Abort(msg)
             elif stat.S_ISDIR(st.st_mode) and os.path.isdir(
-                os.path.join(curpath, '.hg')
+                os.path.join(curpath, b'.hg')
             ):
                 if not self.callback or not self.callback(curpath):
-                    msg = _("path '%s' is inside nested repo %r")
+                    msg = _(b"path '%s' is inside nested repo %r")
                     raise error.Abort(msg % (path, pycompat.bytestr(prefix)))
 
     def check(self, path):
@@ -203,7 +203,7 @@
         auditor(name)
         return util.pconvert(name)
     elif name == root:
-        return ''
+        return b''
     else:
         # Determine whether `name' is in the hierarchy at or beneath `root',
         # by iterating name=dirname(name) until that causes no change (can't
@@ -219,7 +219,7 @@
             if s:
                 if not rel:
                     # name was actually the same as root (maybe a symlink)
-                    return ''
+                    return b''
                 rel.reverse()
                 name = os.path.join(*rel)
                 auditor(name)
@@ -236,15 +236,15 @@
         try:
             if cwd != root:
                 canonpath(root, root, myname, auditor)
-                relpath = util.pathto(root, cwd, '')
+                relpath = util.pathto(root, cwd, b'')
                 if relpath.endswith(pycompat.ossep):
                     relpath = relpath[:-1]
-                hint = _("consider using '--cwd %s'") % relpath
+                hint = _(b"consider using '--cwd %s'") % relpath
         except error.Abort:
             pass
 
         raise error.Abort(
-            _("%s not under root '%s'") % (myname, root), hint=hint
+            _(b"%s not under root '%s'") % (myname, root), hint=hint
         )