changeset 21816:212955411633

merge with stable
author Matt Mackall <mpm@selenic.com>
date Fri, 27 Jun 2014 15:20:50 -0700
parents 5125856a28cf (current diff) a4b67bf1f0a5 (diff)
children 6b0275e5f276
files
diffstat 2 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/match.py	Sun Feb 23 03:13:21 2014 +0100
+++ b/mercurial/match.py	Fri Jun 27 15:20:50 2014 -0700
@@ -233,6 +233,10 @@
     [^/]*
     >>> print _globre(r'**')
     .*
+    >>> print _globre(r'**/a')
+    (?:.*/)?a
+    >>> print _globre(r'a/**/b')
+    a\/(?:.*/)?b
     >>> print _globre(r'[a*?!^][^b][!c]')
     [a*?!^][\^b][^c]
     >>> print _globre(r'{a,b}')
@@ -254,7 +258,11 @@
         elif c == '*':
             if peek() == '*':
                 i += 1
-                res += '.*'
+                if peek() == '/':
+                    i += 1
+                    res += '(?:.*/)?'
+                else:
+                    res += '.*'
             else:
                 res += '[^/]*'
         elif c == '?':
--- a/tests/test-hgignore.t	Sun Feb 23 03:13:21 2014 +0100
+++ b/tests/test-hgignore.t	Fri Jun 27 15:20:50 2014 -0700
@@ -134,3 +134,17 @@
   ? a.c
   ? a.o
   ? syntax
+
+Check recursive glob pattern matches no directories (dir/**/c.o matches dir/c.o)
+
+  $ echo "syntax: glob" > .hgignore
+  $ echo "dir/**/c.o" >> .hgignore
+  $ touch dir/c.o
+  $ mkdir dir/subdir
+  $ touch dir/subdir/c.o
+  $ hg status
+  A dir/b.o
+  ? .hgignore
+  ? a.c
+  ? a.o
+  ? syntax