Comments
Patch
@@ -11,12 +11,16 @@
_commentre = None
-def ignorepats(lines):
+def ignorepats(lines, defaultsyntax = None):
'''parse lines (iterable) of .hgignore text, returning a tuple of
(patterns, parse errors). These patterns should be given to compile()
to be validated and converted into a match function.'''
syntaxes = {'re': 'relre:', 'regexp': 'relre:', 'glob': 'relglob:'}
- syntax = 'relre:'
+ if defaultsyntax:
+ syntax = defaultsyntax
+ else:
+ syntax = 'relre:'
+
patterns = []
warnings = []
@@ -62,7 +66,10 @@
try:
pats[f] = []
fp = open(f)
- pats[f], warnings = ignorepats(fp)
+ defaultsyntax = None
+ if re.search(r'(/|^)\.gitignore$', fp.name):
+ defaultsyntax = 'relglob:'
+ pats[f], warnings = ignorepats(fp, defaultsyntax)
fp.close()
for warning in warnings:
warn("%s: %s\n" % (f, warning))
@@ -124,3 +124,40 @@
(?:(?:|.*/)[^/]*(?:/|$))
$ cd ..
+
+Check ignoring using .gitignore defaults to glob syntax
+
+ $ rm .hgignore
+ $ echo "*.o" > .gitignore
+ $ hg st
+ A dir/b.o
+ ? .gitignore
+ ? a.c
+ ? a.o
+ ? dir/c.o
+ ? syntax
+
+ $ echo "[ui]" > .hg/hgrc
+ $ echo "ignore=.gitignore" >> .hg/hgrc
+ $ hg st
+ A dir/b.o
+ ? .gitignore
+ ? a.c
+ ? syntax
+
+ $ echo ".*\.o" > .gitignore
+ $ hg st
+ A dir/b.o
+ ? .gitignore
+ ? a.c
+ ? a.o
+ ? dir/c.o
+ ? syntax
+
+ $ rm .gitignore
+ $ echo "*.o" > foo.gitignore
+ $ echo "[ui]" > .hg/hgrc
+ $ echo "ignore=foo.gitignore" >> .hg/hgrc
+ $ hg st
+ abort: foo.gitignore: invalid pattern (relre): *.o
+ [255]