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

login
register
mail settings
Submitter Durham Goode
Date May 18, 2015, 6:28 p.m.
Message ID <d74b5e7ce361d09fc240.1431973739@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/9141/
State Accepted
Headers show

Comments

Durham Goode - May 18, 2015, 6:28 p.m.
# HG changeset patch
# User Durham Goode <durham@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.

Patch

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]