~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/status.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-12-07 21:39:19 UTC
  • mfrom: (2168.1.3 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20061207213919-1cc5d101c30fda65
(Keir Mierle) Add support for 'bzr status --short'

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
                     show_ids=False,
77
77
                     to_file=None,
78
78
                     show_pending=True,
79
 
                     revision=None):
 
79
                     revision=None,
 
80
                     short=False):
80
81
    """Display summary of changes.
81
82
 
82
83
    By default this compares the working tree to a previous revision. 
101
102
        If not None it must be a RevisionSpec list.
102
103
        If one revision show compared it with working tree.
103
104
        If two revisions show status between first and second.
 
105
    :param short: If True, gives short SVN-style status lines
104
106
    """
105
107
    if show_unchanged is not None:
106
108
        warn("show_status_trees with show_unchanged has been deprecated "
137
139
                              specific_files=specific_files)
138
140
        delta.show(to_file,
139
141
                   show_ids=show_ids,
140
 
                   show_unchanged=show_unchanged)
141
 
 
142
 
        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)
143
149
        conflict_title = False
144
150
        # show the new conflicts only for now. XXX: get them from the delta.
145
151
        for conflict in new.conflicts():
146
 
            if conflict_title is False:
 
152
            if not short and conflict_title is False:
147
153
                print >> to_file, "conflicts:"
148
154
                conflict_title = True
149
 
            print >> to_file, "  %s" % conflict
 
155
            if short:
 
156
                prefix = 'C '
 
157
            else:
 
158
                prefix = ' '
 
159
            print >> to_file, "%s %s" % (prefix, conflict)
150
160
        if new_is_working_tree and show_pending:
151
 
            show_pending_merges(new, to_file)
 
161
            show_pending_merges(new, to_file, short)
152
162
    finally:
153
163
        wt.unlock()
154
164
 
155
 
def show_pending_merges(new, to_file):
 
165
def show_pending_merges(new, to_file, short=False):
156
166
    """Write out a display of pending merges in a working tree."""
157
167
    parents = new.get_parent_ids()
158
168
    if len(parents) < 2:
160
170
    pending = parents[1:]
161
171
    branch = new.branch
162
172
    last_revision = parents[0]
163
 
    print >>to_file, 'pending merges:'
 
173
    if not short:
 
174
        print >>to_file, 'pending merges:'
164
175
    if last_revision is not None:
165
176
        try:
166
177
            ignore = set(branch.repository.get_ancestry(last_revision))
178
189
            from bzrlib.osutils import terminal_width
179
190
            width = terminal_width()
180
191
            m_revision = branch.repository.get_revision(merge)
181
 
            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)
182
197
            inner_merges = branch.repository.get_ancestry(merge)
183
198
            assert inner_merges[0] is None
184
199
            inner_merges.pop(0)
187
202
                if mmerge in ignore:
188
203
                    continue
189
204
                mm_revision = branch.repository.get_revision(mmerge)
190
 
                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)
191
210
                ignore.add(mmerge)
192
211
        except errors.NoSuchRevision:
193
 
            print >> to_file, ' ', merge
 
212
            if short:
 
213
                prefix = 'P '
 
214
            else:
 
215
                prefix = ' '
 
216
            print >> to_file, prefix, merge
194
217
        
195
 
def list_paths(header, paths, specific_files, to_file):
 
218
def list_paths(header, paths, specific_files, to_file, short_status_letter=''):
196
219
    done_header = False
197
220
    for path in paths:
198
221
        if specific_files and not is_inside_any(specific_files, path):
199
222
            continue
200
 
        if not done_header:
 
223
        if not short_status_letter and not done_header:
201
224
            print >>to_file, '%s:' % header
202
225
            done_header = True
203
 
        print >>to_file, ' ', path
 
226
        print >>to_file, '%s  %s' % (short_status_letter, path)