~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/status.py

  • Committer: John Arbash Meinel
  • Date: 2007-05-04 18:59:36 UTC
  • mto: This revision was merged to the branch mainline in revision 2643.
  • Revision ID: john@arbash-meinel.com-20070504185936-1mjdoqmtz74xe5mg
A C implementation of _fields_to_entry_0_parents drops the time from 400ms to 330ms for a 21k-entry tree

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
from bzrlib.log import line_log
26
26
from bzrlib.osutils import is_inside_any
27
27
from bzrlib.symbol_versioning import (deprecated_function,
 
28
        zero_eight,
28
29
        )
29
30
from bzrlib.trace import warning
30
31
 
32
33
# if known, but only if really going to the terminal (not into a file)
33
34
 
34
35
 
 
36
@deprecated_function(zero_eight)
 
37
def show_status(branch, show_unchanged=None,
 
38
                specific_files=None,
 
39
                show_ids=False,
 
40
                to_file=None,
 
41
                show_pending=True,
 
42
                revision=None):
 
43
    """Display summary of changes.
 
44
 
 
45
    Please use show_tree_status instead.
 
46
 
 
47
    By default this compares the working tree to a previous revision. 
 
48
    If the revision argument is given, summarizes changes between the 
 
49
    working tree and another, or between two revisions.
 
50
 
 
51
    The result is written out as Unicode and to_file should be able 
 
52
    to encode that.
 
53
 
 
54
    show_unchanged
 
55
        If set, includes unchanged files.
 
56
 
 
57
    specific_files
 
58
        If set, only show the status of files in this list.
 
59
 
 
60
    show_ids
 
61
        If set, includes each file's id.
 
62
 
 
63
    to_file
 
64
        If set, write to this file (default stdout.)
 
65
 
 
66
    show_pending
 
67
        If set, write pending merges.
 
68
 
 
69
    revision
 
70
        If None the compare latest revision with working tree
 
71
        If one revision show compared it with working tree.
 
72
        If two revisions show status between first and second.
 
73
    """
 
74
    show_tree_status(branch.bzrdir.open_workingtree(), show_unchanged, 
 
75
                     specific_files, show_ids, to_file, show_pending, revision)
 
76
 
 
77
 
35
78
def show_tree_status(wt, show_unchanged=None,
36
79
                     specific_files=None,
37
80
                     show_ids=False,
84
127
            old = new.basis_tree()
85
128
        elif len(revision) > 0:
86
129
            try:
87
 
                rev_id = revision[0].as_revision_id(wt.branch)
 
130
                rev_id = revision[0].in_history(wt.branch).rev_id
88
131
                old = wt.branch.repository.revision_tree(rev_id)
89
132
            except errors.NoSuchRevision, e:
90
133
                raise errors.BzrCommandError(str(e))
91
134
            if (len(revision) > 1) and (revision[1].spec is not None):
92
135
                try:
93
 
                    rev_id = revision[1].as_revision_id(wt.branch)
 
136
                    rev_id = revision[1].in_history(wt.branch).rev_id
94
137
                    new = wt.branch.repository.revision_tree(rev_id)
95
138
                    new_is_working_tree = False
96
139
                except errors.NoSuchRevision, e:
103
146
            _raise_if_nonexistent(specific_files, old, new)
104
147
            want_unversioned = not versioned
105
148
            if short:
106
 
                changes = new.iter_changes(old, show_unchanged, specific_files,
 
149
                changes = new._iter_changes(old, show_unchanged, specific_files,
107
150
                    require_versioned=False, want_unversioned=want_unversioned)
108
151
                reporter = _mod_delta._ChangeReporter(output_file=to_file,
109
152
                    unversioned_filter=new.is_ignored)
120
163
                           show_ids=show_ids,
121
164
                           show_unchanged=show_unchanged,
122
165
                           short_status=False)
123
 
            # show the new conflicts only for now. XXX: get them from the
124
 
            # delta.
125
 
            conflicts = new.conflicts()
126
 
            if specific_files is not None:
127
 
                conflicts = conflicts.select_conflicts(new, specific_files,
128
 
                    ignore_misses=True, recurse=True)[1]
129
 
            if len(conflicts) > 0 and not short:
130
 
                to_file.write("conflicts:\n")
131
 
            for conflict in conflicts:
 
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
132
172
                if short:
133
173
                    prefix = 'C  '
134
174
                else:
135
175
                    prefix = ' '
136
 
                to_file.write("%s %s\n" % (prefix, conflict))
137
 
            if (new_is_working_tree and show_pending
138
 
                and specific_files is None):
 
176
                print >> to_file, "%s %s" % (prefix, conflict)
 
177
            if new_is_working_tree and show_pending:
139
178
                show_pending_merges(new, to_file, short)
140
179
        finally:
141
180
            old.unlock()
152
191
    branch = new.branch
153
192
    last_revision = parents[0]
154
193
    if not short:
155
 
        to_file.write('pending merges:\n')
 
194
        print >>to_file, 'pending merges:'
156
195
    if last_revision is not None:
157
196
        try:
158
 
            ignore = set(branch.repository.get_ancestry(last_revision,
159
 
                                                        topo_sorted=False))
 
197
            ignore = set(branch.repository.get_ancestry(last_revision))
160
198
        except errors.NoSuchRevision:
161
199
            # the last revision is a ghost : assume everything is new 
162
200
            # except for it
169
207
        ignore.add(merge)
170
208
        try:
171
209
            from bzrlib.osutils import terminal_width
172
 
            width = terminal_width() - 1    # we need one extra space to avoid
173
 
                                            # extra blank lines
 
210
            width = terminal_width()
174
211
            m_revision = branch.repository.get_revision(merge)
175
212
            if short:
176
 
                prefix = 'P   '
 
213
                prefix = 'P  '
177
214
            else:
178
 
                prefix = '  '
179
 
            to_file.write(prefix)
180
 
            to_file.write(line_log(m_revision, width - len(prefix)))
181
 
            to_file.write('\n')
 
215
                prefix = ' '
 
216
            print >> to_file, prefix, line_log(m_revision, width - 4)
182
217
            inner_merges = branch.repository.get_ancestry(merge)
183
218
            assert inner_merges[0] is None
184
219
            inner_merges.pop(0)
188
223
                    continue
189
224
                mm_revision = branch.repository.get_revision(mmerge)
190
225
                if short:
191
 
                    prefix = 'P.   '
 
226
                    prefix = 'P.  '
192
227
                else:
193
 
                    prefix = '    '
194
 
                to_file.write(prefix)
195
 
                to_file.write(line_log(mm_revision, width - len(prefix)))
196
 
                to_file.write('\n')
 
228
                    prefix = '   '
 
229
                print >> to_file, prefix, line_log(mm_revision, width - 5)
197
230
                ignore.add(mmerge)
198
231
        except errors.NoSuchRevision:
199
232
            if short:
200
233
                prefix = 'P  '
201
234
            else:
202
235
                prefix = ' '
203
 
            to_file.write(prefix + ' ' + merge)
204
 
            to_file.write('\n')
 
236
            print >> to_file, prefix, merge