Best way to check if a directory is an brz branch

Nicholas Allen nick.allen at onlinehome.de
Tue Feb 17 14:57:21 GMT 2009


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

Hi Vincent,

Yes I realize this should work but I think it should be a method in
BzrLib and not something I, or anyone else, should have to code. I'm
sure this method could be coded more efficiently too (eg no need to try
to instantiate and catch exceptions but just check if a certain file
exists).

Nick

> 
> 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.
> 
> Hth,
> 
>         Vincent
> 

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

iEUEARECAAYFAkma0E4ACgkQ1+i51gqqEGmT+wCfcNnD70GrE88cM6Kbwef7r46e
+vgAkwbF6pjMEGNlRx+9pZa+myW8JhQ=
=trR6
-----END PGP SIGNATURE-----



More information about the bazaar mailing list