15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
from bzrlib.osutils import is_inside_any
19
19
from bzrlib.delta import compare_trees
20
from bzrlib.log import line_log
20
21
from bzrlib.errors import NoSuchRevision
21
from bzrlib.log import line_log
22
from bzrlib.osutils import is_inside_any
23
from bzrlib.symbol_versioning import *
25
23
# TODO: when showing single-line logs, truncate to the width of the terminal
26
24
# if known, but only if really going to the terminal (not into a file)
29
@deprecated_function(zero_eight)
30
27
def show_status(branch, show_unchanged=False,
31
28
specific_files=None,
36
33
"""Display summary of changes.
38
Please use show_tree_status instead.
40
By default this compares the working tree to a previous revision.
41
If the revision argument is given, summarizes changes between the
42
working tree and another, or between two revisions.
44
The result is written out as Unicode and to_file should be able
48
If set, includes unchanged files.
51
If set, only show the status of files in this list.
54
If set, includes each file's id.
57
If set, write to this file (default stdout.)
60
If set, write pending merges.
63
If None the compare latest revision with working tree
64
If one revision show compared it with working tree.
65
If two revisions show status between first and second.
67
show_tree_status(branch.bzrdir.open_workingtree(), show_unchanged,
68
specific_files, show_ids, to_file, show_pending, revision)
71
def show_tree_status(wt, show_unchanged=False,
77
"""Display summary of changes.
79
35
By default this compares the working tree to a previous revision.
80
36
If the revision argument is given, summarizes changes between the
81
37
working tree and another, or between two revisions.
106
62
if to_file == None:
107
63
to_file = sys.stdout
111
67
new_is_working_tree = True
112
68
if revision is None:
114
old = new.basis_tree()
69
old = branch.basis_tree()
70
new = branch.working_tree()
115
71
elif len(revision) > 0:
117
rev_id = revision[0].in_history(wt.branch).rev_id
118
old = wt.branch.repository.revision_tree(rev_id)
73
rev_id = revision[0].in_history(branch).rev_id
74
old = branch.revision_tree(rev_id)
119
75
except NoSuchRevision, e:
120
76
raise BzrCommandError(str(e))
121
if (len(revision) > 1) and (revision[1].spec is not None):
123
rev_id = revision[1].in_history(wt.branch).rev_id
124
new = wt.branch.repository.revision_tree(rev_id)
79
rev_id = revision[1].in_history(branch).rev_id
80
new = branch.revision_tree(rev_id)
125
81
new_is_working_tree = False
126
82
except NoSuchRevision, e:
127
83
raise BzrCommandError(str(e))
85
new = branch.working_tree()
131
88
delta = compare_trees(old, new, want_unchanged=show_unchanged,
132
89
specific_files=specific_files)
133
91
delta.show(to_file,
134
92
show_ids=show_ids,
135
93
show_unchanged=show_unchanged)
140
98
if new_is_working_tree and show_pending:
141
99
show_pending_merges(new, to_file)
145
103
def show_pending_merges(new, to_file):
146
104
"""Write out a display of pending merges in a working tree."""
151
109
print >>to_file, 'pending merges:'
152
110
last_revision = branch.last_revision()
153
111
if last_revision is not None:
154
ignore = set(branch.repository.get_ancestry(last_revision))
112
ignore = set(branch.get_ancestry(last_revision))
157
115
for merge in new.pending_merges():
158
116
ignore.add(merge)
160
m_revision = branch.repository.get_revision(merge)
118
m_revision = branch.get_revision(merge)
161
119
print >> to_file, ' ', line_log(m_revision, 77)
162
inner_merges = branch.repository.get_ancestry(merge)
120
inner_merges = branch.get_ancestry(merge)
163
121
inner_merges.reverse()
164
122
for mmerge in inner_merges:
165
123
if mmerge in ignore:
167
mm_revision = branch.repository.get_revision(mmerge)
125
mm_revision = branch.get_revision(mmerge)
168
126
print >> to_file, ' ', line_log(mm_revision, 75)
169
127
ignore.add(mmerge)
170
128
except NoSuchRevision: