[PATCH] Small ignored fix
Thomas Arendsen Hein
thomas at intevation.de
Mon Jul 30 13:02:54 CDT 2007
* Brad Schick <schickb at gmail.com> [20070724 18:24]:
> In the current stable sources, re:pattern and glob:pattern are not
> working in ignore files. Attached is a tiny patch to fix that.
> # HG changeset patch
> # User Brad Schick <schickb at gmail.com>
> # Date 1185082975 25200
> # Node ID 5a4af582c1e778aedb060a87657fa1a14d3fae18
> # Parent 10afa3fab6b4a219cff732d5d2bee354ec4d1166
> fixed problem with glob: and re: lines in ignore files
>
> diff -r 10afa3fab6b4 -r 5a4af582c1e7 mercurial/ignore.py
> --- a/mercurial/ignore.py Sat Jul 21 17:36:45 2007 +0200
> +++ b/mercurial/ignore.py Sat Jul 21 22:42:55 2007 -0700
> @@ -57,7 +57,7 @@ def ignore(root, files, warn):
> warn(_("%s: ignoring invalid syntax '%s'\n") % (f, s))
> continue
> pat = syntax + line
> - for s in syntaxes.values():
> + for s in syntaxes.keys():
> if line.startswith(s):
> pat = line
> break
Thanks for the report.
I'll push a slightly different patch to crew-stable and crew:
# HG changeset patch
# User Thomas Arendsen Hein <thomas at intevation.de>
# Date 1185818476 -7200
# Node ID ac97e065cfc7868311814588c624e21c257ddad8
# Parent 60c54154ec4c764ec2010d5ec21e7918c8a4e4f9
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.
diff -r 60c54154ec4c -r ac97e065cfc7 mercurial/ignore.py
--- 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,9 +57,12 @@ def ignore(root, files, warn):
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:
diff -r 60c54154ec4c -r ac97e065cfc7 tests/test-hgignore
--- 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 ".*\.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:/'
diff -r 60c54154ec4c -r ac97e065cfc7 tests/test-hgignore.out
--- 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
@@ -8,6 +8,21 @@ A dir/b.o
? syntax
--
abort: .hgignore: invalid pattern (relre): *.o
+--
+A dir/b.o
+? .hgignore
+? a.c
+? syntax
+--
+A dir/b.o
+? .hgignore
+? a.c
+? syntax
+--
+A dir/b.o
+? .hgignore
+? a.c
+? syntax
--
A dir/b.o
? .hgignore
--
thomas at intevation.de - http://intevation.de/~thomas/ - OpenPGP key: 0x5816791A
Intevation GmbH, Osnabrueck - Register: Amtsgericht Osnabrueck, HR B 18998
Geschaeftsfuehrer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner
More information about the Mercurial
mailing list