[PATCH 3 of 6] ignore: move bad file handling out of readignorefile

Durham Goode durham at fb.com
Mon May 18 18:28:59 UTC 2015


# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1431815879 25200
#      Sat May 16 15:37:59 2015 -0700
# Node ID d74b5e7ce361d09fc240c68e3c5eaec89ae2c92f
# Parent  f0bebbe084ce886b7b42999d2f8b82cc6d4b6523
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.

diff --git a/mercurial/ignore.py b/mercurial/ignore.py
--- a/mercurial/ignore.py
+++ b/mercurial/ignore.py
@@ -54,15 +54,10 @@ def ignorepats(lines):
 
     return patterns
 
-def readignorefile(filepath, warn):
-    try:
-        pats = []
-        fp = open(filepath)
-        pats = ignorepats(fp)
-        fp.close()
-    except IOError, inst:
-        warn(_("skipping unreadable ignore file '%s': %s\n") %
-             (filepath, inst.strerror))
+def readignorefile(filepath):
+    fp = open(filepath)
+    pats = ignorepats(fp)
+    fp.close()
     return pats
 
 def readpats(root, files, warn):
@@ -72,7 +67,11 @@ def readpats(root, files, warn):
     for f in files:
         if f in pats:
             continue
-        pats[f] = readignorefile(f, warn)
+        try:
+            pats[f] = readignorefile(f)
+        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]
 



More information about the Mercurial-devel mailing list