Example #1
0
    def newtree_cb(self, menu, vfs_file):
        # We can only cope with local files
        if vfs_file.get_uri_scheme() != 'file':
            return

        file = vfs_file.get_uri()

        # We only want to continue here if we get a NotBranchError
        try:
            tree, path = WorkingTree.open_containing(file)
        except NotBranchError:
            BzrDir.create_standalone_workingtree(file)
Example #2
0
    def setup_tree(self):
        wt = BzrDir.create_standalone_workingtree('.')
        wt.commit("base A", allow_pointless=True, rev_id='A')
        wt.commit("base B", allow_pointless=True, rev_id='B')
        wt.commit("base C", allow_pointless=True, rev_id='C')

        return wt
Example #3
0
    def setup_tree(self):
        wt = BzrDir.create_standalone_workingtree('.')
        wt.commit("base A", allow_pointless=True, rev_id='A')
        wt.commit("base B", allow_pointless=True, rev_id='B')
        wt.commit("base C", allow_pointless=True, rev_id='C')

        return wt
Example #4
0
 def prepare_simple_history(self):
     """Prepare and return a working tree with one commit of one file"""
     # Commit with modified file should say so
     wt = BzrDir.create_standalone_workingtree('.')
     self.build_tree(['hello.txt', 'extra.txt'])
     wt.add(['hello.txt'])
     wt.commit(message='added')
     return wt
Example #5
0
 def prepare_simple_history(self):
     """Prepare and return a working tree with one commit of one file"""
     # Commit with modified file should say so
     wt = BzrDir.create_standalone_workingtree('.')
     self.build_tree(['hello.txt', 'extra.txt'])
     wt.add(['hello.txt'])
     wt.commit(message='added')
     return wt
Example #6
0
 def make_trees(self):
     grandparent_tree = BzrDir.create_standalone_workingtree('grandparent')
     self.build_tree_contents([('grandparent/file1', 'grandparent')])
     grandparent_tree.add('file1')
     grandparent_tree.commit('initial commit', rev_id='revision1')
     parent_bzrdir = grandparent_tree.bzrdir.sprout('parent')
     parent_tree = parent_bzrdir.open_workingtree()
     parent_tree.commit('next commit', rev_id='revision2')
     branch_tree = parent_tree.bzrdir.sprout('branch').open_workingtree()
     self.build_tree_contents([('branch/file1', 'branch')])
     branch_tree.commit('last commit', rev_id='revision3')
Example #7
0
 def test_verbose_commit_with_unknown(self):
     """Unknown files should not be listed by default in verbose output"""
     # Is that really the best policy?
     wt = BzrDir.create_standalone_workingtree('.')
     self.build_tree(['hello.txt', 'extra.txt'])
     wt.add(['hello.txt'])
     out,err = self.run_bzr('commit -m added')
     self.assertEqual('', out)
     self.assertContainsRe(err, '^Committing to: .*\n'
                           'added hello\.txt\n'
                           'Committed revision 1\.\n$')
Example #8
0
 def test_verbose_commit_with_unknown(self):
     """Unknown files should not be listed by default in verbose output"""
     # Is that really the best policy?
     wt = BzrDir.create_standalone_workingtree('.')
     self.build_tree(['hello.txt', 'extra.txt'])
     wt.add(['hello.txt'])
     out, err = self.run_bzr('commit -m added')
     self.assertEqual('', out)
     self.assertContainsRe(
         err, '^Committing to: .*\n'
         'added hello\.txt\n'
         'Committed revision 1\.\n$')
Example #9
0
def create_branch_with_one_revision(branch_dir, format=None):
    """Create a dummy Bazaar branch at the given directory."""
    if not os.path.exists(branch_dir):
        os.makedirs(branch_dir)
    try:
        tree = BzrDir.create_standalone_workingtree(branch_dir, format)
    except FileExists:
        return
    f = open(os.path.join(branch_dir, 'hello'), 'w')
    f.write('foo')
    f.close()
    tree.commit('message')
    return tree
Example #10
0
def create_branch_with_one_revision(branch_dir, format=None):
    """Create a dummy Bazaar branch at the given directory."""
    if not os.path.exists(branch_dir):
        os.makedirs(branch_dir)
    try:
        tree = BzrDir.create_standalone_workingtree(branch_dir, format)
    except FileExists:
        return
    f = open(os.path.join(branch_dir, "hello"), "w")
    f.write("foo")
    f.close()
    tree.commit("message")
    return tree
Example #11
0
    def create_branches(self):
        self.build_tree(['base/', 'base/a', 'base/b'])
        format = bzrdir.format_registry.make_bzrdir('knit')
        try:
            wt_base = BzrDir.create_standalone_workingtree(
                self.get_url('base'), format=format)
        except errors.NotLocalUrl:
            raise TestSkipped('Not a local URL')
    
        b_base = wt_base.branch

        wt_base.add('a')
        wt_base.add('b')
        wt_base.commit('first', rev_id='r@b-1')

        wt_child = b_base.bzrdir.sprout('child').open_workingtree()
        self.sftp_base = Branch.open(self.get_url('base'))
        wt_child.branch.bind(self.sftp_base)
        # check the branch histories are ready for using in tests.
        self.assertEqual(['r@b-1'], b_base.revision_history())
        self.assertEqual(['r@b-1'], wt_child.branch.revision_history())
        return b_base, wt_child
Example #12
0
    def create_branches(self):
        self.build_tree(['base/', 'base/a', 'base/b'])
        format = bzrdir.format_registry.make_bzrdir('knit')
        try:
            wt_base = BzrDir.create_standalone_workingtree(
                self.get_url('base'), format=format)
        except errors.NotLocalUrl:
            raise TestSkipped('Not a local URL')

        b_base = wt_base.branch

        wt_base.add('a')
        wt_base.add('b')
        wt_base.commit('first', rev_id='r@b-1')

        wt_child = b_base.bzrdir.sprout('child').open_workingtree()
        self.sftp_base = Branch.open(self.get_url('base'))
        wt_child.branch.bind(self.sftp_base)
        # check the branch histories are ready for using in tests.
        self.assertEqual(['r@b-1'], b_base.revision_history())
        self.assertEqual(['r@b-1'], wt_child.branch.revision_history())
        return b_base, wt_child
Example #13
0
    def test_simple_binding(self):
        self.build_tree(['base/', 'base/a', 'base/b', 'child/'])
        try:
            wt_base = BzrDir.create_standalone_workingtree(
                self.get_url('base'))
        except errors.NotLocalUrl:
            raise TestSkipped('Not a local URL')

        wt_base.add('a')
        wt_base.add('b')
        wt_base.commit('first', rev_id='r@b-1')

        b_base = wt_base.branch
        # manually make a branch we can bind, because the default format
        # may not be bindable-from, and we want to test the side effects etc
        # of bondage.
        format = bzrdir.format_registry.make_bzrdir('knit')
        b_child = BzrDir.create_branch_convenience('child', format=format)
        self.assertEqual(None, b_child.get_bound_location())
        self.assertEqual(None, b_child.get_master_branch())

        sftp_b_base = Branch.open(self.get_url('base'))
        b_child.bind(sftp_b_base)
        self.assertEqual(sftp_b_base.base, b_child.get_bound_location())
        # the bind must not have given b_child history:
        self.assertEqual([], b_child.revision_history())
        # we should be able to update the branch at this point:
        self.assertEqual(None, b_child.update())
        # and now there must be history.
        self.assertEqual(['r@b-1'], b_child.revision_history())
        # this line is more of a working tree test line, but - what the hey,
        # it has work to do.
        b_child.bzrdir.open_workingtree().update()
        self.failUnlessExists('child/a')
        self.failUnlessExists('child/b')

        b_child.unbind()
        self.assertEqual(None, b_child.get_bound_location())
Example #14
0
    def test_simple_binding(self):
        self.build_tree(['base/', 'base/a', 'base/b', 'child/'])
        try:
            wt_base = BzrDir.create_standalone_workingtree(self.get_url('base'))
        except errors.NotLocalUrl:
            raise TestSkipped('Not a local URL')

        wt_base.add('a')
        wt_base.add('b')
        wt_base.commit('first', rev_id='r@b-1')

        b_base = wt_base.branch
        # manually make a branch we can bind, because the default format
        # may not be bindable-from, and we want to test the side effects etc
        # of bondage.
        format = bzrdir.format_registry.make_bzrdir('knit')
        b_child = BzrDir.create_branch_convenience('child', format=format)
        self.assertEqual(None, b_child.get_bound_location())
        self.assertEqual(None, b_child.get_master_branch())

        sftp_b_base = Branch.open(self.get_url('base'))
        b_child.bind(sftp_b_base)
        self.assertEqual(sftp_b_base.base, b_child.get_bound_location())
        # the bind must not have given b_child history:
        self.assertEqual([], b_child.revision_history())
        # we should be able to update the branch at this point:
        self.assertEqual(None, b_child.update())
        # and now there must be history.
        self.assertEqual(['r@b-1'], b_child.revision_history())
        # this line is more of a working tree test line, but - what the hey,
        # it has work to do.
        b_child.bzrdir.open_workingtree().update()
        self.failUnlessExists('child/a')
        self.failUnlessExists('child/b')

        b_child.unbind()
        self.assertEqual(None, b_child.get_bound_location())
 def prepare_tree(self):
     return BzrDir.create_standalone_workingtree(".")
Example #16
0
 def test_merge_reprocess(self):
     d = BzrDir.create_standalone_workingtree('.')
     d.commit('h')
     self.run_bzr('merge . --reprocess --merge-type weave')
Example #17
0
 def prepare_tree(self):
     return BzrDir.create_standalone_workingtree(".")