Rev 4673: Cleanup imports in blackbox/test_merge.py. in file:///home/vila/src/bzr/bugs/merge-strict/

Vincent Ladeuil v.ladeuil+lp at free.fr
Tue Sep 8 16:39:36 BST 2009


At file:///home/vila/src/bzr/bugs/merge-strict/

------------------------------------------------------------
revno: 4673
revision-id: v.ladeuil+lp at free.fr-20090908153936-bi89hl7i6h3djzcv
parent: pqm at pqm.ubuntu.com-20090904024310-7a3uqlf6iruxvz6m
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: merge-strict
timestamp: Tue 2009-09-08 17:39:36 +0200
message:
  Cleanup imports in blackbox/test_merge.py.
-------------- next part --------------
=== modified file 'bzrlib/tests/blackbox/test_merge.py'
--- a/bzrlib/tests/blackbox/test_merge.py	2009-08-06 06:58:09 +0000
+++ b/bzrlib/tests/blackbox/test_merge.py	2009-09-08 15:39:36 +0000
@@ -21,23 +21,25 @@
 
 import os
 
-from bzrlib import merge_directive
-from bzrlib.branch import Branch
-from bzrlib.bzrdir import BzrDir
-from bzrlib.conflicts import ConflictList, ContentsConflict
-from bzrlib.osutils import abspath, file_kind, pathjoin
-from bzrlib.tests.blackbox import ExternalBase
-import bzrlib.urlutils as urlutils
-from bzrlib.workingtree import WorkingTree
-
-
-class TestMerge(ExternalBase):
+from bzrlib import (
+    branch,
+    bzrdir,
+    conflicts,
+    merge_directive,
+    osutils,
+    tests,
+    urlutils,
+    workingtree,
+    )
+
+
+class TestMerge(tests.TestCaseWithTransport):
 
     def example_branch(self, path='.'):
         tree = self.make_branch_and_tree(path)
         self.build_tree_contents([
-            (pathjoin(path, 'hello'), 'foo'),
-            (pathjoin(path, 'goodbye'), 'baz')])
+            (osutils.pathjoin(path, 'hello'), 'foo'),
+            (osutils.pathjoin(path, 'goodbye'), 'baz')])
         tree.add('hello')
         tree.commit(message='setup')
         tree.add('goodbye')
@@ -63,13 +65,11 @@
         return tree, other
 
     def test_merge_reprocess(self):
-        d = BzrDir.create_standalone_workingtree('.')
+        d = bzrdir.BzrDir.create_standalone_workingtree('.')
         d.commit('h')
         self.run_bzr('merge . --reprocess --merge-type weave')
 
     def test_merge(self):
-        from bzrlib.branch import Branch
-
         a_tree = self.example_branch('a')
         ancestor = a_tree.branch.revno()
         b_tree = a_tree.bzrdir.sprout('b').open_workingtree()
@@ -80,7 +80,7 @@
         # We can't merge when there are in-tree changes
         os.chdir('a')
         self.run_bzr('merge ../b', retcode=3)
-        a = WorkingTree.open('.')
+        a = workingtree.WorkingTree.open('.')
         a_tip = a.commit("Like an epidemic of u's")
         self.run_bzr('merge ../b -r last:1..last:1 --merge-type blooof',
                     retcode=3)
@@ -99,7 +99,7 @@
         self.run_bzr('merge ../b -r last:1')
         self.check_file_contents('goodbye', 'quux')
         # Merging a branch pulls its revision into the tree
-        b = Branch.open('../b')
+        b = branch.Branch.open('../b')
         b_tip = b.last_revision()
         self.failUnless(a.branch.repository.has_revision(b_tip))
         self.assertEqual([a_tip, b_tip], a.get_parent_ids())
@@ -249,8 +249,8 @@
 
         base = urlutils.local_path_from_url(branch_a.base)
         self.assertEndsWith(err, '+N  b\nAll changes applied successfully.\n')
-        self.assertEquals(abspath(branch_b.get_submit_branch()),
-                          abspath(parent))
+        self.assertEquals(osutils.abspath(branch_b.get_submit_branch()),
+                          osutils.abspath(parent))
         # test implicit --remember when committing new file
         self.build_tree(['e'])
         tree_b.add('e')
@@ -265,8 +265,8 @@
         out, err = self.run_bzr('merge ../branch_c --remember')
         self.assertEquals(out, '')
         self.assertEquals(err, '+N  c\nAll changes applied successfully.\n')
-        self.assertEquals(abspath(branch_b.get_submit_branch()),
-                          abspath(branch_c.bzrdir.root_transport.base))
+        self.assertEquals(osutils.abspath(branch_b.get_submit_branch()),
+                          osutils.abspath(branch_c.bzrdir.root_transport.base))
         # re-open tree as external run_bzr modified it
         tree_b = branch_b.bzrdir.open_workingtree()
         tree_b.commit('merge branch_c')
@@ -294,7 +294,7 @@
                                               tree_b.get_parent_ids()[0])
         self.assertEqualDiff(testament_a.as_text(),
                          testament_b.as_text())
-        tree_a.set_conflicts(ConflictList())
+        tree_a.set_conflicts(conflicts.ConflictList())
         tree_a.commit('message')
         # it is legal to attempt to merge an already-merged bundle
         output = self.run_bzr('merge ../bundle')[1]
@@ -349,7 +349,7 @@
         os.chdir('a')
         (out, err) = self.run_bzr('merge --pull ../b')
         self.assertContainsRe(out, 'Now on revision 2\\.')
-        tree_a = WorkingTree.open('.')
+        tree_a = workingtree.WorkingTree.open('.')
         self.assertEqual([self.id2], tree_a.get_parent_ids())
 
     def test_merge_kind_change(self):
@@ -363,14 +363,15 @@
         tree_a.commit('changed file to directory')
         os.chdir('tree_b')
         self.run_bzr('merge ../tree_a')
-        self.assertEqual('directory', file_kind('file'))
+        self.assertEqual('directory', osutils.file_kind('file'))
         tree_b.revert()
-        self.assertEqual('file', file_kind('file'))
+        self.assertEqual('file', osutils.file_kind('file'))
         self.build_tree_contents([('file', 'content_2')])
         tree_b.commit('content change')
         self.run_bzr('merge ../tree_a', retcode=1)
         self.assertEqual(tree_b.conflicts(),
-                         [ContentsConflict('file', file_id='file-id')])
+                         [conflicts.ContentsConflict('file',
+                                                     file_id='file-id')])
 
     def test_directive_cherrypick(self):
         source = self.make_branch_and_tree('source')
@@ -496,18 +497,6 @@
         out, err = self.run_bzr(['merge', '-d', 'a', 'b'])
         self.assertContainsRe(err, 'Warning: criss-cross merge encountered.')
 
-    def test_merge_force(self):
-        tree_a = self.make_branch_and_tree('a')
-        self.build_tree(['a/foo'])
-        tree_a.add(['foo'])
-        tree_a.commit('add file')
-        tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
-        self.build_tree_contents([('a/foo', 'change 1')])
-        tree_a.commit('change file')
-        tree_b.merge_from_branch(tree_a.branch)
-        tree_a.commit('empty change to allow merge to run')
-        self.run_bzr(['merge', '../a', '--force'], working_dir='b')
-
     def test_merge_from_submit(self):
         tree_a = self.make_branch_and_tree('a')
         tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
@@ -560,11 +549,11 @@
         tree_a.merge_from_branch(tree_b.branch)
         self.build_tree_contents([('a/file',
                                    'base-contents\nthis-contents\n')])
-        tree_a.set_conflicts(ConflictList())
+        tree_a.set_conflicts(conflicts.ConflictList())
         tree_b.merge_from_branch(tree_a.branch)
         self.build_tree_contents([('b/file',
                                    'base-contents\nother-contents\n')])
-        tree_b.set_conflicts(ConflictList())
+        tree_b.set_conflicts(conflicts.ConflictList())
         tree_a.commit('', rev_id='rev3a')
         tree_b.commit('', rev_id='rev3b')
         out, err = self.run_bzr(['merge', '-d', 'a', 'b', '--lca'], retcode=1)
@@ -598,3 +587,20 @@
         other.commit('rev1b')
         self.run_bzr('merge -d this other -r0..')
         self.failUnlessExists('this/other_file')
+
+
+class TestMergeForce(TestMerge):
+
+    def test_merge_force(self):
+        tree_a = self.make_branch_and_tree('a')
+        self.build_tree(['a/foo'])
+        tree_a.add(['foo'])
+        tree_a.commit('add file')
+        tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
+        self.build_tree_contents([('a/foo', 'change 1')])
+        tree_a.commit('change file')
+        tree_b.merge_from_branch(tree_a.branch)
+        tree_a.commit('empty change to allow merge to run')
+        self.run_bzr(['merge', '../a', '--force'], working_dir='b')
+
+



More information about the bazaar-commits mailing list