~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_uncommit.py

Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
        self.assertContainsRe(out, 'second commit')
49
49
 
50
50
        # Nothing has changed
51
 
        self.assertEqual('a2', wt.last_revision())
 
51
        self.assertEqual(['a2'], wt.get_parent_ids())
52
52
 
53
53
        # Uncommit, don't prompt
54
54
        out, err = self.run_bzr('uncommit', '--force')
56
56
        self.assertContainsRe(out, 'second commit')
57
57
 
58
58
        # This should look like we are back in revno 1
59
 
        self.assertEqual('a1', wt.last_revision())
 
59
        self.assertEqual(['a1'], wt.get_parent_ids())
60
60
        out, err = self.run_bzr('status')
61
61
        self.assertEquals(out, 'modified:\n  a\n')
62
62
 
66
66
        checkout_tree = wt.bzrdir.sprout('checkout').open_workingtree()
67
67
        checkout_tree.branch.bind(wt.branch)
68
68
 
69
 
        self.assertEqual('a2', checkout_tree.last_revision())
 
69
        self.assertEqual(['a2'], checkout_tree.get_parent_ids())
70
70
 
71
71
        os.chdir('checkout')
72
72
        out, err = self.run_bzr('uncommit', '--dry-run', '--force')
74
74
        self.assertNotContainsRe(out, 'initial commit')
75
75
        self.assertContainsRe(out, 'second commit')
76
76
 
77
 
        self.assertEqual('a2', checkout_tree.last_revision())
 
77
        self.assertEqual(['a2'], checkout_tree.get_parent_ids())
78
78
 
79
79
        out, err = self.run_bzr('uncommit', '--force')
80
80
        self.assertNotContainsRe(out, 'initial commit')
82
82
 
83
83
        # uncommit in a checkout should uncommit the parent branch
84
84
        # (but doesn't effect the other working tree)
85
 
        self.assertEquals('a1', checkout_tree.last_revision())
 
85
        self.assertEquals(['a1'], checkout_tree.get_parent_ids())
86
86
        self.assertEquals('a1', wt.branch.last_revision())
87
 
        self.assertEquals('a2', wt.last_revision())
 
87
        self.assertEquals(['a2'], wt.get_parent_ids())
88
88
 
89
89
    def test_uncommit_bound(self):
90
90
        os.mkdir('a')
91
91
        a = BzrDirMetaFormat1().initialize('a')
92
92
        a.create_repository()
93
93
        a.create_branch()
94
 
        t = a.create_workingtree()
95
 
        t.commit('commit 1')
96
 
        t.commit('commit 2')
97
 
        t.commit('commit 3')
98
 
        b = t.bzrdir.sprout('b').open_branch()
99
 
        b.bind(t.branch)
 
94
        t_a = a.create_workingtree()
 
95
        t_a.commit('commit 1')
 
96
        t_a.commit('commit 2')
 
97
        t_a.commit('commit 3')
 
98
        b = t_a.bzrdir.sprout('b').open_branch()
 
99
        b.bind(t_a.branch)
100
100
        uncommit.uncommit(b)
101
 
        t.set_last_revision(t.branch.last_revision())
102
101
        self.assertEqual(len(b.revision_history()), 2)
103
 
        self.assertEqual(len(t.branch.revision_history()), 2)
104
 
        t.commit('commit 3b')
 
102
        self.assertEqual(len(t_a.branch.revision_history()), 2)
 
103
        # update A's tree to not have the uncomitted revision referenced.
 
104
        t_a.update()
 
105
        t_a.commit('commit 3b')
105
106
        self.assertRaises(BoundBranchOutOfDate, uncommit.uncommit, b)
106
 
        b.pull(t.branch)
 
107
        b.pull(t_a.branch)
107
108
        uncommit.uncommit(b)
108
109
 
109
110
    def test_uncommit_revision(self):
114
115
 
115
116
        self.assertNotContainsRe(out, 'initial commit')
116
117
        self.assertContainsRe(out, 'second commit')
117
 
        self.assertEqual('a1', wt.last_revision())
 
118
        self.assertEqual(['a1'], wt.get_parent_ids())
118
119
        self.assertEqual('a1', wt.branch.last_revision())
119
120
 
120
121
    def test_uncommit_neg_1(self):
131
132
        tree2.commit('unchanged', rev_id='b3')
132
133
        tree2.commit('unchanged', rev_id='b4')
133
134
 
134
 
        wt.branch.fetch(tree2.branch)
135
 
        wt.set_pending_merges(['b4'])
 
135
        wt.merge_from_branch(tree2.branch)
136
136
        wt.commit('merge b4', rev_id='a3')
137
137
 
138
 
        self.assertEqual('a3', wt.last_revision())
139
 
        self.assertEqual([], wt.pending_merges())
 
138
        self.assertEqual(['a3'], wt.get_parent_ids())
140
139
 
141
140
        os.chdir('tree')
142
141
        out, err = self.run_bzr('uncommit', '--force')
143
142
 
144
 
        self.assertEqual('a2', wt.last_revision())
145
 
        self.assertEqual(['b4'], wt.pending_merges())
 
143
        self.assertEqual(['a2', 'b4'], wt.get_parent_ids())
146
144
 
147
145
    def test_uncommit_pending_merge(self):
148
146
        wt = self.create_simple_tree()
154
152
 
155
153
        os.chdir('tree')
156
154
        out, err = self.run_bzr('uncommit', '--force')
157
 
        self.assertEqual('a1', wt.last_revision())
158
 
        self.assertEqual(['b3'], wt.pending_merges())
 
155
        self.assertEqual(['a1', 'b3'], wt.get_parent_ids())
159
156
 
160
157
    def test_uncommit_multiple_merge(self):
161
158
        wt = self.create_simple_tree()
163
160
        tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
164
161
 
165
162
        tree2.commit('unchanged', rev_id='b3')
166
 
        wt.branch.fetch(tree2.branch)
167
 
        wt.set_pending_merges(['b3'])
 
163
 
 
164
        wt.merge_from_branch(tree2.branch)
168
165
        wt.commit('merge b3', rev_id='a3')
169
166
 
170
167
        tree2.commit('unchanged', rev_id='b4')
171
 
        wt.branch.fetch(tree2.branch)
172
 
        wt.set_pending_merges(['b4'])
 
168
 
 
169
        wt.merge_from_branch(tree2.branch)
173
170
        wt.commit('merge b4', rev_id='a4')
174
171
 
175
 
        self.assertEqual('a4', wt.last_revision())
176
 
        self.assertEqual([], wt.pending_merges())
 
172
        self.assertEqual(['a4'], wt.get_parent_ids())
177
173
 
178
174
        os.chdir('tree')
179
175
        out, err = self.run_bzr('uncommit', '--force', '-r', '2')
180
176
 
181
 
        self.assertEqual('a2', wt.last_revision())
182
 
        self.assertEqual(['b3', 'b4'], wt.pending_merges())
 
177
        self.assertEqual(['a2', 'b3', 'b4'], wt.get_parent_ids())
183
178
 
184
179
    def test_uncommit_merge_plus_pending(self):
185
180
        wt = self.create_simple_tree()
195
190
        wt.branch.fetch(tree2.branch)
196
191
        wt.set_pending_merges(['b4'])
197
192
 
198
 
        self.assertEqual('a3', wt.last_revision())
199
 
        self.assertEqual(['b4'], wt.pending_merges())
 
193
        self.assertEqual(['a3', 'b4'], wt.get_parent_ids())
200
194
 
201
195
        os.chdir('tree')
202
196
        out, err = self.run_bzr('uncommit', '--force', '-r', '2')
203
197
 
204
 
        self.assertEqual('a2', wt.last_revision())
205
 
        self.assertEqual(['b3', 'b4'], wt.pending_merges())
 
198
        self.assertEqual(['a2', 'b3', 'b4'], wt.get_parent_ids())
206
199
 
207
200
    def test_uncommit_octopus_merge(self):
208
201
        # Check that uncommit keeps the pending merges in the same order
213
206
 
214
207
        tree2.commit('unchanged', rev_id='b3')
215
208
        tree3.commit('unchanged', rev_id='c3')
216
 
        wt.branch.fetch(tree2.branch)
217
 
        wt.branch.fetch(tree3.branch)
218
 
        wt.set_pending_merges(['b3', 'c3'])
 
209
        
 
210
        wt.merge_from_branch(tree2.branch)
 
211
        wt.merge_from_branch(tree3.branch)
219
212
        wt.commit('merge b3, c3', rev_id='a3')
220
213
 
221
214
        tree2.commit('unchanged', rev_id='b4')
222
215
        tree3.commit('unchanged', rev_id='c4')
223
 
        wt.branch.fetch(tree2.branch)
224
 
        wt.branch.fetch(tree3.branch)
225
 
        wt.set_pending_merges(['c4', 'b4'])
 
216
 
 
217
        wt.merge_from_branch(tree3.branch)
 
218
        wt.merge_from_branch(tree2.branch)
226
219
        wt.commit('merge b4, c4', rev_id='a4')
227
220
 
228
 
        self.assertEqual('a4', wt.last_revision())
229
 
        self.assertEqual([], wt.pending_merges())
 
221
        self.assertEqual(['a4'], wt.get_parent_ids())
230
222
 
231
223
        os.chdir('tree')
232
224
        out, err = self.run_bzr('uncommit', '--force', '-r', '2')
233
225
 
234
 
        self.assertEqual('a2', wt.last_revision())
235
 
        self.assertEqual(['b3', 'c3', 'c4', 'b4'], wt.pending_merges())
 
226
        self.assertEqual(['a2', 'b3', 'c3', 'c4', 'b4'], wt.get_parent_ids())