~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robey Pointer
  • Date: 2006-09-03 00:28:18 UTC
  • mfrom: (1981 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1996.
  • Revision ID: robey@lag.net-20060903002818-71ca5c7bfea93a26
merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
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):
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
        self.merge(tree2.branch, wt)
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()
163
161
        tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
164
162
 
165
163
        tree2.commit('unchanged', rev_id='b3')
166
 
        wt.branch.fetch(tree2.branch)
167
 
        wt.set_pending_merges(['b3'])
 
164
 
 
165
        self.merge(tree2.branch, wt)
168
166
        wt.commit('merge b3', rev_id='a3')
169
167
 
170
168
        tree2.commit('unchanged', rev_id='b4')
171
 
        wt.branch.fetch(tree2.branch)
172
 
        wt.set_pending_merges(['b4'])
 
169
 
 
170
        self.merge(tree2.branch, wt)
173
171
        wt.commit('merge b4', rev_id='a4')
174
172
 
175
 
        self.assertEqual('a4', wt.last_revision())
176
 
        self.assertEqual([], wt.pending_merges())
 
173
        self.assertEqual(['a4'], wt.get_parent_ids())
177
174
 
178
175
        os.chdir('tree')
179
176
        out, err = self.run_bzr('uncommit', '--force', '-r', '2')
180
177
 
181
 
        self.assertEqual('a2', wt.last_revision())
182
 
        self.assertEqual(['b3', 'b4'], wt.pending_merges())
 
178
        self.assertEqual(['a2', 'b3', 'b4'], wt.get_parent_ids())
183
179
 
184
180
    def test_uncommit_merge_plus_pending(self):
185
181
        wt = self.create_simple_tree()
213
209
 
214
210
        tree2.commit('unchanged', rev_id='b3')
215
211
        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'])
 
212
        
 
213
        self.merge(tree2.branch, wt)
 
214
        self.merge(tree3.branch, wt)
219
215
        wt.commit('merge b3, c3', rev_id='a3')
220
216
 
221
217
        tree2.commit('unchanged', rev_id='b4')
222
218
        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'])
 
219
 
 
220
        self.merge(tree3.branch, wt)
 
221
        self.merge(tree2.branch, wt)
226
222
        wt.commit('merge b4, c4', rev_id='a4')
227
223
 
228
 
        self.assertEqual('a4', wt.last_revision())
229
 
        self.assertEqual([], wt.pending_merges())
 
224
        self.assertEqual(['a4'], wt.get_parent_ids())
230
225
 
231
226
        os.chdir('tree')
232
227
        out, err = self.run_bzr('uncommit', '--force', '-r', '2')
233
228
 
234
 
        self.assertEqual('a2', wt.last_revision())
235
 
        self.assertEqual(['b3', 'c3', 'c4', 'b4'], wt.pending_merges())
 
229
        self.assertEqual(['a2', 'b3', 'c3', 'c4', 'b4'], wt.get_parent_ids())