/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2006-07-18 18:57:54 UTC
  • mto: This revision was merged to the branch mainline in revision 1868.
  • Revision ID: john@arbash-meinel.com-20060718185754-4007745748e28db9
Commit timestamp restricted to 1ms precision.

The old code would restrict to 1s resolution if the timestamp was
supplied, while it preserved full resolution if the timestamp was
auto generated. Now both paths preserve only 1ms resolution.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2010 Canonical Ltd
2
 
#
3
 
# This program is free software; you can redistribute it and/or modify
4
 
# it under the terms of the GNU General Public License as published by
5
 
# the Free Software Foundation; either version 2 of the License, or
6
 
# (at your option) any later version.
7
 
#
8
 
# This program is distributed in the hope that it will be useful,
9
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
# GNU General Public License for more details.
12
 
#
13
 
# You should have received a copy of the GNU General Public License
14
 
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
 
18
 
import os
19
 
 
20
 
from bzrlib import (
21
 
    bzrdir,
22
 
    osutils,
23
 
    repository,
24
 
    tests,
25
 
    workingtree,
26
 
    )
27
 
 
28
 
 
29
 
class TestJoin(tests.TestCaseWithTransport):
30
 
 
31
 
    def make_trees(self):
32
 
        base_tree = self.make_branch_and_tree('tree',
33
 
            format='dirstate-with-subtree')
34
 
        base_tree.commit('empty commit')
35
 
        self.build_tree(['tree/subtree/', 'tree/subtree/file1'])
36
 
        sub_tree = self.make_branch_and_tree('tree/subtree')
37
 
        sub_tree.set_root_id('subtree-root-id')
38
 
        sub_tree.add('file1', 'file1-id')
39
 
        sub_tree.commit('added file1')
40
 
        return base_tree, sub_tree
41
 
 
42
 
    def check_success(self, path):
43
 
        base_tree = workingtree.WorkingTree.open(path)
44
 
        self.assertEqual('file1-id', base_tree.path2id('subtree/file1'))
45
 
 
46
 
    def test_join(self):
47
 
        base_tree, sub_tree = self.make_trees()
48
 
        self.run_bzr('join tree/subtree')
49
 
        self.check_success('tree')
50
 
 
51
 
    def test_join_dot(self):
52
 
        base_tree, sub_tree = self.make_trees()
53
 
        self.run_bzr('join .', working_dir='tree/subtree')
54
 
        self.check_success('tree')
55
 
 
56
 
    def test_join_error(self):
57
 
        base_tree, sub_tree = self.make_trees()
58
 
        os.mkdir('tree/subtree2')
59
 
        osutils.rename('tree/subtree', 'tree/subtree2/subtree')
60
 
        self.run_bzr_error(
61
 
            ('Cannot join .*subtree.  Parent directory is not versioned',),
62
 
             'join tree/subtree2/subtree')
63
 
        # disabled because this gives an ugly error at present -- mbp 20070306
64
 
        ## self.run_bzr_error(
65
 
        ##     ('Cannot join .*subtree.  Parent directory is not versioned',),
66
 
        ##      'join', '--reference', 'tree/subtree2/subtree')
67
 
        self.run_bzr_error(('Not a branch:.*subtree2',),
68
 
                           'join tree/subtree2')
69
 
 
70
 
    def test_join_reference(self):
71
 
        """Join can add a reference if --reference is supplied"""
72
 
        base_tree, sub_tree = self.make_trees()
73
 
        self.run_bzr('join . --reference', working_dir='tree/subtree')
74
 
        sub_tree.lock_read()
75
 
        self.addCleanup(sub_tree.unlock)
76
 
        self.assertEqual('file1-id', sub_tree.path2id('file1'))
77
 
        self.assertTrue('file1-id' in sub_tree)
78
 
        self.assertEqual('subtree-root-id', sub_tree.path2id(''))
79
 
        self.assertEqual('', sub_tree.id2path('subtree-root-id'))
80
 
        self.assertIs(None, base_tree.path2id('subtree/file1'))
81
 
        base_tree.lock_read()
82
 
        self.addCleanup(base_tree.unlock)
83
 
        self.assertTrue('file1-id' not in base_tree)
84
 
        self.assertEqual('subtree-root-id', base_tree.path2id('subtree'))
85
 
        self.assertEqual('subtree', base_tree.id2path('subtree-root-id'))
86
 
 
87
 
    def test_references_check_repository_support(self):
88
 
        """Users are stopped from adding a reference that can't be committed."""
89
 
        # in 0.15 the default format has a dirstate workingtree, that can
90
 
        # support tree references, but the default repository format
91
 
        # cannot.
92
 
        tree = self.make_branch_and_tree('tree', format='dirstate')
93
 
        tree2 = self.make_branch_and_tree('tree/subtree')
94
 
        out, err = self.run_bzr('join --reference tree/subtree',
95
 
                                retcode=3)
96
 
        self.assertContainsRe(err, r"Can't join trees")
97
 
        self.assertContainsRe(err, r"use bzr upgrade")
98
 
 
99