~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2012-01-06 22:44:57 UTC
  • mfrom: (6436 +trunk)
  • mto: (6437.3.11 2.5)
  • mto: This revision was merged to the branch mainline in revision 6444.
  • Revision ID: jelmer@samba.org-20120106224457-re0pcy0fz31xob77
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2009, 2012 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
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
import os
18
 
from bzrlib.tests import TestCaseWithTransport
19
 
from bzrlib.branch import Branch
20
 
 
21
 
 
22
 
class TestRevisionHistory(TestCaseWithTransport):
 
17
from bzrlib import (
 
18
    branch,
 
19
    tests,
 
20
    )
 
21
 
 
22
 
 
23
class TestRevisionHistory(tests.TestCaseWithTransport):
23
24
 
24
25
    def _build_branch(self):
25
26
        # setup a standalone branch with three commits
26
27
        tree = self.make_branch_and_tree('test')
27
 
        open('test/foo', 'wb').write('1111\n')
 
28
        with open('test/foo', 'wb') as f:
 
29
            f.write('1111\n')
28
30
        tree.add('foo')
29
31
        tree.commit('added foo',rev_id='revision_1')
30
 
        open('test/foo', 'wb').write('2222\n')
 
32
        with open('test/foo', 'wb')as f:
 
33
            f.write('2222\n')
31
34
        tree.commit('updated foo',rev_id='revision_2')
32
 
        open('test/foo', 'wb').write('3333\n')
 
35
        with open('test/foo', 'wb')as f:
 
36
            f.write('3333\n')
33
37
        tree.commit('updated foo again',rev_id='revision_3')
34
38
        return tree
35
39
 
36
 
    def _check_revision_history(self, location=''):
37
 
        rh = self.run_bzr(['revision-history', location])[0]
 
40
    def _check_revision_history(self, location='', working_dir=None):
 
41
        rh = self.run_bzr(['revision-history', location],
 
42
                          working_dir=working_dir)[0]
38
43
        self.assertEqual(rh, 'revision_1\nrevision_2\nrevision_3\n')
39
44
 
40
45
    def test_revision_history(self):
41
 
        """Tests 'revision_history' command"""
 
46
        """No location"""
42
47
        self._build_branch()
43
 
        os.chdir('test')
44
 
        self._check_revision_history()
 
48
        self._check_revision_history(working_dir='test')
45
49
 
46
50
    def test_revision_history_with_location(self):
47
 
        """Tests 'revision_history' command with a specified location."""
 
51
        """With a specified location."""
48
52
        self._build_branch()
49
53
        self._check_revision_history('test')
50
54
 
51
55
    def test_revision_history_with_repo_branch(self):
52
 
        """Tests 'revision_history' command with a location that is a
53
 
        repository branch."""
 
56
        """With a repository branch location."""
54
57
        self._build_branch()
55
58
        self.run_bzr('init-repo repo')
56
59
        self.run_bzr('branch test repo/test')
57
60
        self._check_revision_history('repo/test')
58
61
 
59
62
    def test_revision_history_with_checkout(self):
60
 
        """Tests 'revision_history' command with a location that is a
61
 
        checkout of a repository branch."""
 
63
        """With a repository branch checkout location."""
62
64
        self._build_branch()
63
65
        self.run_bzr('init-repo repo')
64
66
        self.run_bzr('branch test repo/test')
66
68
        self._check_revision_history('test-checkout')
67
69
 
68
70
    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
        """With a repository branch lightweight checkout location."""
71
72
        self._build_branch()
72
73
        self.run_bzr('init-repo repo')
73
74
        self.run_bzr('branch test repo/test')