Best way to check if a file matches an ignore pattern
John Arbash Meinel
john at arbash-meinel.com
Sun Sep 7 15:27:40 BST 2008
-----BEGIN PGP SIGNED MESSAGE-----
Nicholas Allen wrote:
> Sorry, I was not clear enough - I meant from the command line. I need it
> for my Eclipse plugin (which is written in Java) so I need some way to
> detect this by invoking bzr commands...
> Mark Hammond wrote:
>>> How can I check if a file matches an ignore pattern?
>> Use the tree.is_ignored() method.
echo > ~/.bazaar/plugins/is_ignored.py <<EOF
from bzrlib import commands, workingtree
"""Check to see if a path would be ignored."""
takes_args = ['filename']
def run(self, filename):
tree, relpath = \
except (errors.NoWorkingTree, errors.NotBranchError):
# Either a branch without a working tree, or no branch at all
# That can't really be considered ignored
if tree.path2id(relpath) is not None:
# Versioned files are never ignored
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the bazaar