From patchwork Tue Apr 15 00:40:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3,of,8,match] match: _globre doctests From: Mads Kiilerich X-Patchwork-Id: 4355 Message-Id: To: mercurial-devel@selenic.com Date: Tue, 15 Apr 2014 02:40:37 +0200 # HG changeset patch # User Mads Kiilerich # Date 1397419208 -7200 # Sun Apr 13 22:00:08 2014 +0200 # Node ID a1eeacd999bf8bc79b9585a010cf22e531827bbd # Parent 6f98a143adb15ae578df3414a04ecf5c48838d2a match: _globre doctests 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