Best way to check if a directory is an brz branch
Nicholas Allen
nick.allen at onlinehome.de
Tue Feb 17 18:16:53 GMT 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
>
> def is_branch(p):
> from bzrlib import (branch, errors)
> try:
> br, relpath = branch.Branch.open_containing(p)
> except errors.NotBranchError:
> return False
> if relpath != '':
> return False
> else:
> return True
>
> should work.
Would I not need to catch other exceptions too? What if it is a branch
but there is a problem opening it? How do I know what open_containing(p)
will throw?
With Python being so lenient and unverbose about everything it makes
obtaining this information much harder. I really wish Bazaar had been
written in Java ;-)
Nick
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkma/xIACgkQ1+i51gqqEGkCOACdFfyF8Nf8YbYtZZGzEpeak63e
/zoAniFACxe0TcsvJcfZ2T8ueJzIfe5n
=kjM4
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list