/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
5273.1.8 by Vincent Ladeuil
Merge bzr.dev into cleanup
1
# Copyright (C) 2007-2010 Canonical Ltd
1551.13.18 by Aaron Bentley
Add copyright notice
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
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1551.13.18 by Aaron Bentley
Add copyright notice
16
5283.4.1 by Martin Pool
Deprecate ExternalBase.check_output and update some callers to use scripts
17
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
18
from breezy.tests import TestCaseWithTransport
5283.4.1 by Martin Pool
Deprecate ExternalBase.check_output and update some callers to use scripts
19
20
21
class TestCatRevision(TestCaseWithTransport):
1551.13.17 by Aaron Bentley
Move cat-revision tests out of test_revision_info
22
23
    def test_cat_unicode_revision(self):
1551.13.16 by Aaron Bentley
Fix cat-revision REVISION
24
        tree = self.make_branch_and_tree('.')
6855.4.1 by Jelmer Vernooij
Yet more bees.
25
        tree.commit('This revision', rev_id=b'abcd')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
26
        output, errors = self.run_bzr(['cat-revision', u'abcd'])
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
27
        self.assertContainsRe(output, 'This revision')
28
        self.assertEqual('', errors)
1551.13.17 by Aaron Bentley
Move cat-revision tests out of test_revision_info
29
30
    def test_cat_revision(self):
6622.1.29 by Jelmer Vernooij
Fix some more tests.
31
        """Test brz cat-revision.
1551.13.17 by Aaron Bentley
Move cat-revision tests out of test_revision_info
32
        """
33
        wt = self.make_branch_and_tree('.')
34
        r = wt.branch.repository
35
6855.4.1 by Jelmer Vernooij
Yet more bees.
36
        wt.commit('Commit one', rev_id=b'a@r-0-1')
37
        wt.commit('Commit two', rev_id=b'a@r-0-2')
38
        wt.commit('Commit three', rev_id=b'a@r-0-3')
1551.13.17 by Aaron Bentley
Move cat-revision tests out of test_revision_info
39
6754.8.4 by Jelmer Vernooij
Use new context stuff.
40
        with r.lock_read():
5035.2.1 by Jelmer Vernooij
Repository.get_revision_xml() has been removed.
41
            revs = {}
42
            for i in (1, 2, 3):
7045.3.1 by Jelmer Vernooij
Fix another ~500 tests.
43
                revid = b"a@r-0-%d" % i
7143.15.2 by Jelmer Vernooij
Run autopep8.
44
                stream = r.revisions.get_record_stream([(revid,)], 'unordered',
45
                                                       False)
7018.3.10 by Jelmer Vernooij
Consistent return values in PreviewTree.list_files.
46
                revs[i] = next(stream).get_bytes_as('fulltext')
1551.13.17 by Aaron Bentley
Move cat-revision tests out of test_revision_info
47
5283.4.1 by Martin Pool
Deprecate ExternalBase.check_output and update some callers to use scripts
48
        for i in [1, 2, 3]:
49
            self.assertEqual(revs[i],
7143.15.2 by Jelmer Vernooij
Run autopep8.
50
                             self.run_bzr('cat-revision -r revid:a@r-0-%d' % i)[0].encode('utf-8'))
51
            self.assertEqual(revs[i],
52
                             self.run_bzr('cat-revision a@r-0-%d' % i)[0].encode('utf-8'))
53
            self.assertEqual(revs[i],
54
                             self.run_bzr('cat-revision -r %d' % i)[0].encode('utf-8'))
3668.4.1 by Jelmer Vernooij
Show proper error rather than traceback when an unknown revision id is specified to bzr cat-revision.
55
56
    def test_cat_no_such_revid(self):
57
        tree = self.make_branch_and_tree('.')
58
        err = self.run_bzr('cat-revision abcd', retcode=3)[1]
7143.15.2 by Jelmer Vernooij
Run autopep8.
59
        self.assertContainsRe(
60
            err, 'The repository .* contains no revision abcd.')
3668.4.1 by Jelmer Vernooij
Show proper error rather than traceback when an unknown revision id is specified to bzr cat-revision.
61
5171.3.7 by Martin von Gagern
Added blackbox tests for --directory option.
62
    def test_cat_revision_directory(self):
63
        """Test --directory option"""
64
        tree = self.make_branch_and_tree('a')
6855.4.1 by Jelmer Vernooij
Yet more bees.
65
        tree.commit('This revision', rev_id=b'abcd')
5171.3.7 by Martin von Gagern
Added blackbox tests for --directory option.
66
        output, errors = self.run_bzr(['cat-revision', '-d', 'a', u'abcd'])
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
67
        self.assertContainsRe(output, 'This revision')
68
        self.assertEqual('', errors)
5616.4.1 by Jelmer Vernooij
'bzr cat-revision' no longer requires a working tree.
69
70
    def test_cat_tree_less_branch(self):
71
        tree = self.make_branch_and_tree('.')
6855.4.1 by Jelmer Vernooij
Yet more bees.
72
        tree.commit('This revision', rev_id=b'abcd')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
73
        tree.controldir.destroy_workingtree()
5616.4.1 by Jelmer Vernooij
'bzr cat-revision' no longer requires a working tree.
74
        output, errors = self.run_bzr(['cat-revision', '-d', 'a', u'abcd'])
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
75
        self.assertContainsRe(output, 'This revision')
76
        self.assertEqual('', errors)