[PATCH 4 of 8] ignore: remove redundant warn argument

Durham Goode durham at fb.com
Wed May 13 10:13:18 CDT 2015


# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1431468960 25200
#      Tue May 12 15:16:00 2015 -0700
# Node ID 8bd4aa1146eca2364986ef2a17fbf88ed7cfcdb6
# Parent  5af3cb8572c462a3f21c45f7f8d9fdb0289dd373
ignore: remove redundant warn argument

Now that we're passing the ui around, we don't need to pass a warn function
around with it.

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -149,7 +149,7 @@ class dirstate(object):
                 # we need to use os.path.join here rather than self._join
                 # because path is arbitrary and user-specified
                 files.append(os.path.join(self._rootdir, util.expandpath(path)))
-        return ignore.ignore(self._ui, self._root, files, self._ui.warn)
+        return ignore.ignore(self._ui, self._root, files)
 
     @propertycache
     def _slash(self):
diff --git a/mercurial/ignore.py b/mercurial/ignore.py
--- a/mercurial/ignore.py
+++ b/mercurial/ignore.py
@@ -55,21 +55,21 @@ def ignorepats(lines):
 
     return patterns, warnings
 
-def readignorefile(ui, filepath, warn, skipwarning=False):
+def readignorefile(ui, filepath, skipwarning=False):
     try:
         pats = []
         fp = open(filepath)
         pats, warnings = ignorepats(fp)
         fp.close()
         for warning in warnings:
-            warn("%s: %s\n" % (filepath, warning))
+            ui.warn("%s: %s\n" % (filepath, warning))
     except IOError, inst:
         if not skipwarning:
-            warn(_("skipping unreadable ignore file '%s': %s\n") %
+            ui.warn(_("skipping unreadable ignore file '%s': %s\n") %
                  (filepath, inst.strerror))
     return pats
 
-def readpats(ui, root, files, warn):
+def readpats(ui, root, files):
     '''return a dict mapping ignore-file-name to list-of-patterns'''
 
     pats = {}
@@ -77,11 +77,11 @@ def readpats(ui, root, files, warn):
         if f in pats:
             continue
         skipwarning = f == files[0]
-        pats[f] = readignorefile(ui, f, warn, skipwarning=skipwarning)
+        pats[f] = readignorefile(ui, f, skipwarning=skipwarning)
 
     return [(f, pats[f]) for f in files if f in pats]
 
-def ignore(ui, root, files, warn):
+def ignore(ui, root, files):
     '''return matcher covering patterns in 'files'.
 
     the files parsed for patterns include:
@@ -101,7 +101,7 @@ def ignore(ui, root, files, warn):
     glob:pattern   # non-rooted glob
     pattern        # pattern of the current default type'''
 
-    pats = readpats(ui, root, files, warn)
+    pats = readpats(ui, root, files)
 
     allpats = []
     for f, patlist in pats:


More information about the Mercurial-devel mailing list