~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/status.py

  • Committer: Andrew Bennetts
  • Date: 2007-03-28 07:08:42 UTC
  • mfrom: (2380 +trunk)
  • mto: (2018.5.146 hpss)
  • mto: This revision was merged to the branch mainline in revision 2414.
  • Revision ID: andrew.bennetts@canonical.com-20070328070842-r843houy668oxb9o
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007 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
81
81
                     to_file=None,
82
82
                     show_pending=True,
83
83
                     revision=None,
84
 
                     short=False):
 
84
                     short=False,
 
85
                     versioned=False):
85
86
    """Display summary of changes.
86
87
 
87
88
    By default this compares the working tree to a previous revision. 
106
107
        If not None it must be a RevisionSpec list.
107
108
        If one revision show compared it with working tree.
108
109
        If two revisions show status between first and second.
109
 
    :param short: If True, gives short SVN-style status lines
 
110
    :param short: If True, gives short SVN-style status lines.
 
111
    :param versioned: If True, only shows versioned files.
110
112
    """
111
113
    if show_unchanged is not None:
112
114
        warn("show_status_trees with show_unchanged has been deprecated "
138
140
                    raise errors.BzrCommandError(str(e))
139
141
            else:
140
142
                new = wt
141
 
        _raise_if_nonexistent(specific_files, old, new)
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)
162
 
        conflict_title = False
163
 
        # show the new conflicts only for now. XXX: get them from the delta.
164
 
        for conflict in new.conflicts():
165
 
            if not short and conflict_title is False:
166
 
                print >> to_file, "conflicts:"
167
 
                conflict_title = True
 
143
        old.lock_read()
 
144
        new.lock_read()
 
145
        try:
 
146
            _raise_if_nonexistent(specific_files, old, new)
 
147
            want_unversioned = not versioned
168
148
            if short:
169
 
                prefix = 'C  '
 
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)
170
154
            else:
171
 
                prefix = ' '
172
 
            print >> to_file, "%s %s" % (prefix, conflict)
173
 
        if new_is_working_tree and show_pending:
174
 
            show_pending_merges(new, to_file, short)
 
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
            conflict_title = False
 
167
            # show the new conflicts only for now. XXX: get them from the delta.
 
168
            for conflict in new.conflicts():
 
169
                if not short and conflict_title is False:
 
170
                    print >> to_file, "conflicts:"
 
171
                    conflict_title = True
 
172
                if short:
 
173
                    prefix = 'C  '
 
174
                else:
 
175
                    prefix = ' '
 
176
                print >> to_file, "%s %s" % (prefix, conflict)
 
177
            if new_is_working_tree and show_pending:
 
178
                show_pending_merges(new, to_file, short)
 
179
        finally:
 
180
            old.unlock()
 
181
            new.unlock()
175
182
    finally:
176
183
        wt.unlock()
177
184
 
227
234
            else:
228
235
                prefix = ' '
229
236
            print >> to_file, prefix, merge
230
 
        
231
 
def list_paths(header, paths, specific_files, to_file, short_status_letter=''):
232
 
    done_header = False
233
 
    for path in paths:
234
 
        if specific_files and not is_inside_any(specific_files, path):
235
 
            continue
236
 
        if not short_status_letter and not done_header:
237
 
            print >>to_file, '%s:' % header
238
 
            done_header = True
239
 
        print >>to_file, '%s  %s' % (short_status_letter, path)