/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

  • Committer: Aaron Bentley
  • Date: 2007-03-03 17:17:53 UTC
  • mfrom: (2309 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2316.
  • Revision ID: aaron.bentley@utoronto.ca-20070303171753-o0s1yrxx5sn12p2k
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
import sys
18
18
 
 
19
from bzrlib import (
 
20
    delta as _mod_delta,
 
21
    tree,
 
22
    )
19
23
from bzrlib.diff import _raise_if_nonexistent
20
24
import bzrlib.errors as errors
21
25
from bzrlib.log import line_log
76
80
                     show_ids=False,
77
81
                     to_file=None,
78
82
                     show_pending=True,
79
 
                     revision=None):
 
83
                     revision=None,
 
84
                     short=False):
80
85
    """Display summary of changes.
81
86
 
82
87
    By default this compares the working tree to a previous revision. 
101
106
        If not None it must be a RevisionSpec list.
102
107
        If one revision show compared it with working tree.
103
108
        If two revisions show status between first and second.
 
109
    :param short: If True, gives short SVN-style status lines
104
110
    """
105
111
    if show_unchanged is not None:
106
112
        warn("show_status_trees with show_unchanged has been deprecated "
133
139
            else:
134
140
                new = wt
135
141
        _raise_if_nonexistent(specific_files, old, new)
136
 
        delta = new.changes_from(old, want_unchanged=show_unchanged,
137
 
                              specific_files=specific_files)
138
 
        delta.show(to_file,
139
 
                   show_ids=show_ids,
140
 
                   show_unchanged=show_unchanged)
141
 
 
142
 
        list_paths('unknown', new.unknowns(), specific_files, to_file)
 
142
        if short:
 
143
            specific_file_ids = tree.find_ids_across_trees(specific_files,
 
144
                (old, new), require_versioned=False)
 
145
            changes = new._iter_changes(old, show_unchanged,
 
146
                                        specific_file_ids)
 
147
            reporter = _mod_delta.ChangeReporter(old.inventory,
 
148
                output_file=to_file)
 
149
            _mod_delta.report_changes(changes, reporter)
 
150
        else:
 
151
            delta = new.changes_from(old, want_unchanged=show_unchanged,
 
152
                                  specific_files=specific_files)
 
153
            delta.show(to_file,
 
154
                       show_ids=show_ids,
 
155
                       show_unchanged=show_unchanged,
 
156
                       short_status=short)
 
157
        short_status_letter = '? '
 
158
        if not short:
 
159
            short_status_letter = ''
 
160
        list_paths('unknown', new.unknowns(), specific_files, to_file,
 
161
                   short_status_letter)
143
162
        conflict_title = False
144
163
        # show the new conflicts only for now. XXX: get them from the delta.
145
164
        for conflict in new.conflicts():
146
 
            if conflict_title is False:
 
165
            if not short and conflict_title is False:
147
166
                print >> to_file, "conflicts:"
148
167
                conflict_title = True
149
 
            print >> to_file, "  %s" % conflict
 
168
            if short:
 
169
                prefix = 'C  '
 
170
            else:
 
171
                prefix = ' '
 
172
            print >> to_file, "%s %s" % (prefix, conflict)
150
173
        if new_is_working_tree and show_pending:
151
 
            show_pending_merges(new, to_file)
 
174
            show_pending_merges(new, to_file, short)
152
175
    finally:
153
176
        wt.unlock()
154
177
 
155
 
def show_pending_merges(new, to_file):
 
178
def show_pending_merges(new, to_file, short=False):
156
179
    """Write out a display of pending merges in a working tree."""
157
180
    parents = new.get_parent_ids()
158
181
    if len(parents) < 2:
160
183
    pending = parents[1:]
161
184
    branch = new.branch
162
185
    last_revision = parents[0]
163
 
    print >>to_file, 'pending merges:'
 
186
    if not short:
 
187
        print >>to_file, 'pending merges:'
164
188
    if last_revision is not None:
165
189
        try:
166
190
            ignore = set(branch.repository.get_ancestry(last_revision))
178
202
            from bzrlib.osutils import terminal_width
179
203
            width = terminal_width()
180
204
            m_revision = branch.repository.get_revision(merge)
181
 
            print >> to_file, ' ', line_log(m_revision, width - 3)
 
205
            if short:
 
206
                prefix = 'P  '
 
207
            else:
 
208
                prefix = ' '
 
209
            print >> to_file, prefix, line_log(m_revision, width - 4)
182
210
            inner_merges = branch.repository.get_ancestry(merge)
183
211
            assert inner_merges[0] is None
184
212
            inner_merges.pop(0)
187
215
                if mmerge in ignore:
188
216
                    continue
189
217
                mm_revision = branch.repository.get_revision(mmerge)
190
 
                print >> to_file, '   ', line_log(mm_revision, width - 5)
 
218
                if short:
 
219
                    prefix = 'P.  '
 
220
                else:
 
221
                    prefix = '   '
 
222
                print >> to_file, prefix, line_log(mm_revision, width - 5)
191
223
                ignore.add(mmerge)
192
224
        except errors.NoSuchRevision:
193
 
            print >> to_file, ' ', merge
 
225
            if short:
 
226
                prefix = 'P  '
 
227
            else:
 
228
                prefix = ' '
 
229
            print >> to_file, prefix, merge
194
230
        
195
 
def list_paths(header, paths, specific_files, to_file):
 
231
def list_paths(header, paths, specific_files, to_file, short_status_letter=''):
196
232
    done_header = False
197
233
    for path in paths:
198
234
        if specific_files and not is_inside_any(specific_files, path):
199
235
            continue
200
 
        if not done_header:
 
236
        if not short_status_letter and not done_header:
201
237
            print >>to_file, '%s:' % header
202
238
            done_header = True
203
 
        print >>to_file, ' ', path
 
239
        print >>to_file, '%s  %s' % (short_status_letter, path)