[Pkg-bazaar-commits] ./bzr/unstable r4: match ignore patterns against only the last path component

mbp at sourcefrog.net mbp at sourcefrog.net
Fri Apr 10 07:24:22 UTC 2009


------------------------------------------------------------
revno: 4
committer: mbp at sourcefrog.net
timestamp: Wed 2005-03-09 04:15:02 +0000
message:
  match ignore patterns against only the last path component
  unless a path is given
modified:
  bzrlib/tree.py
-------------- next part --------------
=== modified file 'bzrlib/tree.py'
--- a/bzrlib/tree.py	2005-03-09 04:08:15 +0000
+++ b/bzrlib/tree.py	2005-03-09 04:15:02 +0000
@@ -258,14 +258,20 @@
 
 
     def is_ignored(self, filename):
-        """Check whether the filename matches an ignore pattern."""
+        """Check whether the filename matches an ignore pattern.
+
+        Patterns containing '/' need to match the whole path; others
+        match against only the last component."""
         ## TODO: Take them from a file, not hardcoded
         ## TODO: Use extended zsh-style globs maybe?
         ## TODO: Use '**' to match directories?
-        ## TODO: Patterns without / should match in subdirectories?
-        for i in bzrlib.DEFAULT_IGNORE:
-            if fnmatch.fnmatchcase(filename, i):
-                return True
+        for pat in bzrlib.DEFAULT_IGNORE:
+            if '/' in pat:
+                if fnmatch.fnmatchcase(filename, pat):
+                    return True
+            else:
+                if fnmatch.fnmatchcase(splitpath(filename)[-1], pat):
+                    return True
         return False
         
 



More information about the Pkg-bazaar-commits mailing list