Best way to check if a file matches an ignore pattern

Aaron Bentley aaron at aaronbentley.com
Sun Sep 7 15:50:51 BST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Nicholas Allen wrote:
> Sorry, I was not clear enough - I meant from the command line.

What makes you think you can't use bzrlib from the commandline? :-)

$python -c "import sys
from bzrlib import workingtree, errors
try:
    tree, relpath = workingtree.WorkingTree.open_containing(sys.argv[1])
except (errors.NoWorkingTree, errors.NotBranchError):
    sys.exit(3)
if tree.path2id(relpath):
    sys.exit(0)
elif tree.is_ignored(relpath):
    sys.exit(1)
else:
    sys.exit(0)
" bzrr.pyc

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIw+pL0F+nu1YWqI0RArnsAJwI6+J6NJBAZvEdQoX5TofM2g8SbQCfaidz
x+ORVC7+KT6ACwTtzq0x71s=
=ur+G
-----END PGP SIGNATURE-----



More information about the bazaar mailing list