~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/status.py

  • Committer: Alexander Belchenko
  • Date: 2007-01-04 23:36:44 UTC
  • mfrom: (2224 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2225.
  • Revision ID: bialix@ukr.net-20070104233644-7znkxoj9b0y7ev28
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2005, 2006 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
16
16
 
17
17
import sys
18
18
 
19
 
from bzrlib import (
20
 
    delta as _mod_delta,
21
 
    tree,
22
 
    )
23
19
from bzrlib.diff import _raise_if_nonexistent
24
20
import bzrlib.errors as errors
25
21
from bzrlib.log import line_log
81
77
                     to_file=None,
82
78
                     show_pending=True,
83
79
                     revision=None,
84
 
                     short=False,
85
 
                     versioned=False):
 
80
                     short=False):
86
81
    """Display summary of changes.
87
82
 
88
83
    By default this compares the working tree to a previous revision. 
107
102
        If not None it must be a RevisionSpec list.
108
103
        If one revision show compared it with working tree.
109
104
        If two revisions show status between first and second.
110
 
    :param short: If True, gives short SVN-style status lines.
111
 
    :param versioned: If True, only shows versioned files.
 
105
    :param short: If True, gives short SVN-style status lines
112
106
    """
113
107
    if show_unchanged is not None:
114
108
        warn("show_status_trees with show_unchanged has been deprecated "
140
134
                    raise errors.BzrCommandError(str(e))
141
135
            else:
142
136
                new = wt
143
 
        old.lock_read()
144
 
        new.lock_read()
145
 
        try:
146
 
            _raise_if_nonexistent(specific_files, old, new)
147
 
            want_unversioned = not versioned
148
 
            if short:
149
 
                changes = new._iter_changes(old, show_unchanged, specific_files,
150
 
                    require_versioned=False, want_unversioned=want_unversioned)
151
 
                reporter = _mod_delta._ChangeReporter(output_file=to_file,
152
 
                    unversioned_filter=new.is_ignored)
153
 
                _mod_delta.report_changes(changes, reporter)
154
 
            else:
155
 
                delta = new.changes_from(old, want_unchanged=show_unchanged,
156
 
                                      specific_files=specific_files,
157
 
                                      want_unversioned=want_unversioned)
158
 
                # filter out unknown files. We may want a tree method for
159
 
                # this
160
 
                delta.unversioned = [unversioned for unversioned in
161
 
                    delta.unversioned if not new.is_ignored(unversioned[0])]
162
 
                delta.show(to_file,
163
 
                           show_ids=show_ids,
164
 
                           show_unchanged=show_unchanged,
165
 
                           short_status=False)
166
 
            # show the new conflicts only for now. XXX: get them from the
167
 
            # delta.
168
 
            conflicts = new.conflicts()
169
 
            if specific_files is not None:
170
 
                conflicts = conflicts.select_conflicts(new, specific_files,
171
 
                    ignore_misses=True, recurse=True)[1]
172
 
            if len(conflicts) > 0 and not short:
 
137
        _raise_if_nonexistent(specific_files, old, new)
 
138
        delta = new.changes_from(old, want_unchanged=show_unchanged,
 
139
                              specific_files=specific_files)
 
140
        delta.show(to_file,
 
141
                   show_ids=show_ids,
 
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)
 
149
        conflict_title = False
 
150
        # show the new conflicts only for now. XXX: get them from the delta.
 
151
        for conflict in new.conflicts():
 
152
            if not short and conflict_title is False:
173
153
                print >> to_file, "conflicts:"
174
 
            for conflict in conflicts:
175
 
                if short:
176
 
                    prefix = 'C  '
177
 
                else:
178
 
                    prefix = ' '
179
 
                print >> to_file, "%s %s" % (prefix, conflict)
180
 
            if new_is_working_tree and show_pending:
181
 
                show_pending_merges(new, to_file, short)
182
 
        finally:
183
 
            old.unlock()
184
 
            new.unlock()
 
154
                conflict_title = True
 
155
            if short:
 
156
                prefix = 'C '
 
157
            else:
 
158
                prefix = ' '
 
159
            print >> to_file, "%s %s" % (prefix, conflict)
 
160
        if new_is_working_tree and show_pending:
 
161
            show_pending_merges(new, to_file, short)
185
162
    finally:
186
163
        wt.unlock()
187
164
 
197
174
        print >>to_file, 'pending merges:'
198
175
    if last_revision is not None:
199
176
        try:
200
 
            ignore = set(branch.repository.get_ancestry(last_revision,
201
 
                                                        topo_sorted=False))
 
177
            ignore = set(branch.repository.get_ancestry(last_revision))
202
178
        except errors.NoSuchRevision:
203
179
            # the last revision is a ghost : assume everything is new 
204
180
            # except for it
214
190
            width = terminal_width()
215
191
            m_revision = branch.repository.get_revision(merge)
216
192
            if short:
217
 
                prefix = 'P  '
 
193
                prefix = 'P '
218
194
            else:
219
195
                prefix = ' '
220
196
            print >> to_file, prefix, line_log(m_revision, width - 4)
227
203
                    continue
228
204
                mm_revision = branch.repository.get_revision(mmerge)
229
205
                if short:
230
 
                    prefix = 'P.  '
 
206
                    prefix = 'P. '
231
207
                else:
232
208
                    prefix = '   '
233
209
                print >> to_file, prefix, line_log(mm_revision, width - 5)
234
210
                ignore.add(mmerge)
235
211
        except errors.NoSuchRevision:
236
212
            if short:
237
 
                prefix = 'P  '
 
213
                prefix = 'P '
238
214
            else:
239
215
                prefix = ' '
240
216
            print >> to_file, prefix, merge
 
217
        
 
218
def list_paths(header, paths, specific_files, to_file, short_status_letter=''):
 
219
    done_header = False
 
220
    for path in paths:
 
221
        if specific_files and not is_inside_any(specific_files, path):
 
222
            continue
 
223
        if not short_status_letter and not done_header:
 
224
            print >>to_file, '%s:' % header
 
225
            done_header = True
 
226
        print >>to_file, '%s  %s' % (short_status_letter, path)