mercurial/util.py
changeset 21914 10e99839a7a4
parent 21913 50aad4609224
child 22245 234e4c24b980
--- a/mercurial/util.py	Tue Jul 15 15:01:52 2014 -0700
+++ b/mercurial/util.py	Tue Jul 15 15:14:45 2014 -0700
@@ -744,6 +744,21 @@
                 pass
         return remod.compile(pat, flags)
 
+    @propertycache
+    def escape(self):
+        '''Return the version of escape corresponding to self.compile.
+
+        This is imperfect because whether re2 or re is used for a particular
+        function depends on the flags, etc, but it's the best we can do.
+        '''
+        global _re2
+        if _re2 is None:
+            self._checkre2()
+        if _re2:
+            return re2.escape
+        else:
+            return remod.escape
+
 re = _re()
 
 _fspathcache = {}