|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
How to open branch object equivalent of -r ancestor::parentTo 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. |
|
|
Re: How to open branch object equivalent of -r ancestor::parent-----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. 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. Aaron -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk9jf2EACgkQ0F+nu1YWqI1+pQCePAkp7JYkunCzRAMzAzOav59V wp8Anj19zsRFul7eug6dBUUaWy5DJfX/ =nqK9 -----END PGP SIGNATURE----- |
|
|
Re: How to open branch object equivalent of -r ancestor::parentAaron 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. 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(), > old_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. > > Aaron > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.11 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ > > iEYEARECAAYFAk9jf2EACgkQ0F+nu1YWqI1+pQCePAkp7JYkunCzRAMzAzOav59V > wp8Anj19zsRFul7eug6dBUUaWy5DJfX/ > =nqK9 > -----END PGP SIGNATURE----- > > |
|
|
Re: How to open branch object equivalent of -r ancestor::parentAaron 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 |
|
|
Re: How to open branch object equivalent of -r ancestor::parent-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 On 12-03-29 12:12 PM, Alexander Belchenko wrote: > 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? You need to take read (or write) locks on both repositories. One way to do this is to take locks on both branches. Aaron -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk90rqUACgkQ0F+nu1YWqI1YEACeM3swdv7ukma5f/Tu+DfTPUXK b/wAnA/MWMxb55Urho5C++Y/zxGzl3BR =IAtz -----END PGP SIGNATURE----- |
|
|
Re: How to open branch object equivalent of -r ancestor::parentAaron Bentley пишет:
> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On 12-03-29 12:12 PM, Alexander Belchenko wrote: >> 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? > > You need to take read (or write) locks on both repositories. One way > to do this is to take locks on both branches. Thank you! That helps. > > Aaron > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.11 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ > > iEYEARECAAYFAk90rqUACgkQ0F+nu1YWqI1YEACeM3swdv7ukma5f/Tu+DfTPUXK > b/wAnA/MWMxb55Urho5C++Y/zxGzl3BR > =IAtz > -----END PGP SIGNATURE----- > > |
| Free embeddable forum powered by Nabble | Forum Help |