[PATCH 3 of 8] ignore: add ui to ignore stack

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


# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1431468882 25200
#      Tue May 12 15:14:42 2015 -0700
# Node ID 5af3cb8572c462a3f21c45f7f8d9fdb0289dd373
# Parent  1236d101b01d251715016df1b0ba53d3a37edfb8
ignore: add ui to ignore stack

In a future patch we will need access to the ui.config inside the ignore logic.
This patch adds it to the functions.  A future patch will also remove the
redundant 'warn' variable here.

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._root, files, self._ui.warn)
+        return ignore.ignore(self._ui, self._root, files, self._ui.warn)
 
     @propertycache
     def _slash(self):
diff --git a/mercurial/ignore.py b/mercurial/ignore.py
--- a/mercurial/ignore.py
+++ b/mercurial/ignore.py
@@ -55,7 +55,7 @@ def ignorepats(lines):
 
     return patterns, warnings
 
-def readignorefile(filepath, warn, skipwarning=False):
+def readignorefile(ui, filepath, warn, skipwarning=False):
     try:
         pats = []
         fp = open(filepath)
@@ -69,7 +69,7 @@ def readignorefile(filepath, warn, skipw
                  (filepath, inst.strerror))
     return pats
 
-def readpats(root, files, warn):
+def readpats(ui, root, files, warn):
     '''return a dict mapping ignore-file-name to list-of-patterns'''
 
     pats = {}
@@ -77,11 +77,11 @@ def readpats(root, files, warn):
         if f in pats:
             continue
         skipwarning = f == files[0]
-        pats[f] = readignorefile(f, warn, skipwarning=skipwarning)
+        pats[f] = readignorefile(ui, f, warn, skipwarning=skipwarning)
 
     return [(f, pats[f]) for f in files if f in pats]
 
-def ignore(root, files, warn):
+def ignore(ui, root, files, warn):
     '''return matcher covering patterns in 'files'.
 
     the files parsed for patterns include:
@@ -101,7 +101,7 @@ def ignore(root, files, warn):
     glob:pattern   # non-rooted glob
     pattern        # pattern of the current default type'''
 
-    pats = readpats(root, files, warn)
+    pats = readpats(ui, root, files, warn)
 
     allpats = []
     for f, patlist in pats:


More information about the Mercurial-devel mailing list