How to open branch object equivalent of -r ancestor::parent

Alexander Belchenko bialix at ukr.net
Thu Mar 29 16:12:34 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 =
>> mod_branch.Branch.open_containing(branch.get_parent())[0]
>>
>> 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.
> 
> 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(),
>                             old_branch.last_revision())
> 
> That should give you the revision you need to diff against.

I have lock error which I'm not quite understand. here is the code:

def get_parent_submission_info(branch):
     """Get the status information for a branch versus its submit branch.

     :return: delta
     """
     new_tree = branch.basis_tree()
     old_branch = mod_branch.Branch.open_containing(branch.get_parent())[0]
     # Thanks to Aaron for code snippet
     # Get a graph, so we 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(),
                                 old_branch.last_revision())
     old_tree = old_branch.repository.revision_tree(lca)
     return changes_between_trees(new_tree, old_tree)[0]

I've got error message instead of expected delta between 2 trees:

_KnitGraphIndex(CombinedGraphIndex(<bzrlib.btree_index.BTreeGraphIndex 
object at 0x02EEEF10>, <bzrlib.btree_index.BTreeGraphIndex object at 
0x02EEEE30>)) is not locked

What did I do wrong?

-- 
All the dude wanted was his rug back



More information about the bazaar mailing list