~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/status.py

  • Committer: Robert Collins
  • Date: 2005-12-24 02:20:45 UTC
  • mto: (1185.50.57 bzr-jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1550.
  • Revision ID: robertc@robertcollins.net-20051224022045-14efc8dfa0e1a4e9
Start tests for api usage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
from bzrlib.log import line_log
21
21
from bzrlib.errors import NoSuchRevision
22
22
 
 
23
# TODO: when showing single-line logs, truncate to the width of the terminal
 
24
# if known, but only if really going to the terminal (not into a file)
 
25
 
23
26
 
24
27
def show_status(branch, show_unchanged=False,
25
28
                specific_files=None,
27
30
                to_file=None,
28
31
                show_pending=True,
29
32
                revision=None):
30
 
    """Display status for non-ignored working files.
 
33
    """Display summary of changes.
 
34
 
 
35
    By default this compares the working tree to a previous revision. 
 
36
    If the revision argument is given, summarizes changes between the 
 
37
    working tree and another, or between two revisions.
 
38
 
 
39
    The result is written out as Unicode and to_file should be able 
 
40
    to encode that.
31
41
 
32
42
    show_unchanged
33
43
        If set, includes unchanged files.
83
93
                   show_unchanged=show_unchanged)
84
94
 
85
95
        if new_is_working_tree:
86
 
            conflicts = new.iter_conflicts()
87
 
            unknowns = new.unknowns()
88
 
            list_paths('unknown', unknowns, specific_files, to_file)
89
 
            list_paths('conflicts', conflicts, specific_files, to_file)
90
 
            if show_pending and len(new.pending_merges()) > 0:
91
 
                print >>to_file, 'pending merges:'
92
 
                last_revision = branch.last_revision()
93
 
                if last_revision is not None:
94
 
                    ignore = set(branch.get_ancestry(last_revision))
95
 
                else:
96
 
                    ignore = set()
97
 
                for merge in new.pending_merges():
98
 
                    ignore.add(merge)
99
 
                    try:
100
 
                        m_revision = branch.get_revision(merge)
101
 
                        print >> to_file, ' ', line_log(m_revision, 77)
102
 
                        inner_merges = branch.get_ancestry(merge)
103
 
                        inner_merges.reverse()
104
 
                        for mmerge in inner_merges:
105
 
                            if mmerge in ignore:
106
 
                                continue
107
 
                            mm_revision = branch.get_revision(mmerge)
108
 
                            print >> to_file, '   ', line_log(mm_revision, 75)
109
 
                            ignore.add(mmerge)
110
 
                            
111
 
                    except NoSuchRevision:
112
 
                        print >> to_file, ' ', merge 
113
 
                        
 
96
            list_paths('unknown', new.unknowns(), specific_files, to_file)
 
97
            list_paths('conflicts', new.iter_conflicts(), specific_files, to_file)
 
98
        if new_is_working_tree and show_pending:
 
99
            show_pending_merges(new, to_file)
114
100
    finally:
115
101
        branch.unlock()
 
102
 
 
103
def show_pending_merges(new, to_file):
 
104
    """Write out a display of pending merges in a working tree."""
 
105
    pending = new.pending_merges()
 
106
    branch = new.branch
 
107
    if len(pending) == 0:
 
108
        return
 
109
    print >>to_file, 'pending merges:'
 
110
    last_revision = branch.last_revision()
 
111
    if last_revision is not None:
 
112
        ignore = set(branch.get_ancestry(last_revision))
 
113
    else:
 
114
        ignore = set()
 
115
    for merge in new.pending_merges():
 
116
        ignore.add(merge)
 
117
        try:
 
118
            m_revision = branch.get_revision(merge)
 
119
            print >> to_file, ' ', line_log(m_revision, 77)
 
120
            inner_merges = branch.get_ancestry(merge)
 
121
            inner_merges.reverse()
 
122
            for mmerge in inner_merges:
 
123
                if mmerge in ignore:
 
124
                    continue
 
125
                mm_revision = branch.get_revision(mmerge)
 
126
                print >> to_file, '   ', line_log(mm_revision, 75)
 
127
                ignore.add(mmerge)
 
128
        except NoSuchRevision:
 
129
            print >> to_file, ' ', merge 
116
130
        
117
131
def list_paths(header, paths, specific_files, to_file):
118
132
    done_header = False