Fix re: and glob: patterns in .hgignore (reported by Brad Schick)
authorThomas Arendsen Hein <thomas@intevation.de>
Mon, 30 Jul 2007 20:01:16 +0200
changeset 5029 ac97e065cfc7
parent 4997 60c54154ec4c
child 5030 c89671c3b062
child 5042 f191bc3916f7
child 5048 8db8e1100f3f
Fix re: and glob: patterns in .hgignore (reported by Brad Schick) relglob: and relre: were already detected for a long time, so I kept this undocumented functionality, especially as it was already tested in test-hgignore.
mercurial/ignore.py
tests/test-hgignore
tests/test-hgignore.out
--- a/mercurial/ignore.py	Thu Jul 26 11:19:53 2007 -0500
+++ b/mercurial/ignore.py	Mon Jul 30 20:01:16 2007 +0200
@@ -57,10 +57,13 @@
                         warn(_("%s: ignoring invalid syntax '%s'\n") % (f, s))
                     continue
                 pat = syntax + line
-                for s in syntaxes.values():
-                    if line.startswith(s):
+                for s, rels in syntaxes.items():
+                    if line.startswith(rels):
                         pat = line
                         break
+                    elif line.startswith(s+':'):
+                        pat = rels + line[len(s)+1:]
+                        break
                 pats[f].append(pat)
         except IOError, inst:
             if f != files[0]:
--- a/tests/test-hgignore	Thu Jul 26 11:19:53 2007 -0500
+++ b/tests/test-hgignore	Mon Jul 30 20:01:16 2007 +0200
@@ -40,12 +40,15 @@
 echo ".*\.o" > .hgignore
 echo "--" ; hg status
 
-# XXX: broken
-#echo "glob:**.o" > .hgignore
-#echo "--" ; hg status
-#
-#echo "glob:*.o" > .hgignore
-#echo "--" ; hg status
+echo "glob:**.o" > .hgignore
+echo "--" ; hg status
+
+echo "glob:*.o" > .hgignore
+echo "--" ; hg status
+
+echo "syntax: glob" > .hgignore
+echo "re:.*\.o" >> .hgignore
+echo "--" ; hg status
 
 echo "syntax: invalid" > .hgignore
 echo "--" ; hg status 2>&1 | sed -e 's/.*\.hgignore:/.hgignore:/'
--- a/tests/test-hgignore.out	Thu Jul 26 11:19:53 2007 -0500
+++ b/tests/test-hgignore.out	Mon Jul 30 20:01:16 2007 +0200
@@ -14,6 +14,21 @@
 ? a.c
 ? syntax
 --
+A dir/b.o
+? .hgignore
+? a.c
+? syntax
+--
+A dir/b.o
+? .hgignore
+? a.c
+? syntax
+--
+A dir/b.o
+? .hgignore
+? a.c
+? syntax
+--
 .hgignore: ignoring invalid syntax 'invalid'
 A dir/b.o
 ? .hgignore