コード例 #1
0
 def test_update_returns_conflict_count(self):
     # working tree formats from the meta-dir format and newer support
     # setting the last revision on a tree independently of that on the
     # branch. Its concievable that some future formats may want to
     # couple them again (i.e. because its really a smart server and
     # the working tree will always match the branch). So we test
     # that formats where initialising a branch does not initialise a
     # tree - and thus have separable entities - support skewing the
     # two things.
     main_branch = self.make_branch('tree')
     try:
         # if there is a working tree now, this is not supported.
         main_branch.bzrdir.open_workingtree()
         return
     except errors.NoWorkingTree:
         pass
     wt = main_branch.bzrdir.create_workingtree()
     # create an out of date working tree by making a checkout in this
     # current format
     self.build_tree(['checkout/', 'tree/file'])
     checkout = bzrdir.BzrDirMetaFormat1().initialize('checkout')
     branch.BranchReferenceFormat().initialize(checkout, main_branch)
     old_tree = self.workingtree_format.initialize(checkout)
     # now commit to 'tree'
     wt.add('file')
     wt.commit('A', rev_id='A')
     # and add a file file to the checkout
     self.build_tree(['checkout/file'])
     old_tree.add('file')
     # and update old_tree
     self.assertEqual(1, old_tree.update())
     self.assertEqual(['A'], old_tree.get_parent_ids())
コード例 #2
0
 def test_get_reference(self):
     """For a BranchReference, get_reference should return the location."""
     branch = self.make_branch('target')
     checkout = branch.create_checkout('checkout', lightweight=True)
     reference_url = branch.bzrdir.root_transport.abspath('') + '/'
     # if the api for create_checkout changes to return different checkout types
     # then this file read will fail.
     self.assertFileEqual(reference_url, 'checkout/.bzr/branch/location')
     self.assertEqual(
         reference_url,
         _mod_branch.BranchReferenceFormat().get_reference(checkout.bzrdir))
コード例 #3
0
 def test_create_open_reference(self):
     bzrdirformat = bzrdir.BzrDirMetaFormat1()
     t = self.get_transport()
     t.mkdir('repo')
     dir = bzrdirformat.initialize(self.get_url('repo'))
     dir.create_repository()
     target_branch = dir.create_branch()
     t.mkdir('branch')
     branch_dir = bzrdirformat.initialize(self.get_url('branch'))
     made_branch = _mod_branch.BranchReferenceFormat().initialize(
         branch_dir, target_branch=target_branch)
     self.assertEqual(made_branch.base, target_branch.base)
     opened_branch = branch_dir.open_branch()
     self.assertEqual(opened_branch.base, target_branch.base)
コード例 #4
0
ファイル: test_update.py プロジェクト: saminigod/cygwin
    def test_update_with_merges(self):
        # Test that 'bzr update' works correctly when you have
        # an update in the master tree, and a lightweight checkout
        # which has merged another branch
        master = self.make_branch_and_tree('master')
        self.build_tree(['master/file'])
        master.add(['file'])
        master.commit('one', rev_id='m1')

        self.build_tree(['checkout1/'])
        checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
        branch.BranchReferenceFormat().initialize(checkout_dir, master.branch)
        checkout1 = checkout_dir.create_workingtree('m1')

        # Create a second branch, with an extra commit
        other = master.bzrdir.sprout('other').open_workingtree()
        self.build_tree(['other/file2'])
        other.add(['file2'])
        other.commit('other2', rev_id='o2')

        # Create a new commit in the master branch
        self.build_tree(['master/file3'])
        master.add(['file3'])
        master.commit('f3', rev_id='m2')

        # Merge the other branch into checkout
        os.chdir('checkout1')
        self.run_bzr('merge ../other')

        self.assertEqual(['o2'], checkout1.get_parent_ids()[1:])

        # At this point, 'commit' should fail, because we are out of date
        self.run_bzr_error(["please run 'bzr update'"], 'commit -m merged')

        # This should not report about local commits being pending
        # merges, because they were real merges
        out, err = self.run_bzr('update')
        self.assertEqual('', out)
        self.assertEndsWith(
            err, 'All changes applied successfully.\n'
            'Updated to revision 2.\n')
        self.assertContainsRe(err, r'\+N  file3')
        # The pending merges should still be there
        self.assertEqual(['o2'], checkout1.get_parent_ids()[1:])
コード例 #5
0
ファイル: test_info.py プロジェクト: saminigod/cygwin
    def test_info_locking(self):
        transport = self.get_transport()
        # Create shared repository with a branch
        repo = self.make_repository('repo', shared=True,
                                    format=bzrdir.BzrDirMetaFormat1())
        repo.set_make_working_trees(False)
        repo.bzrdir.root_transport.mkdir('branch')
        repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
                                    format=bzrdir.BzrDirMetaFormat1())
        # Do a heavy checkout
        transport.mkdir('tree')
        transport.mkdir('tree/checkout')
        co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
            format=bzrdir.BzrDirMetaFormat1())
        co_branch.bind(repo_branch)
        # Do a light checkout of the heavy one
        transport.mkdir('tree/lightcheckout')
        lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
        branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
        lco_dir.create_workingtree()
        lco_tree = lco_dir.open_workingtree()

        # Test all permutations of locking the working tree, branch and repository
        # W B R

        # U U U
        self.assertCheckoutStatusOutput('-v tree/lightcheckout', lco_tree,
                                        repo_branch=repo_branch,
                                        verbose=True, light_checkout=True)
        # U U L
        lco_tree.branch.repository.lock_write()
        try:
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
            lco_tree, repo_branch=repo_branch,
            repo_locked=True, verbose=True, light_checkout=True)
        finally:
            lco_tree.branch.repository.unlock()
        # U L L
        lco_tree.branch.lock_write()
        try:
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
            lco_tree,
            branch_locked=True,
            repo_locked=True,
            repo_branch=repo_branch,
            verbose=True)
        finally:
            lco_tree.branch.unlock()
        # L L L
        lco_tree.lock_write()
        try:
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
            lco_tree, repo_branch=repo_branch,
            tree_locked=True,
            branch_locked=True,
            repo_locked=True,
            verbose=True)
        finally:
            lco_tree.unlock()
        # L L U
        lco_tree.lock_write()
        lco_tree.branch.repository.unlock()
        try:
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
            lco_tree, repo_branch=repo_branch,
            tree_locked=True,
            branch_locked=True,
            verbose=True)
        finally:
            lco_tree.branch.repository.lock_write()
            lco_tree.unlock()
        # L U U
        lco_tree.lock_write()
        lco_tree.branch.unlock()
        try:
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
            lco_tree, repo_branch=repo_branch,
            tree_locked=True,
            verbose=True)
        finally:
            lco_tree.branch.lock_write()
            lco_tree.unlock()
        # L U L
        lco_tree.lock_write()
        lco_tree.branch.unlock()
        lco_tree.branch.repository.lock_write()
        try:
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
            lco_tree, repo_branch=repo_branch,
            tree_locked=True,
            repo_locked=True,
            verbose=True)
        finally:
            lco_tree.branch.repository.unlock()
            lco_tree.branch.lock_write()
            lco_tree.unlock()
        # U L U
        lco_tree.branch.lock_write()
        lco_tree.branch.repository.unlock()
        try:
            self.assertCheckoutStatusOutput('-v tree/lightcheckout',
            lco_tree, repo_branch=repo_branch,
            branch_locked=True,
            verbose=True)
        finally:
            lco_tree.branch.repository.lock_write()
            lco_tree.branch.unlock()

        if sys.platform == 'win32':
            self.knownFailure('Win32 cannot run "bzr info"'
                              ' when the tree is locked.')
コード例 #6
0
    def apply(self, force=False):
        """Apply the reconfiguration

        :param force: If true, the reconfiguration is applied even if it will
            destroy local changes.
        :raise errors.UncommittedChanges: if the local tree is to be destroyed
            but contains uncommitted changes.
        :raise errors.NoBindLocation: if no bind location was specified and
            none could be autodetected.
        """
        if not force:
            self._check()
        if self._create_repository:
            repo = self.bzrdir.create_repository()
            if self.local_branch and not self._destroy_branch:
                repo.fetch(self.local_branch.repository,
                           self.local_branch.last_revision())
        else:
            repo = self.repository
        if self._create_branch and self.referenced_branch is not None:
            repo.fetch(self.referenced_branch.repository,
                       self.referenced_branch.last_revision())
        if self._create_reference:
            reference_branch = branch.Branch.open(self._select_bind_location())
        if self._destroy_repository:
            if self._create_reference:
                reference_branch.repository.fetch(self.repository)
            elif self.local_branch is not None and not self._destroy_branch:
                up = self.local_branch.bzrdir.root_transport.clone('..')
                up_bzrdir = bzrdir.BzrDir.open_containing_from_transport(up)[0]
                new_repo = up_bzrdir.find_repository()
                new_repo.fetch(self.repository)
        last_revision_info = None
        if self._destroy_reference:
            last_revision_info = self.referenced_branch.last_revision_info()
            self.bzrdir.destroy_branch()
        if self._destroy_branch:
            last_revision_info = self.local_branch.last_revision_info()
            if self._create_reference:
                self.local_branch.tags.merge_to(reference_branch.tags)
            self.bzrdir.destroy_branch()
        if self._create_branch:
            local_branch = self.bzrdir.create_branch()
            if last_revision_info is not None:
                local_branch.set_last_revision_info(*last_revision_info)
            if self._destroy_reference:
                self.referenced_branch.tags.merge_to(local_branch.tags)
        else:
            local_branch = self.local_branch
        if self._create_reference:
            format = branch.BranchReferenceFormat().initialize(self.bzrdir,
                reference_branch)
        if self._destroy_tree:
            self.bzrdir.destroy_workingtree()
        if self._create_tree:
            self.bzrdir.create_workingtree()
        if self._unbind:
            self.local_branch.unbind()
        if self._bind:
            bind_location = self._select_bind_location()
            local_branch.bind(branch.Branch.open(bind_location))
        if self._destroy_repository:
            self.bzrdir.destroy_repository()