mercurial/util.py
changeset 5215 b0bc8cf41ffc
parent 5214 316ce5e85b3e
parent 5206 0f6a1bdf89fb
child 5216 335696e2a58f
child 5291 23651848d638
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -476,6 +476,15 @@ def _matcher(canonroot, cwd, names, inc,
         try:
             pat = '(?:%s)' % '|'.join([regex(k, p, tail) for (k, p) in pats])
             return re.compile(pat).match
+        except OverflowError:
+            # We're using a Python with a tiny regex engine and we
+            # made it explode, so we'll divide the pattern list in two
+            # until it works
+            l = len(pats)
+            if l < 2:
+                raise
+            a, b = matchfn(pats[:l/2], tail), matchfn(pats[l/2:], tail)
+            return lambda s: a(s) or b(s)
         except re.error:
             for k, p in pats:
                 try: