Best way to check if a directory is an brz branch

Jelmer Vernooij jelmer at
Tue Feb 17 12:09:33 GMT 2009

On Tue, 2009-02-17 at 12:51 +0100, Nicholas Allen wrote:
> I'm wondering what's the best way to check if a directory on the file
> system is a Bazaar branch. At the moment I do something like:
> if os.path.isdir(os.path.join(directory, '.bzr/branch')):
> but this seems overly tied to the implementation details of Bazaar. I
> couldn't find a method to do this. One way would be to try to open a
> branch for a directory and catch exceptions but that seems inefficient
> and would also fail if there was a problem with the branch itself.
> I expected a static method in Branch or BzrDir to check this. eg
> is_branch(directory).
See bzrlib.bzrdir.BzrDir.has_branch().


Jelmer Vernooij <jelmer at> -
Jabber: jelmer at

More information about the bazaar mailing list