New public Graph.revision_relation method

Martin von Gagern Martin.vGagern at gmx.net
Wed Dec 9 08:47:52 GMT 2009


Hi!

I'm looking for a public interface to cheaply test the relation between
two revisions, i.e. "a is an ancestor of b", "b is an ancestor of a" or
"neither is an ancestor of the other".

There is a method Branch._revision_relations which performs such a test
and requires the graph as an argument. And of course there is
Graph.is_ancestor which does a cheap one-way check, but would duplicate
work needlessly for a two-way comparison. I found no public method doing
exactly what I had in mind, although I might have overlooked something
(as I did with my last request for a public method...).

I propose to add a method Graph.revision_relation (no plural) that does
a two-way comparison, and to also have global constants for the possible
return values. Both Branch._revision_relations and Graph.is_ancestor
could be reimplemented using this new method, and the former could be
replaced by direct Graph.revision_relation calls in bzrlib. If future
development in bzrlib finds a cheaper comparison than a heads call,
applications using revision_relation could benefit without modification.

I'd be willing to write a patch (resp. merge directive) if you agree to
the general concept.

I noticed that there is a special Graph implementation,
graph.HeadsCache, which does cache replies to heads requests. It seems
to be used in repository.CommitBuilder only. Caching all replies on a
general basis is probably too much overhead, though, and if there ever
is a reason to do so, then the general Graph implementation should
probably do so. So for now I'd not use HeadsCache. Do you agree?

Greetings,
 Martin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20091209/b6e740bc/attachment.pgp 


More information about the bazaar mailing list