~bzr-pqm/bzr/bzr.dev

2052.3.1 by John Arbash Meinel
Add tests to cleanup the copyright of all source files
1
# Copyright (C) 2006 Canonical Ltd
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
2
#
1733.2.1 by Michael Ellerman
Add an optional location parameter to the 'revision-history' command.
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.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
7
#
1733.2.1 by Michael Ellerman
Add an optional location parameter to the 'revision-history' command.
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.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
12
#
1733.2.1 by Michael Ellerman
Add an optional location parameter to the 'revision-history' command.
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
1733.2.1 by Michael Ellerman
Add an optional location parameter to the 'revision-history' command.
16
17
import os
18
from bzrlib.tests import TestCaseWithTransport
19
from bzrlib.branch import Branch
20
21
22
class TestRevisionHistory(TestCaseWithTransport):
23
24
    def _build_branch(self):
25
        # setup a standalone branch with three commits
26
        tree = self.make_branch_and_tree('test')
27
        open('test/foo', 'wb').write('1111\n')
28
        tree.add('foo')
29
        tree.commit('added foo',rev_id='revision_1')
30
        open('test/foo', 'wb').write('2222\n')
31
        tree.commit('updated foo',rev_id='revision_2')
32
        open('test/foo', 'wb').write('3333\n')
33
        tree.commit('updated foo again',rev_id='revision_3')
34
        return tree
35
36
    def _check_revision_history(self, location=''):
2530.3.4 by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr
37
        rh = self.run_bzr(['revision-history', location])[0]
1733.2.1 by Michael Ellerman
Add an optional location parameter to the 'revision-history' command.
38
        self.assertEqual(rh, 'revision_1\nrevision_2\nrevision_3\n')
39
40
    def test_revision_history(self):
41
        """Tests 'revision_history' command"""
42
        self._build_branch()
43
        os.chdir('test')
44
        self._check_revision_history()
45
46
    def test_revision_history_with_location(self):
47
        """Tests 'revision_history' command with a specified location."""
48
        self._build_branch()
49
        self._check_revision_history('test')
50
51
    def test_revision_history_with_repo_branch(self):
52
        """Tests 'revision_history' command with a location that is a
53
        repository branch."""
54
        self._build_branch()
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
55
        self.run_bzr('init-repo repo')
56
        self.run_bzr('branch test repo/test')
1733.2.1 by Michael Ellerman
Add an optional location parameter to the 'revision-history' command.
57
        self._check_revision_history('repo/test')
58
59
    def test_revision_history_with_checkout(self):
60
        """Tests 'revision_history' command with a location that is a
61
        checkout of a repository branch."""
62
        self._build_branch()
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
63
        self.run_bzr('init-repo repo')
64
        self.run_bzr('branch test repo/test')
65
        self.run_bzr('checkout repo/test test-checkout')
1733.2.1 by Michael Ellerman
Add an optional location parameter to the 'revision-history' command.
66
        self._check_revision_history('test-checkout')
67
68
    def test_revision_history_with_lightweight_checkout(self):
69
        """Tests 'revision_history' command with a location that is a
70
        lightweight checkout of a repository branch."""
71
        self._build_branch()
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
72
        self.run_bzr('init-repo repo')
73
        self.run_bzr('branch test repo/test')
74
        self.run_bzr('checkout --lightweight repo/test test-checkout')
1733.2.1 by Michael Ellerman
Add an optional location parameter to the 'revision-history' command.
75
        self._check_revision_history('test-checkout')