Fastest way to find repository heads?

John Arbash Meinel john at arbash-meinel.com
Wed Jul 8 23:27:29 BST 2009


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

Jelmer Vernooij wrote:
> When talking to a git smart server and trying to figure out which
> revisions to fetch, bzr-git has to provide the server with all of the
> heads in the repository so that the client and the server can negotiate
> which revisions have to be transferred.
> 
> What is the best way of doing this? At the moment I'm using this:
> 
> heads = repo.get_graph().heads(repo.all_revision_ids())
> 
> But this is taking quite some time for large repositories, is there
> perhaps a more efficient way of doing this?
> 
> Alternatively, I guess the repository could store this information, but
> that would obviously require a new repository format.
> 
> Cheers,
> 
> Jelmer

I'll mention that KnownGraph is probably a lot better about this. So doing:

all_revs = repo.all_revision_ids()
parent_map = repo.get_parent_map(all_revs)
graph = graph.KnownGraph(parent_map)
heads = graph.heads(all_revs)

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

iEYEARECAAYFAkpVHVEACgkQJdeBCYSNAAPXzQCfbOXalHs/AjCmTFYSkXGkvM6X
56YAn3+hO1+H9LriLU8UxY/mBXEYmkbd
=gSte
-----END PGP SIGNATURE-----



More information about the bazaar mailing list