53
53
status._show_shelve_summary,
56
def assertStatus(self, expected_lines, working_tree,
56
def assertStatus(self, expected_lines, working_tree, specific_files=None,
57
57
revision=None, short=False, pending=True, verbose=False):
58
58
"""Run status in working_tree and look for output.
60
60
:param expected_lines: The lines to look for.
61
61
:param working_tree: The tree to run status in.
63
output_string = self.status_string(working_tree, revision, short,
63
output_string = self.status_string(working_tree, specific_files, revision, short,
65
65
self.assertEqual(expected_lines, output_string.splitlines(True))
67
def status_string(self, wt, revision=None, short=False, pending=True,
67
def status_string(self, wt, specific_files=None, revision=None,
68
short=False, pending=True, verbose=False):
69
69
# use a real file rather than StringIO because it doesn't handle
70
70
# Unicode very well.
71
71
tof = codecs.getwriter('utf-8')(TemporaryFile())
72
show_tree_status(wt, to_file=tof, revision=revision, short=short,
73
show_pending=pending, verbose=verbose)
72
show_tree_status(wt, specific_files=specific_files, to_file=tof,
73
revision=revision, short=short, show_pending=pending,
75
76
return tof.read().decode('utf-8')
326
327
wt.commit('Create five empty files.')
327
open('FILE_B', 'w').write('Modification to file FILE_B.')
328
open('FILE_C', 'w').write('Modification to file FILE_C.')
328
with open('FILE_B', 'w') as f: f.write('Modification to file FILE_B.')
329
with open('FILE_C', 'w') as f: f.write('Modification to file FILE_C.')
329
330
unlink('FILE_E') # FILE_E will be versioned but missing
330
open('FILE_Q', 'w').write('FILE_Q is added but not committed.')
331
with open('FILE_Q', 'w') as f: f.write('FILE_Q is added but not committed.')
331
332
wt.add('FILE_Q') # FILE_Q will be added but not committed
332
333
open('UNVERSIONED_BUT_EXISTING', 'w')
478
479
'X NONEXISTENT\n',
480
482
out, err = self.run_bzr('status --short NONEXISTENT '
481
483
'FILE_A FILE_B UNVERSIONED_BUT_EXISTING '
482
484
'FILE_C FILE_D FILE_E FILE_Q', retcode=3)
483
self.assertEqual(expected, out.splitlines(True))
485
actual = out.splitlines(True)
487
self.assertEqual(expected, actual)
484
488
self.assertContainsRe(err,
485
489
r'.*ERROR: Path\(s\) do not exist: '
568
572
self.run_bzr(['shelve', '--all', '-m', 'bar'])
569
self.build_tree(['spam.c'])
573
self.build_tree(['eggs.c', 'spam.c'])
571
576
self.assertStatus([
574
580
'2 shelves exist. See "bzr shelve --list" for details.\n',
588
specific_files=['spam.c'])
579
591
class CheckoutStatus(BranchStatus):
586
598
def make_branch_and_tree(self, relpath):
587
599
source = self.make_branch(pathjoin('..', relpath))
588
600
checkout = bzrdir.BzrDirMetaFormat1().initialize(relpath)
589
bzrlib.branch.BranchReferenceFormat().initialize(checkout,
590
target_branch=source)
601
checkout.set_branch_reference(source)
591
602
return checkout.create_workingtree()
634
645
self.assertContainsRe(result, "[+]N hello.txt\n")
636
647
self.build_tree(['world.txt'])
637
result = self.run_bzr("status --short -r 0")[0]
648
result = self.run_bzr("status -S -r 0")[0]
638
649
self.assertContainsRe(result, "[+]N hello.txt\n" \
639
650
"[?] world.txt\n")
640
result2 = self.run_bzr("status --short -r 0..")[0]
651
result2 = self.run_bzr("status -S -r 0..")[0]
641
652
self.assertEquals(result2, result)
643
654
def test_status_versioned(self):