Best way to check if a directory is an brz branch

Nicholas Allen nick.allen at onlinehome.de
Tue Feb 17 12:03:36 GMT 2009


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


> 
> You canb try to open it, and catch the NotBranchError.
> 
> from bzrlib.errors import NotBranchError
> from bzrlib.branch import Branch
> try:
>     b = Branch.open(dir)
>     # do something if it is a branch...
> except NotBranchError:
>     # do something else or pass if not a branch
> 

It would be nice to have that contained inside a method is_branch that
did this for you. That way you can use it in expressions and if statements.

I think the BzrLib should have such a function.

Cheers,

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

iEYEARECAAYFAkmap5gACgkQ1+i51gqqEGlC3ACeIItd0+WJIPmAxmsGF6aJ56Dr
EZsAnRdQu2EkeXce3gguIRl3pS6VSp0/
=f8SS
-----END PGP SIGNATURE-----



More information about the bazaar mailing list