changeset 18087:5712e3b12274

ignore: refactor ignore into two functions This prepares us for eventually being able to hash the list of patterns in use.
author Bryan O'Sullivan <bryano@fb.com>
date Mon, 17 Dec 2012 16:23:37 -0800
parents 739c88ff043c
children 52620e5db2f6
files mercurial/ignore.py
diffstat 1 files changed, 19 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/ignore.py	Mon Dec 10 18:12:41 2012 +0100
+++ b/mercurial/ignore.py	Mon Dec 17 16:23:37 2012 -0800
@@ -52,6 +52,24 @@
 
     return patterns, warnings
 
+def readpats(root, files, warn):
+    '''return a dict mapping ignore-file-name to list-of-patterns'''
+
+    pats = {}
+    for f in files:
+        try:
+            pats[f] = []
+            fp = open(f)
+            pats[f], warnings = ignorepats(fp)
+            fp.close()
+            for warning in warnings:
+                warn("%s: %s\n" % (f, warning))
+        except IOError, inst:
+            if f != files[0]:
+                warn(_("skipping unreadable ignore file '%s': %s\n") %
+                     (f, inst.strerror))
+    return pats
+
 def ignore(root, files, warn):
     '''return matcher covering patterns in 'files'.
 
@@ -72,19 +90,7 @@
     glob:pattern   # non-rooted glob
     pattern        # pattern of the current default type'''
 
-    pats = {}
-    for f in files:
-        try:
-            pats[f] = []
-            fp = open(f)
-            pats[f], warnings = ignorepats(fp)
-            fp.close()
-            for warning in warnings:
-                warn("%s: %s\n" % (f, warning))
-        except IOError, inst:
-            if f != files[0]:
-                warn(_("skipping unreadable ignore file '%s': %s\n") %
-                     (f, inst.strerror))
+    pats = readpats(root, files, warn)
 
     allpats = []
     for patlist in pats.values():