/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/status.py

[merge] bzr.dev 2255

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from bzrlib.symbol_versioning import (deprecated_function,
24
24
        zero_eight,
25
25
        )
 
26
from bzrlib.trace import warning
26
27
 
27
28
# TODO: when showing single-line logs, truncate to the width of the terminal
28
29
# if known, but only if really going to the terminal (not into a file)
75
76
                     show_ids=False,
76
77
                     to_file=None,
77
78
                     show_pending=True,
78
 
                     revision=None):
 
79
                     revision=None,
 
80
                     short=False):
79
81
    """Display summary of changes.
80
82
 
81
83
    By default this compares the working tree to a previous revision. 
100
102
        If not None it must be a RevisionSpec list.
101
103
        If one revision show compared it with working tree.
102
104
        If two revisions show status between first and second.
 
105
    :param short: If True, gives short SVN-style status lines
103
106
    """
104
107
    if show_unchanged is not None:
105
108
        warn("show_status_trees with show_unchanged has been deprecated "
112
115
    try:
113
116
        new_is_working_tree = True
114
117
        if revision is None:
 
118
            if wt.last_revision() != wt.branch.last_revision():
 
119
                warning("working tree is out of date, run 'bzr update'")
115
120
            new = wt
116
121
            old = new.basis_tree()
117
122
        elif len(revision) > 0:
134
139
                              specific_files=specific_files)
135
140
        delta.show(to_file,
136
141
                   show_ids=show_ids,
137
 
                   show_unchanged=show_unchanged)
138
 
 
139
 
        list_paths('unknown', new.unknowns(), specific_files, to_file)
 
142
                   show_unchanged=show_unchanged,
 
143
                   short_status=short)
 
144
        short_status_letter = '?'
 
145
        if not short:
 
146
            short_status_letter = ''
 
147
        list_paths('unknown', new.unknowns(), specific_files, to_file,
 
148
                   short_status_letter)
140
149
        conflict_title = False
141
150
        # show the new conflicts only for now. XXX: get them from the delta.
142
151
        for conflict in new.conflicts():
143
 
            if conflict_title is False:
 
152
            if not short and conflict_title is False:
144
153
                print >> to_file, "conflicts:"
145
154
                conflict_title = True
146
 
            print >> to_file, "  %s" % conflict
 
155
            if short:
 
156
                prefix = 'C '
 
157
            else:
 
158
                prefix = ' '
 
159
            print >> to_file, "%s %s" % (prefix, conflict)
147
160
        if new_is_working_tree and show_pending:
148
 
            show_pending_merges(new, to_file)
 
161
            show_pending_merges(new, to_file, short)
149
162
    finally:
150
163
        wt.unlock()
151
164
 
152
 
def show_pending_merges(new, to_file):
 
165
def show_pending_merges(new, to_file, short=False):
153
166
    """Write out a display of pending merges in a working tree."""
154
167
    parents = new.get_parent_ids()
155
168
    if len(parents) < 2:
157
170
    pending = parents[1:]
158
171
    branch = new.branch
159
172
    last_revision = parents[0]
160
 
    print >>to_file, 'pending merges:'
 
173
    if not short:
 
174
        print >>to_file, 'pending merges:'
161
175
    if last_revision is not None:
162
176
        try:
163
177
            ignore = set(branch.repository.get_ancestry(last_revision))
175
189
            from bzrlib.osutils import terminal_width
176
190
            width = terminal_width()
177
191
            m_revision = branch.repository.get_revision(merge)
178
 
            print >> to_file, ' ', line_log(m_revision, width - 3)
 
192
            if short:
 
193
                prefix = 'P '
 
194
            else:
 
195
                prefix = ' '
 
196
            print >> to_file, prefix, line_log(m_revision, width - 4)
179
197
            inner_merges = branch.repository.get_ancestry(merge)
180
198
            assert inner_merges[0] is None
181
199
            inner_merges.pop(0)
184
202
                if mmerge in ignore:
185
203
                    continue
186
204
                mm_revision = branch.repository.get_revision(mmerge)
187
 
                print >> to_file, '   ', line_log(mm_revision, width - 5)
 
205
                if short:
 
206
                    prefix = 'P. '
 
207
                else:
 
208
                    prefix = '   '
 
209
                print >> to_file, prefix, line_log(mm_revision, width - 5)
188
210
                ignore.add(mmerge)
189
211
        except errors.NoSuchRevision:
190
 
            print >> to_file, ' ', merge
 
212
            if short:
 
213
                prefix = 'P '
 
214
            else:
 
215
                prefix = ' '
 
216
            print >> to_file, prefix, merge
191
217
        
192
 
def list_paths(header, paths, specific_files, to_file):
 
218
def list_paths(header, paths, specific_files, to_file, short_status_letter=''):
193
219
    done_header = False
194
220
    for path in paths:
195
221
        if specific_files and not is_inside_any(specific_files, path):
196
222
            continue
197
 
        if not done_header:
 
223
        if not short_status_letter and not done_header:
198
224
            print >>to_file, '%s:' % header
199
225
            done_header = True
200
 
        print >>to_file, ' ', path
 
226
        print >>to_file, '%s  %s' % (short_status_letter, path)