~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/status.py

  • Committer: Martin Pool
  • Date: 2005-07-12 01:44:23 UTC
  • Revision ID: mbp@sourcefrog.net-20050712014423-1d95eb47ce7ab510
- add simple test case for bzr status

- show_status takes to_file argument

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
def show_status(branch, show_unchanged=False,
20
20
                specific_files=None,
21
 
                show_ids=False):
 
21
                show_ids=False,
 
22
                to_file=None):
22
23
    """Display single-line status for non-ignored working files.
23
24
 
24
25
    show_all
26
27
 
27
28
    specific_files
28
29
        If set, only show the status of files in this list.
 
30
 
 
31
    to_file
 
32
        If set, write to this file (default stdout.)
29
33
    """
30
34
    import sys
31
35
    from bzrlib.diff import compare_trees
 
36
 
 
37
    if to_file == None:
 
38
        to_file = sys.stdout
32
39
    
33
40
    branch.lock_read()
34
41
    try:
39
46
        delta = compare_trees(old, new, want_unchanged=show_unchanged,
40
47
                              specific_files=specific_files)
41
48
 
42
 
        delta.show(sys.stdout, show_ids=show_ids,
 
49
        delta.show(to_file,
 
50
                   show_ids=show_ids,
43
51
                   show_unchanged=show_unchanged)
44
52
 
45
53
        unknowns = new.unknowns()
51
59
                if path not in specific_files:
52
60
                    continue
53
61
            if not done_header:
54
 
                print 'unknown:'
 
62
                print >>to_file, 'unknown:'
55
63
                done_header = True
56
 
            print ' ', path
 
64
            print >>to_file, ' ', path
57
65
    finally:
58
66
        branch.unlock()
59
67