Patchwork [3,of,8,match] match: _globre doctests

login
register
mail settings
Submitter Mads Kiilerich
Date April 15, 2014, 12:40 a.m.
Message ID <a1eeacd999bf8bc79b95.1397522437@mk-desktop>
Download mbox | patch
Permalink /patch/4355/
State Accepted
Commit 03782d2fc7764186ce06f864e6819880d8695b9e
Headers show

Comments

Mads Kiilerich - April 15, 2014, 12:40 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1397419208 -7200
#      Sun Apr 13 22:00:08 2014 +0200
# Node ID a1eeacd999bf8bc79b9585a010cf22e531827bbd
# Parent  6f98a143adb15ae578df3414a04ecf5c48838d2a
match: _globre doctests

Patch

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -228,7 +228,21 @@  def _patsplit(pattern, default):
     return default, pattern
 
 def _globre(pat):
-    '''Convert an extended glob string to a regexp string.'''
+    r'''Convert an extended glob string to a regexp string.
+
+    >>> print _globre(r'?')
+    .
+    >>> print _globre(r'*')
+    [^/]*
+    >>> print _globre(r'**')
+    .*
+    >>> print _globre(r'[a*?!^][^b][!c]')
+    [a*?!^][\^b][^c]
+    >>> print _globre(r'{a,b}')
+    (?:a|b)
+    >>> print _globre(r'.\*\?')
+    \.\*\?
+    '''
     i, n = 0, len(pat)
     res = ''
     group = 0