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

  • Committer: Jan Hudec
  • Date: 2006-11-25 20:38:39 UTC
  • mto: (2199.1.1 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 2200.
  • Revision ID: bulb@ucw.cz-20061125203839-9nuhv32z63hb8811
Option --pull for merge command.

Option --pull was added to merge command, that, if the merge would be
trivial, ie. if the common ancestor is equal to the local tip, causes pull of
the remote instead of creating the merger.

Simple test for this option is included.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2006 Canonical Ltd
 
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
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
"""External tests of 'bzr ls'"""
 
18
 
 
19
import os
 
20
 
 
21
from bzrlib import ignores
 
22
from bzrlib.tests import TestCaseWithTransport
 
23
 
 
24
 
 
25
class TestLS(TestCaseWithTransport):
 
26
 
 
27
    def setUp(self):
 
28
        super(TestLS, self).setUp()
 
29
        
 
30
        # Create a simple branch that can be used in testing
 
31
        ignores._set_user_ignores(['user-ignore'])
 
32
 
 
33
        self.wt = self.make_branch_and_tree('.')
 
34
        self.build_tree_contents([
 
35
                                 ('.bzrignore', '*.pyo\n'),
 
36
                                 ('a', 'hello\n'),
 
37
                                 ])
 
38
 
 
39
    def ls_equals(self, value, *args):
 
40
        out, err = self.run_bzr('ls', *args)
 
41
        self.assertEqual('', err)
 
42
        self.assertEqual(value, out)
 
43
 
 
44
    def test_ls_null_verbose(self):
 
45
        # Can't supply both
 
46
        self.run_bzr_error(['Cannot set both --verbose and --null'],
 
47
                           'ls', '--verbose', '--null')
 
48
 
 
49
    def test_ls_basic(self):
 
50
        """Test the abilities of 'bzr ls'"""
 
51
        self.ls_equals('.bzrignore\na\n')
 
52
        self.ls_equals('?        .bzrignore\n'
 
53
                       '?        a\n',
 
54
                       '--verbose')
 
55
        self.ls_equals('.bzrignore\n'
 
56
                       'a\n',
 
57
                       '--unknown')
 
58
        self.ls_equals('', '--ignored')
 
59
        self.ls_equals('', '--versioned')
 
60
        self.ls_equals('.bzrignore\n'
 
61
                       'a\n',
 
62
                       '--unknown', '--ignored', '--versioned')
 
63
        self.ls_equals('', '--ignored', '--versioned')
 
64
        self.ls_equals('.bzrignore\0a\0', '--null')
 
65
 
 
66
    def test_ls_added(self):
 
67
        self.wt.add(['a'])
 
68
        self.ls_equals('?        .bzrignore\n'
 
69
                       'V        a\n',
 
70
                       '--verbose')
 
71
        self.wt.commit('add')
 
72
        
 
73
        self.build_tree(['subdir/'])
 
74
        self.ls_equals('?        .bzrignore\n'
 
75
                       'V        a\n'
 
76
                       '?        subdir/\n'
 
77
                       , '--verbose')
 
78
        self.build_tree(['subdir/b'])
 
79
        self.wt.add(['subdir/', 'subdir/b', '.bzrignore'])
 
80
        self.ls_equals('V        .bzrignore\n'
 
81
                       'V        a\n'
 
82
                       'V        subdir/\n'
 
83
                       'V        subdir/b\n'
 
84
                       , '--verbose')
 
85
 
 
86
    def test_ls_recursive(self):
 
87
        self.build_tree(['subdir/', 'subdir/b'])
 
88
        self.wt.add(['a', 'subdir/', 'subdir/b', '.bzrignore'])
 
89
 
 
90
        self.ls_equals('.bzrignore\n'
 
91
                       'a\n'
 
92
                       'subdir\n'
 
93
                       , '--non-recursive')
 
94
 
 
95
        self.ls_equals('V        .bzrignore\n'
 
96
                       'V        a\n'
 
97
                       'V        subdir/\n'
 
98
                       , '--verbose', '--non-recursive')
 
99
 
 
100
        # Check what happens in a sub-directory
 
101
        os.chdir('subdir')
 
102
        self.ls_equals('b\n')
 
103
        self.ls_equals('b\0'
 
104
                  , '--null')
 
105
        self.ls_equals('.bzrignore\n'
 
106
                       'a\n'
 
107
                       'subdir\n'
 
108
                       'subdir/b\n'
 
109
                       , '--from-root')
 
110
        self.ls_equals('.bzrignore\0'
 
111
                       'a\0'
 
112
                       'subdir\0'
 
113
                       'subdir/b\0'
 
114
                       , '--from-root', '--null')
 
115
        self.ls_equals('.bzrignore\n'
 
116
                       'a\n'
 
117
                       'subdir\n'
 
118
                       , '--from-root', '--non-recursive')
 
119
 
 
120
    def test_ls_revision(self):
 
121
        self.wt.add(['a'])
 
122
        self.wt.commit('add')
 
123
 
 
124
        self.build_tree(['subdir/'])
 
125
 
 
126
        # Check what happens when we supply a specific revision
 
127
        self.ls_equals('a\n', '--revision', '1')
 
128
        self.ls_equals('V        a\n'
 
129
                       , '--verbose', '--revision', '1')
 
130
 
 
131
        os.chdir('subdir')
 
132
        self.ls_equals('', '--revision', '1')
 
133
 
 
134
    def test_ls_ignored(self):
 
135
        # Now try to do ignored files.
 
136
        self.wt.add(['a', '.bzrignore'])
 
137
 
 
138
        self.build_tree(['blah.py', 'blah.pyo', 'user-ignore'])
 
139
        self.ls_equals('.bzrignore\n'
 
140
                       'a\n'
 
141
                       'blah.py\n'
 
142
                       'blah.pyo\n'
 
143
                       'user-ignore\n'
 
144
                       )
 
145
        self.ls_equals('V        .bzrignore\n'
 
146
                       'V        a\n'
 
147
                       '?        blah.py\n'
 
148
                       'I        blah.pyo\n'
 
149
                       'I        user-ignore\n'
 
150
                       , '--verbose')
 
151
        self.ls_equals('blah.pyo\n'
 
152
                       'user-ignore\n'
 
153
                       , '--ignored')
 
154
        self.ls_equals('blah.py\n'
 
155
                       , '--unknown')
 
156
        self.ls_equals('.bzrignore\n'
 
157
                       'a\n'
 
158
                       , '--versioned')
 
159