示例#1
0
    def test_mv_already_moved_files_forcing_after(self):
        """Test brz mv versioned_files to directory/unversioned_file.

        Tests if an attempt to move an existing versioned file to an existing
        unversioned file in some other directory will fail, informing the user
        to use the --after option to force this.

        Setup: a1, a2, sub are versioned and in the working tree,
               sub/a1, sub/a2 are in working tree.
        User does: mv a* sub; touch a1; touch a2; brz mv a1 a2 sub
        """
        self.build_tree(['a1', 'a2', 'sub/', 'sub/a1', 'sub/a2'])
        tree = self.make_branch_and_tree('.')
        tree.add(['a1', 'a2', 'sub'])
        osutils.rename('a1', 'sub/a1')
        osutils.rename('a2', 'sub/a2')
        self.build_tree(['a1'])  # touch a1
        self.build_tree(['a2'])  # touch a2

        self.run_bzr_error([
            "^brz: ERROR: Could not rename a1 => sub/a1 because both files"
            " exist. \\(Use --after to tell brz about a rename that has already"
            " happened\\)$"
        ], 'mv a1 a2 sub')
        self.assertPathExists('a1')
        self.assertPathExists('a2')
        self.assertPathExists('sub/a1')
        self.assertPathExists('sub/a2')
示例#2
0
    def test_mv_already_moved_files_using_after(self):
        """Test brz mv --after versioned_file to directory/unversioned_file.

        Tests if an existing versioned file can be forced to move to an
        existing unversioned file in some other directory using the --after
        option. With the result that bazaar considers
        directory/unversioned_file to be moved from versioned_file and
        versioned_file will become unversioned.

        Setup: a1, a2, sub are versioned and in the working tree,
               sub/a1, sub/a2 are in working tree.
        User does: mv a* sub; touch a1; touch a2; brz mv a1 a2 sub --after
        """
        self.build_tree(['a1', 'a2', 'sub/', 'sub/a1', 'sub/a2'])
        tree = self.make_branch_and_tree('.')
        tree.add(['a1', 'a2', 'sub'])
        osutils.rename('a1', 'sub/a1')
        osutils.rename('a2', 'sub/a2')
        self.build_tree(['a1'])  # touch a1
        self.build_tree(['a2'])  # touch a2

        self.run_bzr('mv a1 a2 sub --after')
        self.assertPathExists('a1')
        self.assertPathExists('a2')
        self.assertPathExists('sub/a1')
        self.assertPathExists('sub/a2')
        self.assertInWorkingTree('sub/a1')
        self.assertInWorkingTree('sub/a2')
示例#3
0
 def make_abcd_tree(self):
     tree = self.make_branch_and_tree('tree')
     self.build_tree(['tree/a', 'tree/c'])
     tree.add(['a', 'c'])
     tree.commit('record old names')
     osutils.rename('tree/a', 'tree/b')
     osutils.rename('tree/c', 'tree/d')
     return tree
示例#4
0
 def test_join_error(self):
     base_tree, sub_tree = self.make_trees()
     os.mkdir('tree/subtree2')
     osutils.rename('tree/subtree', 'tree/subtree2/subtree')
     self.run_bzr_error(
         ('Cannot join .*subtree.  Parent directory is not versioned', ),
         'join tree/subtree2/subtree')
     # disabled because this gives an ugly error at present -- mbp 20070306
     # self.run_bzr_error(
     ##     ('Cannot join .*subtree.  Parent directory is not versioned',),
     # 'join', '--reference', 'tree/subtree2/subtree')
     self.run_bzr_error(('Not a branch:.*subtree2', ), 'join tree/subtree2')
示例#5
0
    def test_mv_already_moved_file_into_subdir(self):
        """Test brz mv original_file to versioned_directory/file.

        Tests if a file which has already been moved into a versioned
        directory by an external tool, is handled correctly by brz mv.
        Setup: a and sub/ are in the working tree.
        User does: mv a sub/a; brz mv a sub/a
        """
        self.build_tree(['a', 'sub/'])
        tree = self.make_branch_and_tree('.')
        tree.add(['a', 'sub'])

        osutils.rename('a', 'sub/a')
        self.run_bzr('mv a sub/a')
        self.assertMoved('a', 'sub/a')
示例#6
0
    def test_mv_already_moved_file(self):
        """Test brz mv original_file to moved_file.

        Tests if a file which has allready been moved by an external tool,
        is handled correctly by brz mv.
        Setup: a is in the working tree, b does not exist.
        User does: mv a b; brz mv a b
        """
        self.build_tree(['a'])
        tree = self.make_branch_and_tree('.')
        tree.add(['a'])

        osutils.rename('a', 'b')
        self.run_bzr('mv a b')
        self.assertMoved('a', 'b')
示例#7
0
    def test_mv_already_moved_files_into_subdir(self):
        """Test brz mv original_files to versioned_directory.

        Tests if files which has already been moved into a versioned
        directory by an external tool, is handled correctly by brz mv.
        Setup: a1, a2, sub are in the working tree.
        User does: mv a1 sub/.; brz mv a1 a2 sub
        """
        self.build_tree(['a1', 'a2', 'sub/'])
        tree = self.make_branch_and_tree('.')
        tree.add(['a1', 'a2', 'sub'])

        osutils.rename('a1', 'sub/a1')
        self.run_bzr('mv a1 a2 sub')
        self.assertMoved('a1', 'sub/a1')
        self.assertMoved('a2', 'sub/a2')
示例#8
0
    def test_mv_already_moved_file_into_unversioned_subdir(self):
        """Test brz mv original_file to unversioned_directory/file.

        Tests if an attempt to move an existing versioned file
        into an unversioned directory will fail.
        Setup: a is in the working tree, sub/ is not.
        User does: mv a sub/a; brz mv a sub/a
        """
        self.build_tree(['a', 'sub/'])
        tree = self.make_branch_and_tree('.')
        tree.add(['a'])

        osutils.rename('a', 'sub/a')
        self.run_bzr_error(
            ["^brz: ERROR: Could not move a => a: sub is not versioned\\.$"],
            'mv a sub/a')
        self.assertPathDoesNotExist('a')
        self.assertPathExists('sub/a')
示例#9
0
    def test_mv_already_moved_files_into_unversioned_subdir(self):
        """Test brz mv original_file to unversioned_directory.

        Tests if an attempt to move existing versioned file
        into an unversioned directory will fail.
        Setup: a1, a2 are in the working tree, sub is not.
        User does: mv a1 sub/.; brz mv a1 a2 sub
        """
        self.build_tree(['a1', 'a2', 'sub/'])
        tree = self.make_branch_and_tree('.')
        tree.add(['a1', 'a2'])

        osutils.rename('a1', 'sub/a1')
        self.run_bzr_error(
            ["^brz: ERROR: Could not move to sub. sub is not versioned\\.$"],
            'mv a1 a2 sub')
        self.assertPathDoesNotExist('a1')
        self.assertPathExists('sub/a1')
        self.assertPathExists('a2')
        self.assertPathDoesNotExist('sub/a2')
示例#10
0
    def test_mv_already_moved_file_to_versioned_target(self):
        """Test brz mv existing_file to versioned_file.

        Tests if an attempt to move an existing versioned file
        to another versiond file will fail.
        Setup: a and b are in the working tree.
        User does: rm b; mv a b; brz mv a b
        """
        self.build_tree(['a', 'b'])
        tree = self.make_branch_and_tree('.')
        tree.add(['a', 'b'])

        os.remove('b')
        osutils.rename('a', 'b')
        self.run_bzr_error(
            ["^brz: ERROR: Could not move a => b. b is already versioned\\.$"],
            'mv a b')
        # check that nothing changed
        self.assertPathDoesNotExist('a')
        self.assertPathExists('b')
示例#11
0
    def test_mv_already_moved_directory(self):
        """Use `brz mv a b` to mark a directory as renamed.

        https://bugs.launchpad.net/bzr/+bug/107967/
        """
        self.build_tree(['a/', 'c/'])
        tree = self.make_branch_and_tree('.')
        tree.add(['a', 'c'])
        osutils.rename('a', 'b')
        osutils.rename('c', 'd')
        # mv a b should work just like it does for already renamed files
        self.run_bzr('mv a b')
        self.assertPathDoesNotExist('a')
        self.assertNotInWorkingTree('a')
        self.assertPathExists('b')
        self.assertInWorkingTree('b')
        # and --after should work, too (technically it's ignored)
        self.run_bzr('mv --after c d')
        self.assertPathDoesNotExist('c')
        self.assertNotInWorkingTree('c')
        self.assertPathExists('d')
        self.assertInWorkingTree('d')
示例#12
0
    def test_mv_already_moved_file_using_after(self):
        """Test brz mv --after versioned_file to unversioned_file.

        Tests if an existing versioned file can be forced to move to an
        existing unversioned file using the --after option. With the result
        that bazaar considers the unversioned_file to be moved from
        versioned_file and versioned_file will become unversioned.
        Setup: a is in the working tree and b exists.
        User does: mv a b; touch a; brz mv a b --after
        Resulting in a => b and a is unknown.
        """
        self.build_tree(['a', 'b'])
        tree = self.make_branch_and_tree('.')
        tree.add(['a'])
        osutils.rename('a', 'b')
        self.build_tree(['a'])  # touch a

        self.run_bzr('mv a b --after')
        self.assertPathExists('a')
        self.assertNotInWorkingTree('a')  # a should be unknown now.
        self.assertPathExists('b')
        self.assertInWorkingTree('b')
示例#13
0
    def test_mv_already_moved_file_forcing_after(self):
        """Test brz mv versioned_file to unversioned_file.

        Tests if an attempt to move an existing versioned file to an existing
        unversioned file will fail, informing the user to use the --after
        option to force this.
        Setup: a is in the working tree, b not versioned.
        User does: mv a b; touch a; brz mv a b
        """
        self.build_tree(['a', 'b'])
        tree = self.make_branch_and_tree('.')
        tree.add(['a'])

        osutils.rename('a', 'b')
        self.build_tree(['a'])  # touch a
        self.run_bzr_error([
            "^brz: ERROR: Could not rename a => b because both files exist."
            " \\(Use --after to tell brz about a rename that has already"
            " happened\\)$"
        ], 'mv a b')
        self.assertPathExists('a')
        self.assertPathExists('b')
示例#14
0
 def prepare_lightweight_switch(self):
     branch = self.make_branch('branch')
     branch.create_checkout('tree', lightweight=True)
     osutils.rename('branch', 'branch1')
示例#15
0
 def commit(self):
     """Close the file and move to final name."""
     self._close_tmpfile('commit')
     osutils.rename(self.tmpfilename, self.realfilename)