How to open branch object equivalent of -r ancestor::parent
bialix at ukr.net
Mon Mar 19 19:17:00 UTC 2012
Aaron Bentley пишет:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> On 12-03-16 11:41 AM, Alexander Belchenko wrote:
>> To fix the bug https://bugs.launchpad.net/bzr-explorer/+bug/956268
>> I need to open ancestor related to parent branch instead of tip of
>> parent branch itself.
>> Current code does today:
>> old_branch =
>> Which is equivalent of -r branch::parent
>> I need this to be changed to be equivalent -r ancestor::parent
>> Any suggestions or code snippets will help.
> What you ask is technically possible, but the difference between -r
> branch::parent and -r ancestor::parent is the *revision* they select,
> not the branch they open.
Yes, you're right. I don't need a branch object actually, for
obtaining delta between 2 tree states I need tree object corresponding
to that revision. Thank you for your example! Having revision id I
should be able to obtain revision tree to compare with.
> We'll need the revision anyhow, so let's start there. To get the
> revision used by ancestor::parent, you'll need to
> # Ensure you have both branches open
> old_branch = mod_branch.Branch.open(branch.get_parent())
> # Get a graph, so you can find the common ancestor (LCA)
> graph = old_branch.repository.get_graph(branch.repository)
> # Find the LCA of the revisions
> lca = graph.find_unique_lca(branch.last_revision(),
> That should give you the revision you need to diff against.
> If you really need to specify a branch, not a revision, then I guess
> you can make a memory branch, stacked on either of the other branches,
> and call Branch.set_last_revision_info(1, lca) on it. But I recommend
> avoiding this if at all possible.
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> -----END PGP SIGNATURE-----
More information about the bazaar