~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2007-02-13 20:33:57 UTC
  • mfrom: (2283 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2294.
  • Revision ID: john@arbash-meinel.com-20070213203357-b7yg41mi9sk6cqd0
[merge] bzr.dev 2283
resolve conflicts in moved repository formats
small issue with osutils.contains_whitespace()

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
from cStringIO import StringIO
26
26
import codecs
27
 
from os import mkdir, chdir
 
27
from os import mkdir, chdir, rmdir, unlink
28
28
import sys
29
29
from tempfile import TemporaryFile
30
30
 
76
76
            ],
77
77
            wt)
78
78
        self.assertStatus([
79
 
                '?  bye.c\n',
80
 
                '?  hello.c\n',
 
79
                '?   bye.c\n',
 
80
                '?   hello.c\n',
81
81
            ],
82
82
            wt, short=True)
83
83
 
94
94
            ],
95
95
            wt)
96
96
        self.assertStatus([
97
 
                '?  bye.c\n',
98
 
                '?  hello.c\n',
99
 
                'P  pending@pending-0-0\n',
 
97
                '?   bye.c\n',
 
98
                '?   hello.c\n',
 
99
                'P   pending@pending-0-0\n',
100
100
            ],
101
101
            wt, short=True)
102
102
 
174
174
                wt)
175
175
 
176
176
        self.assertStatus([
177
 
                '?  bye.c\n',
178
 
                '?  dir2\n',
179
 
                '?  directory/hello.c\n'
 
177
                '?   bye.c\n',
 
178
                '?   dir2\n',
 
179
                '?   directory/hello.c\n'
180
180
                ],
181
181
                wt, short=True)
182
182
 
197
197
        show_tree_status(wt, specific_files=['directory'], to_file=tof,
198
198
                         short=True)
199
199
        tof.seek(0)
200
 
        self.assertEquals(tof.readlines(), ['?  directory/hello.c\n'])
 
200
        self.assertEquals(tof.readlines(), ['?   directory/hello.c\n'])
201
201
 
202
202
        tof = StringIO()
203
203
        show_tree_status(wt, specific_files=['dir2'], to_file=tof)
209
209
        tof = StringIO()
210
210
        show_tree_status(wt, specific_files=['dir2'], to_file=tof, short=True)
211
211
        tof.seek(0)
212
 
        self.assertEquals(tof.readlines(), ['?  dir2\n'])
 
212
        self.assertEquals(tof.readlines(), ['?   dir2\n'])
213
213
 
214
214
    def test_status_nonexistent_file(self):
215
215
        # files that don't exist in either the basis tree or working tree
258
258
        result = self.run_bzr("status")[0]
259
259
        self.assert_("unknown:\n  hello.txt\n" in result, result)
260
260
        result = self.run_bzr("status","--short")[0]
261
 
        self.assert_("?  hello.txt\n" in result, result)
 
261
        self.assertContainsRe(result, "[?]   hello.txt\n")
262
262
 
263
263
        self.run_bzr("add", "hello.txt")
264
264
        result = self.run_bzr("status")[0]
265
 
        self.assert_("added:\n  hello.txt\n" in result, result)
 
265
        self.assertContainsRe(result, "added:\n  hello.txt\n")
266
266
        result = self.run_bzr("status","--short")[0]
267
 
        self.assert_("A  hello.txt\n" in result, result)
 
267
        self.assertContainsRe(result, "[+]N  hello.txt\n")
268
268
 
269
269
        self.run_bzr("commit", "-m", "added")
270
270
        result = self.run_bzr("status", "-r", "0..1")[0]
271
 
        self.assert_("added:\n  hello.txt\n" in result, result)
 
271
        self.assertContainsRe(result, "added:\n  hello.txt\n")
272
272
        result = self.run_bzr("status", "--short", "-r", "0..1")[0]
273
 
        self.assert_("A  hello.txt\n" in result, result)
 
273
        self.assertContainsRe(result, "[+]N  hello.txt\n")
274
274
 
275
275
        self.build_tree(['world.txt'])
276
276
        result = self.run_bzr("status", "-r", "0")[0]
277
 
        self.assert_("added:\n  hello.txt\n" \
278
 
                     "unknown:\n  world.txt\n" in result, result)
 
277
        self.assertContainsRe(result, "added:\n  hello.txt\n" \
 
278
                                      "unknown:\n  world.txt\n")
279
279
        result2 = self.run_bzr("status", "-r", "0..")[0]
280
280
        self.assertEquals(result2, result)
281
281
        result = self.run_bzr("status", "--short", "-r", "0")[0]
282
 
        self.assert_("A  hello.txt\n" \
283
 
                     "?  world.txt\n" in result, result)
 
282
        self.assertContainsRe(result, "[+]N  hello.txt\n" \
 
283
                                      "[?]   world.txt\n")
284
284
        result2 = self.run_bzr("status", "--short", "-r", "0..")[0]
285
285
        self.assertEquals(result2, result)
286
286
 
 
287
    def assertStatusContains(self, pattern):
 
288
        """Run status, and assert it contains the given pattern"""
 
289
        result = self.run_bzr("status", "--short")[0]
 
290
        self.assertContainsRe(result, pattern)
 
291
 
 
292
    def test_kind_change_short(self):
 
293
        tree = self.make_branch_and_tree('.')
 
294
        self.build_tree(['file'])
 
295
        tree.add('file')
 
296
        tree.commit('added file')
 
297
        unlink('file')
 
298
        self.build_tree(['file/'])
 
299
        self.assertStatusContains('K  file => file/')
 
300
        tree.rename_one('file', 'directory')
 
301
        self.assertStatusContains('RK  file => directory/')
 
302
        rmdir('directory')
 
303
        self.assertStatusContains('RD  file => directory')
 
304
 
287
305
 
288
306
class TestStatusEncodings(TestCaseWithTransport):
289
307