~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/status.py

Merge in format-5 work - release bzr 0.1rc1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
                specific_files=None,
21
21
                show_ids=False,
22
22
                to_file=None,
23
 
                show_pending=True):
24
 
    """Display single-line status for non-ignored working files.
 
23
                show_pending=True,
 
24
                revision=None):
 
25
    """Display status for non-ignored working files.
25
26
 
26
 
    show_all
27
 
        If true, show unmodified files too.
 
27
    show_unchanged
 
28
        If set, includes unchanged files.
28
29
 
29
30
    specific_files
30
31
        If set, only show the status of files in this list.
31
32
 
 
33
    show_ids
 
34
        If set, includes each file's id.
 
35
 
32
36
    to_file
33
37
        If set, write to this file (default stdout.)
 
38
 
 
39
    show_pending
 
40
        If set, write pending merges.
 
41
 
 
42
    revision
 
43
        If None the compare latest revision with working tree
 
44
        If one revision show compared it with working tree.
 
45
        If two revisions show status between first and second.
34
46
    """
35
47
    import sys
 
48
    from bzrlib.osutils import is_inside_any
36
49
    from bzrlib.delta import compare_trees
37
50
 
38
51
    if to_file == None:
40
53
    
41
54
    branch.lock_read()
42
55
    try:
43
 
 
44
 
        old = branch.basis_tree()
45
 
        new = branch.working_tree()
 
56
        new_is_working_tree = True
 
57
        if revision is None:
 
58
            old = branch.basis_tree()
 
59
            new = branch.working_tree()
 
60
        elif len(revision) > 0:
 
61
            try:
 
62
                rev_id = revision[0].in_history(branch).rev_id
 
63
                old = branch.revision_tree(rev_id)
 
64
            except NoSuchRevision, e:
 
65
                raise BzrCommandError(str(e))
 
66
            if len(revision) > 1:
 
67
                try:
 
68
                    rev_id = revision[1].in_history(branch).rev_id
 
69
                    new = branch.revision_tree(rev_id)
 
70
                    new_is_working_tree = False
 
71
                except NoSuchRevision, e:
 
72
                    raise BzrCommandError(str(e))
 
73
            else:
 
74
                new = branch.working_tree()
 
75
                
46
76
 
47
77
        delta = compare_trees(old, new, want_unchanged=show_unchanged,
48
78
                              specific_files=specific_files)
51
81
                   show_ids=show_ids,
52
82
                   show_unchanged=show_unchanged)
53
83
 
54
 
        unknowns = new.unknowns()
55
 
        done_header = False
56
 
        for path in unknowns:
57
 
            # FIXME: Should also match if the unknown file is within a
58
 
            # specified directory.
59
 
            if specific_files:
60
 
                if path not in specific_files:
 
84
        if new_is_working_tree:
 
85
            unknowns = new.unknowns()
 
86
            done_header = False
 
87
            for path in unknowns:
 
88
                if specific_files and not is_inside_any(specific_files, path):
61
89
                    continue
62
 
            if not done_header:
63
 
                print >>to_file, 'unknown:'
64
 
                done_header = True
65
 
            print >>to_file, ' ', path
66
 
        if show_pending and len(branch.pending_merges()) > 0:
67
 
            print >>to_file, 'pending merges:'
68
 
            for merge in branch.pending_merges():
69
 
                print >> to_file, ' ', merge
 
90
                if not done_header:
 
91
                    print >>to_file, 'unknown:'
 
92
                    done_header = True
 
93
                print >>to_file, ' ', path
 
94
            if show_pending and len(branch.pending_merges()) > 0:
 
95
                print >>to_file, 'pending merges:'
 
96
                for merge in branch.pending_merges():
 
97
                    print >> to_file, ' ', merge
70
98
    finally:
71
99
        branch.unlock()
72
100