mercurial/narrowspec.py
changeset 48777 eb9c55453249
parent 48390 322525db4c98
child 48875 6000f5b25c9b
--- a/mercurial/narrowspec.py	Tue Feb 15 20:24:46 2022 -0800
+++ b/mercurial/narrowspec.py	Tue Feb 15 13:32:11 2022 -0500
@@ -109,23 +109,24 @@
     and patterns that are loaded from sources that use the internal,
     prefixed pattern representation (but can't necessarily be fully trusted).
     """
-    if not isinstance(pats, set):
-        raise error.ProgrammingError(
-            b'narrow patterns should be a set; got %r' % pats
-        )
+    with util.timedcm('narrowspec.validatepatterns(pats size=%d)', len(pats)):
+        if not isinstance(pats, set):
+            raise error.ProgrammingError(
+                b'narrow patterns should be a set; got %r' % pats
+            )
 
-    for pat in pats:
-        if not pat.startswith(VALID_PREFIXES):
-            # Use a Mercurial exception because this can happen due to user
-            # bugs (e.g. manually updating spec file).
-            raise error.Abort(
-                _(b'invalid prefix on narrow pattern: %s') % pat,
-                hint=_(
-                    b'narrow patterns must begin with one of '
-                    b'the following: %s'
+        for pat in pats:
+            if not pat.startswith(VALID_PREFIXES):
+                # Use a Mercurial exception because this can happen due to user
+                # bugs (e.g. manually updating spec file).
+                raise error.Abort(
+                    _(b'invalid prefix on narrow pattern: %s') % pat,
+                    hint=_(
+                        b'narrow patterns must begin with one of '
+                        b'the following: %s'
+                    )
+                    % b', '.join(VALID_PREFIXES),
                 )
-                % b', '.join(VALID_PREFIXES),
-            )
 
 
 def format(includes, excludes):