ignore: refactor ignore into two functions
authorBryan O'Sullivan <bryano@fb.com>
Mon, 17 Dec 2012 16:23:37 -0800
changeset 18087 5712e3b12274
parent 18086 739c88ff043c
child 18088 52620e5db2f6
ignore: refactor ignore into two functions This prepares us for eventually being able to hash the list of patterns in use.
mercurial/ignore.py
--- 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():