/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_revno.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2009, 2011, 2012, 2016 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
 
"""Black-box tests for brz revno.
 
18
"""Black-box tests for bzr revno.
19
19
"""
20
20
 
21
21
import os
22
22
 
23
 
from breezy import tests
24
 
from breezy.tests.matchers import ContainsNoVfsCalls
 
23
from bzrlib import tests
 
24
from bzrlib.tests.matchers import ContainsNoVfsCalls
25
25
 
26
26
 
27
27
class TestRevno(tests.TestCaseWithTransport):
34
34
        os.mkdir('a')
35
35
        os.chdir('a')
36
36
        bzr('init')
37
 
        self.assertEqual(int(bzr('revno')), 0)
 
37
        self.assertEquals(int(bzr('revno')), 0)
38
38
 
39
39
        with open('foo', 'wb') as f: f.write('foo\n')
40
40
        bzr('add foo')
41
41
        bzr('commit -m foo')
42
 
        self.assertEqual(int(bzr('revno')), 1)
 
42
        self.assertEquals(int(bzr('revno')), 1)
43
43
 
44
44
        os.mkdir('baz')
45
45
        bzr('add baz')
46
46
        bzr('commit -m baz')
47
 
        self.assertEqual(int(bzr('revno')), 2)
 
47
        self.assertEquals(int(bzr('revno')), 2)
48
48
 
49
49
        os.chdir('..')
50
 
        self.assertEqual(int(bzr('revno a')), 2)
51
 
        self.assertEqual(int(bzr('revno a/baz')), 2)
 
50
        self.assertEquals(int(bzr('revno a')), 2)
 
51
        self.assertEquals(int(bzr('revno a/baz')), 2)
52
52
 
53
53
    def test_revno_tree(self):
54
54
        # Make branch and checkout
61
61
        wt.commit('mkfile')
62
62
 
63
63
        # Make sure revno says we're on 1
64
 
        out, err = self.run_bzr('revno checkout')
 
64
        out,err = self.run_bzr('revno checkout')
65
65
        self.assertEqual('', err)
66
66
        self.assertEqual('1\n', out)
67
67
 
68
68
        # Make sure --tree knows it's still on 0
69
 
        out, err = self.run_bzr('revno --tree checkout')
 
69
        out,err = self.run_bzr('revno --tree checkout')
70
70
        self.assertEqual('', err)
71
71
        self.assertEqual('0\n', out)
72
72
 
75
75
        b = self.make_branch('branch')
76
76
 
77
77
        # Try getting it's --tree revno
78
 
        out, err = self.run_bzr('revno --tree branch', retcode=3)
 
78
        out,err = self.run_bzr('revno --tree branch', retcode=3)
79
79
        self.assertEqual('', out)
80
 
        self.assertEqual('brz: ERROR: No WorkingTree exists for "branch".\n',
 
80
        self.assertEqual('bzr: ERROR: No WorkingTree exists for "branch".\n',
81
81
            err)
82
82
 
83
83
    def test_dotted_revno_tree(self):
84
84
        builder = self.make_branch_builder('branch')
85
85
        builder.start_series()
86
 
        builder.build_snapshot(None, [
 
86
        builder.build_snapshot('A-id', None, [
87
87
            ('add', ('', 'root-id', 'directory', None)),
88
 
            ('add', ('file', 'file-id', 'file', 'content\n'))],
89
 
            revision_id=b'A-id')
90
 
        builder.build_snapshot(['A-id'], [], revision_id=b'B-id')
91
 
        builder.build_snapshot(['A-id', 'B-id'], [], revision_id=b'C-id')
 
88
            ('add', ('file', 'file-id', 'file', 'content\n'))])
 
89
        builder.build_snapshot('B-id', ['A-id'], [])
 
90
        builder.build_snapshot('C-id', ['A-id', 'B-id'], [])
92
91
        builder.finish_series()
93
92
        b = builder.get_branch()
94
93
        co_b = b.create_checkout('checkout_b', lightweight=True,
95
 
                                 revision_id=b'B-id')
 
94
                                 revision_id='B-id')
96
95
        out, err = self.run_bzr('revno checkout_b')
97
96
        self.assertEqual('', err)
98
97
        self.assertEqual('2\n', out)
103
102
    def test_stale_revno_tree(self):
104
103
        builder = self.make_branch_builder('branch')
105
104
        builder.start_series()
106
 
        builder.build_snapshot(None, [
107
 
            ('add', ('', b'root-id', 'directory', None)),
108
 
            ('add', ('file', b'file-id', 'file', 'content\n'))],
109
 
            revision_id=b'A-id')
110
 
        builder.build_snapshot(['A-id'], [], revision_id=b'B-id')
111
 
        builder.build_snapshot(['A-id'], [], revision_id=b'C-id')
 
105
        builder.build_snapshot('A-id', None, [
 
106
            ('add', ('', 'root-id', 'directory', None)),
 
107
            ('add', ('file', 'file-id', 'file', 'content\n'))])
 
108
        builder.build_snapshot('B-id', ['A-id'], [])
 
109
        builder.build_snapshot('C-id', ['A-id'], [])
112
110
        builder.finish_series()
113
111
        b = builder.get_branch()
114
112
        # The branch is now at "C-id", but the checkout is still at "B-id"
115
113
        # which is no longer in the history
116
114
        co_b = b.create_checkout('checkout_b', lightweight=True,
117
 
                                 revision_id=b'B-id')
 
115
                                 revision_id='B-id')
118
116
        out, err = self.run_bzr('revno checkout_b')
119
117
        self.assertEqual('', err)
120
118
        self.assertEqual('2\n', out)
138
136
        out, err = self.run_bzr('revno -r-2 --tree .', retcode=3)
139
137
        self.assertEqual('', out)
140
138
        self.assertEqual(
141
 
            'brz: ERROR: --tree and --revision can not be used together\n',
 
139
            'bzr: ERROR: --tree and --revision can not be used together\n',
142
140
            err)
143
141
 
144
142
 
147
145
    def test_simple_branch_revno(self):
148
146
        self.setup_smart_server_with_call_log()
149
147
        t = self.make_branch_and_tree('branch')
150
 
        self.build_tree_contents([('branch/foo', b'thecontents')])
 
148
        self.build_tree_contents([('branch/foo', 'thecontents')])
151
149
        t.add("foo")
152
150
        revid = t.commit("message")
153
151
        self.reset_smart_call_log()
164
162
    def test_simple_branch_revno_lookup(self):
165
163
        self.setup_smart_server_with_call_log()
166
164
        t = self.make_branch_and_tree('branch')
167
 
        self.build_tree_contents([('branch/foo', b'thecontents')])
 
165
        self.build_tree_contents([('branch/foo', 'thecontents')])
168
166
        t.add("foo")
169
167
        revid1 = t.commit("message")
170
168
        revid2 = t.commit("message")