Rev 116: Fix rebasing of merge commits. in bzr+ssh://bazaar.launchpad.net/~lifeless/bzr-rebase/dev
Robert Collins
robertc at robertcollins.net
Fri Jan 16 01:07:33 GMT 2009
At bzr+ssh://bazaar.launchpad.net/~lifeless/bzr-rebase/dev
------------------------------------------------------------
revno: 116
revision-id: robertc at robertcollins.net-20090116010711-s2liu81ibp965wy6
parent: robertc at robertcollins.net-20090115060729-fj1p5208cujanmzc
committer: Robert Collins <robertc at robertcollins.net>
branch nick: dev
timestamp: Fri 2009-01-16 12:07:11 +1100
message:
Fix rebasing of merge commits.
=== modified file 'NEWS'
--- a/NEWS 2009-01-15 06:07:29 +0000
+++ b/NEWS 2009-01-16 01:07:11 +0000
@@ -5,6 +5,11 @@
* --new-nick to replay and rebase will recreate the nick for revisions that
are rewritten. (Robert Collins)
+ BUG FIXES
+
+ * rebasing of merges was discarding the merged parents.
+ (Robert Collins, #266897)
+
0.4.2 2008-11-18
FEATURES
=== modified file 'rebase.py'
--- a/rebase.py 2009-01-15 06:07:29 +0000
+++ b/rebase.py 2009-01-16 01:07:11 +0000
@@ -179,7 +179,7 @@
if len(oldparents) > 1:
additional_parents = heads_cache.heads(oldparents[1:])
parents = [new_parent]
- for parent in parents:
+ for parent in oldparents:
if parent in additional_parents and parent not in parents:
# Use as a parent
parent = replace_map.get(parent, (parent,))[0]
=== modified file 'test_blackbox.py'
--- a/test_blackbox.py 2009-01-15 06:07:29 +0000
+++ b/test_blackbox.py 2009-01-16 01:07:11 +0000
@@ -246,6 +246,48 @@
self.run_bzr('rebase --new-nick ../main', working_dir='other')
rev = other.branch.repository.get_revision(other.last_revision())
self.assertEqual('other', rev.properties['branch-nick'])
+
+ def test_always_rebase_merges(self):
+ trunk = self.make_branch_and_tree('trunk')
+ trunk.commit('base')
+ feature2 = trunk.bzrdir.sprout('feature2').open_workingtree()
+ revid2 = feature2.commit('change')
+ feature = trunk.bzrdir.sprout('feature').open_workingtree()
+ feature.commit('change')
+ feature.merge_from_branch(feature2.branch)
+ feature.commit('merge')
+ feature.commit('change2')
+ trunk.commit('additional upstream change')
+ self.run_bzr('rebase --always-rebase-merges ../trunk', working_dir='feature')
+ # second revision back should be a merge of feature2
+ repo = feature.branch.repository
+ repo.lock_read()
+ self.addCleanup(repo.unlock)
+ tip = feature.last_revision()
+ merge_id = repo.get_graph().get_parent_map([tip])[tip][0]
+ merge_parents = repo.get_graph().get_parent_map([merge_id])[merge_id]
+ self.assertEqual(revid2, merge_parents[1])
+
+ def test_rebase_merge(self):
+ trunk = self.make_branch_and_tree('trunk')
+ trunk.commit('base')
+ feature2 = trunk.bzrdir.sprout('feature2').open_workingtree()
+ revid2 = feature2.commit('change')
+ feature = trunk.bzrdir.sprout('feature').open_workingtree()
+ feature.commit('change')
+ feature.merge_from_branch(feature2.branch)
+ feature.commit('merge')
+ feature.commit('change2')
+ trunk.commit('additional upstream change')
+ self.run_bzr('rebase ../trunk', working_dir='feature')
+ # second revision back should be a merge of feature2
+ repo = feature.branch.repository
+ repo.lock_read()
+ self.addCleanup(repo.unlock)
+ tip = feature.last_revision()
+ merge_id = repo.get_graph().get_parent_map([tip])[tip][0]
+ merge_parents = repo.get_graph().get_parent_map([merge_id])[merge_id]
+ self.assertEqual(revid2, merge_parents[1])
class ReplayTests(ExternalBase):
More information about the bazaar-commits
mailing list