~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/status.py

  • Committer: Martin Pool
  • Date: 2005-09-12 09:50:44 UTC
  • Revision ID: mbp@sourcefrog.net-20050912095044-6acfdb5611729987
- no tests in bzrlib.fetch anymore

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
 
                revision=None):
25
 
    """Display status for non-ignored working files.
 
23
                show_pending=True):
 
24
    """Display single-line status for non-ignored working files.
26
25
 
27
 
    show_unchanged
28
 
        If set, includes unchanged files.
 
26
    show_all
 
27
        If true, show unmodified files too.
29
28
 
30
29
    specific_files
31
30
        If set, only show the status of files in this list.
32
31
 
33
 
    show_ids
34
 
        If set, includes each file's id.
35
 
 
36
32
    to_file
37
33
        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.
46
34
    """
47
35
    import sys
48
 
    from bzrlib.osutils import is_inside_any
49
36
    from bzrlib.delta import compare_trees
50
37
 
51
38
    if to_file == None:
53
40
    
54
41
    branch.lock_read()
55
42
    try:
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
 
                
 
43
 
 
44
        old = branch.basis_tree()
 
45
        new = branch.working_tree()
76
46
 
77
47
        delta = compare_trees(old, new, want_unchanged=show_unchanged,
78
48
                              specific_files=specific_files)
81
51
                   show_ids=show_ids,
82
52
                   show_unchanged=show_unchanged)
83
53
 
84
 
        if new_is_working_tree:
85
 
            conflicts = new.iter_conflicts()
86
 
            unknowns = new.unknowns()
87
 
            list_paths('unknown', unknowns, specific_files, to_file)
88
 
            list_paths('conflicts', conflicts, specific_files, to_file)
89
 
            if show_pending and len(branch.pending_merges()) > 0:
90
 
                print >>to_file, 'pending merges:'
91
 
                for merge in branch.pending_merges():
92
 
                    print >> to_file, ' ', merge
 
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:
 
61
                    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
93
70
    finally:
94
71
        branch.unlock()
95
72
        
96
 
def list_paths(header, paths, specific_files, to_file):
97
 
    done_header = False
98
 
    for path in paths:
99
 
        if specific_files and not is_inside_any(specific_files, path):
100
 
            continue
101
 
        if not done_header:
102
 
            print >>to_file, '%s:' % header
103
 
            done_header = True
104
 
        print >>to_file, ' ', path