~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

(mbp) tolerate empty limbo and pending-deletion directories (bug 427773)
 (Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Canonical Ltd
2
 
# -*- coding: utf-8 -*-
 
1
# Copyright (C) 2005, 2006, 2007, 2009 Canonical Ltd
3
2
#
4
3
# This program is free software; you can redistribute it and/or modify
5
4
# it under the terms of the GNU General Public License as published by
13
12
#
14
13
# You should have received a copy of the GNU General Public License
15
14
# along with this program; if not, write to the Free Software
16
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
16
 
18
17
 
19
18
"""Black-box tests for bzr revno.
21
20
 
22
21
import os
23
22
 
24
 
from bzrlib.branch import Branch
25
 
from bzrlib.tests import TestCaseInTempDir
 
23
from bzrlib import tests
26
24
 
27
 
class TestRevno(TestCaseInTempDir):
 
25
class TestRevno(tests.TestCaseWithTransport):
28
26
 
29
27
    def test_revno(self):
30
28
 
50
48
        self.assertEquals(int(bzr('revno a')), 2)
51
49
        self.assertEquals(int(bzr('revno a/baz')), 2)
52
50
 
53
 
 
 
51
    def test_revno_tree(self):
 
52
        # Make branch and checkout
 
53
        wt = self.make_branch_and_tree('branch')
 
54
        checkout = wt.branch.create_checkout('checkout', lightweight=True)
 
55
 
 
56
        # Get the checkout out of date
 
57
        self.build_tree(['branch/file'])
 
58
        wt.add(['file'])
 
59
        wt.commit('mkfile')
 
60
 
 
61
        # Make sure revno says we're on 1
 
62
        out,err = self.run_bzr('revno checkout')
 
63
        self.assertEqual('', err)
 
64
        self.assertEqual('1\n', out)
 
65
 
 
66
        # Make sure --tree knows it's still on 0
 
67
        out,err = self.run_bzr('revno --tree checkout')
 
68
        self.assertEqual('', err)
 
69
        self.assertEqual('0\n', out)
 
70
 
 
71
    def test_revno_tree_no_tree(self):
 
72
        # Make treeless branch
 
73
        b = self.make_branch('branch')
 
74
 
 
75
        # Try getting it's --tree revno
 
76
        out,err = self.run_bzr('revno --tree branch', retcode=3)
 
77
        self.assertEqual('', out)
 
78
        self.assertEqual('bzr: ERROR: No WorkingTree exists for "branch".\n',
 
79
            err)
 
80
 
 
81
    def test_dotted_revno_tree(self):
 
82
        builder = self.make_branch_builder('branch')
 
83
        builder.start_series()
 
84
        builder.build_snapshot('A-id', None, [
 
85
            ('add', ('', 'root-id', 'directory', None)),
 
86
            ('add', ('file', 'file-id', 'file', 'content\n'))])
 
87
        builder.build_snapshot('B-id', ['A-id'], [])
 
88
        builder.build_snapshot('C-id', ['A-id', 'B-id'], [])
 
89
        builder.finish_series()
 
90
        b = builder.get_branch()
 
91
        co_b = b.create_checkout('checkout_b', lightweight=True,
 
92
                                 revision_id='B-id')
 
93
        out, err = self.run_bzr('revno checkout_b')
 
94
        self.assertEqual('', err)
 
95
        self.assertEqual('2\n', out)
 
96
        out, err = self.run_bzr('revno --tree checkout_b')
 
97
        self.assertEqual('', err)
 
98
        self.assertEqual('1.1.1\n', out)
 
99
 
 
100
    def test_stale_revno_tree(self):
 
101
        builder = self.make_branch_builder('branch')
 
102
        builder.start_series()
 
103
        builder.build_snapshot('A-id', None, [
 
104
            ('add', ('', 'root-id', 'directory', None)),
 
105
            ('add', ('file', 'file-id', 'file', 'content\n'))])
 
106
        builder.build_snapshot('B-id', ['A-id'], [])
 
107
        builder.build_snapshot('C-id', ['A-id'], [])
 
108
        builder.finish_series()
 
109
        b = builder.get_branch()
 
110
        # The branch is now at "C-id", but the checkout is still at "B-id"
 
111
        # which is no longer in the history
 
112
        co_b = b.create_checkout('checkout_b', lightweight=True,
 
113
                                 revision_id='B-id')
 
114
        out, err = self.run_bzr('revno checkout_b')
 
115
        self.assertEqual('', err)
 
116
        self.assertEqual('2\n', out)
 
117
        out, err = self.run_bzr('revno --tree checkout_b')
 
118
        self.assertEqual('', err)
 
119
        self.assertEqual('???\n', out)