23
19
from bzrlib.diff import _raise_if_nonexistent
24
20
import bzrlib.errors as errors
25
21
from bzrlib.log import line_log
26
22
from bzrlib.osutils import is_inside_any
27
23
from bzrlib.symbol_versioning import (deprecated_function,
29
from bzrlib.trace import warning
31
27
# TODO: when showing single-line logs, truncate to the width of the terminal
32
28
# if known, but only if really going to the terminal (not into a file)
31
@deprecated_function(zero_eight)
32
def show_status(branch, show_unchanged=None,
38
"""Display summary of changes.
40
Please use show_tree_status instead.
42
By default this compares the working tree to a previous revision.
43
If the revision argument is given, summarizes changes between the
44
working tree and another, or between two revisions.
46
The result is written out as Unicode and to_file should be able
50
If set, includes unchanged files.
53
If set, only show the status of files in this list.
56
If set, includes each file's id.
59
If set, write to this file (default stdout.)
62
If set, write pending merges.
65
If None the compare latest revision with working tree
66
If one revision show compared it with working tree.
67
If two revisions show status between first and second.
69
show_tree_status(branch.bzrdir.open_workingtree(), show_unchanged,
70
specific_files, show_ids, to_file, show_pending, revision)
35
73
def show_tree_status(wt, show_unchanged=None,
36
74
specific_files=None,
43
79
"""Display summary of changes.
45
81
By default this compares the working tree to a previous revision.
97
129
raise errors.BzrCommandError(str(e))
103
_raise_if_nonexistent(specific_files, old, new)
104
want_unversioned = not versioned
106
changes = new._iter_changes(old, show_unchanged, specific_files,
107
require_versioned=False, want_unversioned=want_unversioned)
108
reporter = _mod_delta._ChangeReporter(output_file=to_file,
109
unversioned_filter=new.is_ignored)
110
_mod_delta.report_changes(changes, reporter)
112
delta = new.changes_from(old, want_unchanged=show_unchanged,
113
specific_files=specific_files,
114
want_unversioned=want_unversioned)
115
# filter out unknown files. We may want a tree method for
117
delta.unversioned = [unversioned for unversioned in
118
delta.unversioned if not new.is_ignored(unversioned[0])]
121
show_unchanged=show_unchanged,
123
# show the new conflicts only for now. XXX: get them from the
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:
136
to_file.write("%s %s\n" % (prefix, conflict))
137
if new_is_working_tree and show_pending:
138
show_pending_merges(new, to_file, short)
132
_raise_if_nonexistent(specific_files, old, new)
133
delta = new.changes_from(old, want_unchanged=show_unchanged,
134
specific_files=specific_files)
137
show_unchanged=show_unchanged)
139
list_paths('unknown', new.unknowns(), specific_files, to_file)
140
conflict_title = False
141
# show the new conflicts only for now. XXX: get them from the delta.
142
for conflict in new.conflicts():
143
if conflict_title is False:
144
print >> to_file, "conflicts:"
145
conflict_title = True
146
print >> to_file, " %s" % conflict
147
if new_is_working_tree and show_pending:
148
show_pending_merges(new, to_file)
145
def show_pending_merges(new, to_file, short=False):
152
def show_pending_merges(new, to_file):
146
153
"""Write out a display of pending merges in a working tree."""
147
parents = new.get_parent_ids()
154
pending = new.pending_merges()
156
if len(pending) == 0:
150
pending = parents[1:]
152
last_revision = parents[0]
154
to_file.write('pending merges:\n')
158
print >>to_file, 'pending merges:'
159
last_revision = branch.last_revision()
155
160
if last_revision is not None:
157
ignore = set(branch.repository.get_ancestry(last_revision,
159
except errors.NoSuchRevision:
160
# the last revision is a ghost : assume everything is new
162
ignore = set([None, last_revision])
161
ignore = set(branch.repository.get_ancestry(last_revision))
164
163
ignore = set([None])
165
# TODO: this could be improved using merge_sorted - we'd get the same
166
# output rather than one level of indent.
167
for merge in pending:
164
for merge in new.pending_merges():
168
165
ignore.add(merge)
170
167
from bzrlib.osutils import terminal_width
171
168
width = terminal_width()
172
169
m_revision = branch.repository.get_revision(merge)
177
to_file.write(prefix + ' ' + line_log(m_revision, width - 4))
170
print >> to_file, ' ', line_log(m_revision, width - 3)
179
171
inner_merges = branch.repository.get_ancestry(merge)
180
assert inner_merges[0] is None
172
assert inner_merges[0] == None
181
173
inner_merges.pop(0)
182
174
inner_merges.reverse()
183
175
for mmerge in inner_merges:
184
176
if mmerge in ignore:
186
178
mm_revision = branch.repository.get_revision(mmerge)
191
to_file.write(prefix + ' ' + line_log(mm_revision, width - 5))
179
print >> to_file, ' ', line_log(mm_revision, width - 5)
193
180
ignore.add(mmerge)
194
181
except errors.NoSuchRevision:
199
to_file.write(prefix + ' ' + merge)
182
print >> to_file, ' ', merge
184
def list_paths(header, paths, specific_files, to_file):
187
if specific_files and not is_inside_any(specific_files, path):
190
print >>to_file, '%s:' % header
192
print >>to_file, ' ', path