ignore: move bad file handling out of readignorefile
authorDurham Goode <durham@fb.com>
Sat, 16 May 2015 15:37:59 -0700
changeset 25164 1e86bb282c71
parent 25163 3139900f31b1
child 25165 581e2066d802
ignore: move bad file handling out of readignorefile In preparation for moving readignorefile to match.py to make it more generally usable, let's move the bad ignore file handling up to the ignore specific logic.
mercurial/ignore.py
--- a/mercurial/ignore.py	Sat May 16 15:24:43 2015 -0700
+++ b/mercurial/ignore.py	Sat May 16 15:37:59 2015 -0700
@@ -56,16 +56,11 @@
     return patterns, warnings
 
 def readignorefile(filepath, warn):
-    try:
-        pats = []
-        fp = open(filepath)
-        pats, warnings = ignorepats(fp)
-        fp.close()
-        for warning in warnings:
-            warn("%s: %s\n" % (filepath, warning))
-    except IOError, inst:
-        warn(_("skipping unreadable ignore file '%s': %s\n") %
-             (filepath, inst.strerror))
+    fp = open(filepath)
+    pats, warnings = ignorepats(fp)
+    fp.close()
+    for warning in warnings:
+        warn("%s: %s\n" % (filepath, warning))
     return pats
 
 def readpats(root, files, warn):
@@ -75,7 +70,11 @@
     for f in files:
         if f in pats:
             continue
-        pats[f] = readignorefile(f, warn)
+        try:
+            pats[f] = readignorefile(f, warn)
+        except IOError, inst:
+            warn(_("skipping unreadable ignore file '%s': %s\n") %
+                 (f, inst.strerror))
 
     return [(f, pats[f]) for f in files if f in pats]