~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2010-07-29 11:17:57 UTC
  • mfrom: (5050.3.17 2.2)
  • mto: This revision was merged to the branch mainline in revision 5365.
  • Revision ID: andrew.bennetts@canonical.com-20100729111757-018h3pcefo7z0dnq
Merge lp:bzr/2.2 into lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    conflicts,
34
34
    errors,
35
35
    osutils,
36
 
    status,
37
36
    )
38
37
import bzrlib.branch
39
38
from bzrlib.osutils import pathjoin
45
44
 
46
45
class BranchStatus(TestCaseWithTransport):
47
46
 
48
 
    def setUp(self):
49
 
        super(BranchStatus, self).setUp()
50
 
        # As TestCase.setUp clears all hooks, we install this default
51
 
        # post_status hook handler for the test.
52
 
        status.hooks.install_named_hook('post_status',
53
 
            status._show_shelve_summary,
54
 
            'bzr status')
55
 
 
56
47
    def assertStatus(self, expected_lines, working_tree,
57
48
        revision=None, short=False, pending=True, verbose=False):
58
49
        """Run status in working_tree and look for output.
211
202
        wt = self.make_branch_and_tree('.')
212
203
        b = wt.branch
213
204
 
214
 
        self.build_tree(['directory/','directory/hello.c',
215
 
                         'bye.c','test.c','dir2/',
216
 
                         'missing.c'])
 
205
        self.build_tree(['directory/','directory/hello.c', 'bye.c','test.c','dir2/'])
217
206
        wt.add('directory')
218
207
        wt.add('test.c')
219
208
        wt.commit('testing')
220
 
        wt.add('missing.c')
221
 
        unlink('missing.c')
222
209
 
223
210
        self.assertStatus([
224
 
                'missing:\n',
225
 
                '  missing.c\n',
226
211
                'unknown:\n',
227
212
                '  bye.c\n',
228
213
                '  dir2/\n',
233
218
        self.assertStatus([
234
219
                '?   bye.c\n',
235
220
                '?   dir2/\n',
236
 
                '+!  missing.c\n',
237
221
                '?   directory/hello.c\n'
238
222
                ],
239
223
                wt, short=True)
276
260
        tof.seek(0)
277
261
        self.assertEquals(tof.readlines(), ['+N  test.c\n'])
278
262
 
279
 
        tof = StringIO()
280
 
        show_tree_status(wt, specific_files=['missing.c'], to_file=tof)
281
 
        tof.seek(0)
282
 
        self.assertEquals(tof.readlines(),
283
 
                          ['missing:\n',
284
 
                           '  missing.c\n'])
285
 
 
286
 
        tof = StringIO()
287
 
        show_tree_status(wt, specific_files=['missing.c'], to_file=tof,
288
 
                         short=True)
289
 
        tof.seek(0)
290
 
        self.assertEquals(tof.readlines(),
291
 
                          ['+!  missing.c\n'])
292
 
 
293
263
    def test_specific_files_conflicts(self):
294
264
        tree = self.make_branch_and_tree('.')
295
265
        self.build_tree(['dir2/'])
324
294
        wt.add('FILE_D')
325
295
        wt.add('FILE_E')
326
296
        wt.commit('Create five empty files.')
327
 
        with open('FILE_B', 'w') as f: f.write('Modification to file FILE_B.')
328
 
        with open('FILE_C', 'w') as f: f.write('Modification to file FILE_C.')
 
297
        open('FILE_B', 'w').write('Modification to file FILE_B.')
 
298
        open('FILE_C', 'w').write('Modification to file FILE_C.')
329
299
        unlink('FILE_E')  # FILE_E will be versioned but missing
330
 
        with open('FILE_Q', 'w') as f: f.write('FILE_Q is added but not committed.')
 
300
        open('FILE_Q', 'w').write('FILE_Q is added but not committed.')
331
301
        wt.add('FILE_Q')  # FILE_Q will be added but not committed
332
302
        open('UNVERSIONED_BUT_EXISTING', 'w')
333
303
        return wt
477
447
          ' M  FILE_B\n',
478
448
          'X   NONEXISTENT\n',
479
449
          ]
480
 
        expected.sort()
481
450
        out, err = self.run_bzr('status --short NONEXISTENT '
482
451
                                'FILE_A FILE_B UNVERSIONED_BUT_EXISTING '
483
452
                                'FILE_C FILE_D FILE_E FILE_Q', retcode=3)
484
 
        actual = out.splitlines(True)
485
 
        actual.sort()
486
 
        self.assertEqual(expected, actual)
 
453
        self.assertEqual(expected, out.splitlines(True))
487
454
        self.assertContainsRe(err,
488
455
                              r'.*ERROR: Path\(s\) do not exist: '
489
456
                              'NONEXISTENT.*')
553
520
        out, err = self.run_bzr('status branch1 -rbranch:branch2')
554
521
        self.assertEqual('', out)
555
522
 
556
 
    def test_status_with_shelves(self):
557
 
        """Ensure that _show_shelve_summary handler works.
558
 
        """
559
 
        wt = self.make_branch_and_tree('.')
560
 
        self.build_tree(['hello.c'])
561
 
        wt.add('hello.c')
562
 
        self.run_bzr(['shelve', '--all', '-m', 'foo'])
563
 
        self.build_tree(['bye.c'])
564
 
        wt.add('bye.c')
565
 
        self.assertStatus([
566
 
                'added:\n',
567
 
                '  bye.c\n',
568
 
                '1 shelf exists. See "bzr shelve --list" for details.\n',
569
 
            ],
570
 
            wt)
571
 
        self.run_bzr(['shelve', '--all', '-m', 'bar'])
572
 
        self.build_tree(['spam.c'])
573
 
        wt.add('spam.c')
574
 
        self.assertStatus([
575
 
                'added:\n',
576
 
                '  spam.c\n',
577
 
                '2 shelves exist. See "bzr shelve --list" for details.\n',
578
 
            ],
579
 
            wt)
580
 
 
581
523
 
582
524
class CheckoutStatus(BranchStatus):
583
525
 
637
579
        self.assertContainsRe(result, "[+]N  hello.txt\n")
638
580
 
639
581
        self.build_tree(['world.txt'])
640
 
        result = self.run_bzr("status -S -r 0")[0]
 
582
        result = self.run_bzr("status --short -r 0")[0]
641
583
        self.assertContainsRe(result, "[+]N  hello.txt\n" \
642
584
                                      "[?]   world.txt\n")
643
 
        result2 = self.run_bzr("status -S -r 0..")[0]
 
585
        result2 = self.run_bzr("status --short -r 0..")[0]
644
586
        self.assertEquals(result2, result)
645
587
 
646
588
    def test_status_versioned(self):