changeset 49887:44deb5a164dc

pathutil: slightly faster path audit in the common case
author Arseniy Alekseyev <aalekseyev@janestreet.com>
date Wed, 04 Jan 2023 18:42:20 +0000
parents becd16690cbe
children 445b4d819e9a
files mercurial/pathutil.py
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/pathutil.py	Fri Jan 06 16:01:31 2023 +0000
+++ b/mercurial/pathutil.py	Wed Jan 04 18:42:20 2023 +0000
@@ -90,13 +90,14 @@
                 _(b"path contains illegal component: %s") % path
             )
         # Windows shortname aliases
-        for p in parts:
-            if b"~" in p:
-                first, last = p.split(b"~", 1)
-                if last.isdigit() and first.upper() in [b"HG", b"HG8B6C"]:
-                    raise error.InputError(
-                        _(b"path contains illegal component: %s") % path
-                    )
+        if b"~" in path:
+            for p in parts:
+                if b"~" in p:
+                    first, last = p.split(b"~", 1)
+                    if last.isdigit() and first.upper() in [b"HG", b"HG8B6C"]:
+                        raise error.InputError(
+                            _(b"path contains illegal component: %s") % path
+                        )
         if b'.hg' in _lowerclean(path):
             lparts = [_lowerclean(p) for p in parts]
             for p in b'.hg', b'.hg.':