[MERGE][bug 115343] Allow 'bzr branch -r revid:xxx' to branch any revision in ancestry

John Arbash Meinel john at arbash-meinel.com
Fri Jun 1 16:16:28 BST 2007


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

Aaron Bentley wrote:
> John Arbash Meinel wrote:
>> The attached patch makes "BzrBranch6" also support it. I only test that
>> you can branch anything in Ancestry (not just in your repository) since
>> that seemed more realistic for foreign branches. (And if we ever
>> implement any sort of auto-gc).
> 
> I think I would prefer to ensure you can branch from anything in your
> repository, not just in your ancestry.  This allows you to restore
> branches that you may have deleted by accident.
> 
> Aaron
> 
> (resending, since I think you missed it the first time)

I did indeed miss it, thanks for re-sending.

I do want to have that capability, I'm not sure if it would be at the
"bzr branch" level. Specifically, the test for it would look something like:

def test_sprout_partial_only_in_repository(self):
    """We should be able to sprout from any revision in ancestry."""
    wt = self.make_branch_and_tree('source')
    self.build_tree(['source/a'])
    wt.add('a')
    wt.commit('rev1', rev_id='rev1')
    wt.commit('rev2-alt', rev_id='rev2-alt')
    wt.set_parent_ids(['rev1'])
    wt.branch.set_last_revision_info(1, 'rev1')
    wt.commit('rev2', rev_id='rev2')
    wt.set_parent_ids(['rev2', 'rev2-alt'])
    wt.commit('rev3', rev_id='rev3')

    # Reset so we create a new history
    wt.set_parent_ids([])
    wt.branch.set_last_revision_info(0, NULL_REVISION)
    wt.add('a')
    wt.commit('rev1-alt', rev_id='rev1-alt')

    # Even though wt.branch doesn't contain rev2 in its ancestry
    # anymore,
    # it is still in the repository, so we should be able to spawn a new
    # branch
    repo = self.make_repository('target')
    # You should still be able to fetch the revision from the repository
    repo.fetch(wt.branch.repository, revision_id='rev3')
    # And sprout it from the branch
    branch2 = wt.branch.sprout(repo.bzrdir, revision_id='rev3')
    self.assertEqual((3, 'rev3'), branch2.last_revision_info())
    self.assertEqual(['rev1', 'rev2', 'rev3'],
                     branch2.revision_history())

(basically, set up a couple revisions, and then reset the working tree
to a new line of ancestry, and we can still "branch from it" to get the
old ancestry).

I'm more than happy enough with the:
  repo.fetch(wt.branch.repository, revision_id='rev2')

Which means that we should be able to fetch anything out of the
repository that we have.

However the:
  branch2 = wt.branch.sprout(repo.bzrdir, revision_id='rev3')

I'm much less comfortable with. Having a branch sprout a new branch,
without having the revision in its ancestry just feels wrong.

If spawning were done in a different way, like doing:

branch2 = repo.create_branch(wt.branch.format, revision_id='rev3',
                             path/bzrdir=??)
That has you sprout a branch out of a repository, which is much more
natural than having a branch create another branch, with an arbitrary
revision from the *target* branch's repository.

Thoughts?

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

iD8DBQFGYDhMJdeBCYSNAAMRAkeLAKDJPsHk7DxwPIHPqFsJD8XyIiBaOgCgqn7C
lkpnX5W6uX6fNU8vnVBg95A=
=fveB
-----END PGP SIGNATURE-----




More information about the bazaar mailing list