Comments
Patch
@@ -7,11 +7,11 @@
from i18n import _
import util, match
-import re
+import os, re
_commentre = None
-def ignorepats(lines):
+def ignorepats(ui, root, filepath):
'''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.'''
@@ -20,7 +20,9 @@ def ignorepats(lines):
patterns = []
warnings = []
- for line in lines:
+ fp = open(filepath)
+
+ for line in fp:
if "#" in line:
global _commentre
if not _commentre:
@@ -53,14 +55,13 @@ def ignorepats(lines):
break
patterns.append(linesyntax + line)
+ fp.close()
return patterns, warnings
-def readignorefile(ui, filepath, skipwarning=False):
+def readignorefile(ui, root, filepath, skipwarning=False):
try:
pats = []
- fp = open(filepath)
- pats, warnings = ignorepats(fp)
- fp.close()
+ pats, warnings = ignorepats(ui, root, filepath)
for warning in warnings:
ui.warn("%s: %s\n" % (filepath, warning))
except IOError, inst:
@@ -77,7 +78,8 @@ def readpats(ui, root, files):
if f in pats:
continue
skipwarning = f == files[0]
- pats[f] = readignorefile(ui, f, skipwarning=skipwarning)
+ fullpath = os.path.normpath(os.path.join(root, f))
+ pats[f] = readignorefile(ui, root, fullpath, skipwarning=skipwarning)
return [(f, pats[f]) for f in files if f in pats]