87
94
If showing the status of a working tree, extra information is included
88
95
about unknown files, conflicts, and pending merges.
91
If set, includes unchanged files.
94
If set, a list of filenames whose status should be shown.
95
It is an error to give a filename that is not in the working
97
:param show_unchanged: Deprecated parameter. If set, includes unchanged
99
:param specific_files: If set, a list of filenames whose status should be
100
shown. It is an error to give a filename that is not in the working
96
101
tree, or in the working inventory or in the basis inventory.
99
If set, includes each file's id.
102
If set, write to this file (default stdout.)
105
If set, write pending merges.
108
If None the compare latest revision with working tree
102
:param show_ids: If set, includes each file's id.
103
:param to_file: If set, write to this file (default stdout.)
104
:param show_pending: If set, write pending merges.
105
:param revision: If None the compare latest revision with working tree
106
If not None it must be a RevisionSpec list.
109
107
If one revision show compared it with working tree.
110
108
If two revisions show status between first and second.
109
:param short: If True, gives short SVN-style status lines
111
if show_unchanged is not None:
112
warn("show_status_trees with show_unchanged has been deprecated "
113
"since bzrlib 0.9", DeprecationWarning, stacklevel=2)
113
116
to_file = sys.stdout
117
120
new_is_working_tree = True
118
121
if revision is None:
122
if wt.last_revision() != wt.branch.last_revision():
123
warning("working tree is out of date, run 'bzr update'")
120
125
old = new.basis_tree()
121
126
elif len(revision) > 0:
123
128
rev_id = revision[0].in_history(wt.branch).rev_id
124
129
old = wt.branch.repository.revision_tree(rev_id)
125
except NoSuchRevision, e:
126
raise BzrCommandError(str(e))
130
except errors.NoSuchRevision, e:
131
raise errors.BzrCommandError(str(e))
127
132
if (len(revision) > 1) and (revision[1].spec is not None):
129
134
rev_id = revision[1].in_history(wt.branch).rev_id
130
135
new = wt.branch.repository.revision_tree(rev_id)
131
136
new_is_working_tree = False
132
except NoSuchRevision, e:
133
raise BzrCommandError(str(e))
137
except errors.NoSuchRevision, e:
138
raise errors.BzrCommandError(str(e))
136
_raise_if_nonexistent(specific_files, old, new)
137
delta = compare_trees(old, new, want_unchanged=show_unchanged,
138
specific_files=specific_files)
141
show_unchanged=show_unchanged)
143
if new_is_working_tree:
144
list_paths('unknown', new.unknowns(), specific_files, to_file)
144
_raise_if_nonexistent(specific_files, old, new)
146
changes = new._iter_changes(old, show_unchanged, specific_files,
147
require_versioned=False, want_unversioned=True)
148
reporter = _mod_delta.ChangeReporter(output_file=to_file,
149
unversioned_filter=new.is_ignored)
150
_mod_delta.report_changes(changes, reporter)
152
delta = new.changes_from(old, want_unchanged=show_unchanged,
153
specific_files=specific_files,
154
want_unversioned=True)
155
# filter out unknown files. We may want a tree method for
157
delta.unversioned = [unversioned for unversioned in
158
delta.unversioned if not new.is_ignored(unversioned[0])]
161
show_unchanged=show_unchanged,
145
163
conflict_title = False
146
for conflict in wt.conflicts():
147
if conflict_title is False:
164
# show the new conflicts only for now. XXX: get them from the delta.
165
for conflict in new.conflicts():
166
if not short and conflict_title is False:
148
167
print >> to_file, "conflicts:"
149
168
conflict_title = True
150
print >> to_file, " %s" % conflict
151
if new_is_working_tree and show_pending:
152
show_pending_merges(new, to_file)
173
print >> to_file, "%s %s" % (prefix, conflict)
174
if new_is_working_tree and show_pending:
175
show_pending_merges(new, to_file, short)
156
def show_pending_merges(new, to_file):
182
def show_pending_merges(new, to_file, short=False):
157
183
"""Write out a display of pending merges in a working tree."""
158
pending = new.pending_merges()
184
parents = new.get_parent_ids()
187
pending = parents[1:]
159
188
branch = new.branch
160
if len(pending) == 0:
162
print >>to_file, 'pending merges:'
163
last_revision = branch.last_revision()
189
last_revision = parents[0]
191
print >>to_file, 'pending merges:'
164
192
if last_revision is not None:
165
ignore = set(branch.repository.get_ancestry(last_revision))
194
ignore = set(branch.repository.get_ancestry(last_revision))
195
except errors.NoSuchRevision:
196
# the last revision is a ghost : assume everything is new
198
ignore = set([None, last_revision])
167
200
ignore = set([None])
168
for merge in new.pending_merges():
201
# TODO: this could be improved using merge_sorted - we'd get the same
202
# output rather than one level of indent.
203
for merge in pending:
169
204
ignore.add(merge)
206
from bzrlib.osutils import terminal_width
207
width = terminal_width()
171
208
m_revision = branch.repository.get_revision(merge)
172
print >> to_file, ' ', line_log(m_revision, 77)
213
print >> to_file, prefix, line_log(m_revision, width - 4)
173
214
inner_merges = branch.repository.get_ancestry(merge)
174
assert inner_merges[0] == None
215
assert inner_merges[0] is None
175
216
inner_merges.pop(0)
176
217
inner_merges.reverse()
177
218
for mmerge in inner_merges:
178
219
if mmerge in ignore:
180
221
mm_revision = branch.repository.get_revision(mmerge)
181
print >> to_file, ' ', line_log(mm_revision, 75)
226
print >> to_file, prefix, line_log(mm_revision, width - 5)
182
227
ignore.add(mmerge)
183
except NoSuchRevision:
184
print >> to_file, ' ', merge
186
def list_paths(header, paths, specific_files, to_file):
189
if specific_files and not is_inside_any(specific_files, path):
192
print >>to_file, '%s:' % header
194
print >>to_file, ' ', path
228
except errors.NoSuchRevision:
233
print >> to_file, prefix, merge