Rev 2490: Fix bug #115343, Add a test that we can branch any revision in our ancestry. in http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/branch_from_merged_115343
John Arbash Meinel
john at arbash-meinel.com
Mon May 21 18:03:08 BST 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/branch_from_merged_115343
------------------------------------------------------------
revno: 2490
revision-id: john at arbash-meinel.com-20070521170258-206ck4nmijfode31
parent: john at arbash-meinel.com-20070521164413-tp0zcdi51i5dxkv2
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: branch_from_merged_115343
timestamp: Mon 2007-05-21 19:02:58 +0200
message:
Fix bug #115343, Add a test that we can branch any revision in our ancestry.
And update Branch6 to support this properly.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/tests/branch_implementations/test_sprout.py test_sprout.py-20070521151739-b8t8p7axw1h966ws-1
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2007-05-10 05:55:01 +0000
+++ b/NEWS 2007-05-21 17:02:58 +0000
@@ -8,6 +8,10 @@
that we can pass in the Transport that we already have.
(John Arbash Meinel, #75721)
+ * ``bzr branch -r revid:foo`` can be used to branch any revision in
+ your ancestry. (Previously Branch6 only supported revisions in your
+ mainline). (John Arbash Meinel, #115343)
+
bzr 0.16 2007-05-07
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2007-05-08 20:00:50 +0000
+++ b/bzrlib/branch.py 2007-05-21 17:02:58 +0000
@@ -2077,7 +2077,14 @@
if revision_id is None:
revno, revision_id = self.last_revision_info()
else:
- revno = self.revision_id_to_revno(revision_id)
+ # To figure out the revno for a random revision, we need to build
+ # the revision history, and count its length.
+ # We don't care about the order, just how long it is.
+ # Alternatively, we could start at the current location, and count
+ # backwards. But there is no guarantee that we will find it since
+ # it may be a merged revision.
+ revno = len(list(self.repository.iter_reverse_revision_history(
+ revision_id)))
destination.set_last_revision_info(revno, revision_id)
def _make_tags(self):
=== modified file 'bzrlib/tests/branch_implementations/test_sprout.py'
--- a/bzrlib/tests/branch_implementations/test_sprout.py 2007-05-21 16:44:13 +0000
+++ b/bzrlib/tests/branch_implementations/test_sprout.py 2007-05-21 17:02:58 +0000
@@ -61,3 +61,22 @@
repo_a.copy_content_into(repo_b)
br_b = wt_a.branch.sprout(repo_b.bzrdir, revision_id='1')
self.assertEqual('1', br_b.last_revision())
+
+ def test_sprout_partial_not_in_revision_history(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')
+
+ repo = self.make_repository('target')
+ repo.fetch(wt.branch.repository)
+ branch2 = wt.branch.sprout(repo.bzrdir, revision_id='rev2-alt')
+ self.assertEqual((2, 'rev2-alt'), branch2.last_revision_info())
+ self.assertEqual(['rev1', 'rev2-alt'], branch2.revision_history())
More information about the bazaar-commits
mailing list