Best way to check if a directory is an brz branch

John Arbash Meinel john at arbash-meinel.com
Tue Feb 17 16:17:40 GMT 2009


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

Nicholas Allen wrote:
> 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
> 


bzrlib doesn't have it, because we haven't needed it. If there is a
branch, then we want to do something with it. So Branch.open() works
exactly for what we want to do.

Similarly for the existing plugins (at least the ones I've worked on).

As for doing "os.path.isdir()", etc. It depends if you want to support
".svn" branches if you have bzr-svn installed (similarly for hg branches
with bzr-hg, etc when those plugins have been fleshed out a bit better).

os.path.isdir('.bzr/branch') is certainly going to be the *fastest*, and
will find the 90% of cases where you only care about current-format bzr
branches. (There are some really old formats that did not have a
separate .bzr/branch/ directory, but I don't think you care about them.)

You are welcome to propose a patch, write some tests, and get something
merged into bzrlib. I'm not sure that bzr itself will have any use for
that sort of function. Also, if there is a "broken branch" does that
count as a real branch?

I don't know exactly what functionality you want, or how you are
defining a "real branch". Care to explain a bit more as to why you want
to know that a branch exists, but not actually do anything with the
branch object?

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkma4yQACgkQJdeBCYSNAAMzvwCZAZjwsrdilBPa/4zWSy37oMak
7ZwAoNBrUfuMt8gbPuptfHgAKoBNa8IS
=++aq
-----END PGP SIGNATURE-----



More information about the bazaar mailing list