19
"""Code to show logs of changes.
21
Various flavors of log can be produced:
23
* for one file, or the whole tree, and (not done yet) for
24
files in a given directory
26
* in "verbose" mode with a description of what changed from one
29
* with file-ids and revision-ids shown
31
* from last to first or (not anymore) from first to last;
32
the default is "reversed" because it shows the likely most
33
relevant and interesting information first
35
* (not yet) in XML format
20
40
def find_touching_revisions(branch, file_id):
21
41
"""Yield a description of revisions which affect the file_id.
97
123
to_file = sys.stdout
100
file_id = branch.read_working_inventory().path2id(filename)
102
for revno, revid, why in find_touching_revisions(branch, file_id):
106
for i, revid in enumerate(branch.revision_history()):
109
branch._need_readlock()
125
if specific_fileid or verbose:
126
raise NotImplementedError('sorry, option not implemented at the moment')
128
which_revs = branch.enum_history(direction)
130
for revno, revision_id in which_revs:
131
# TODO: if filename given, check if it's changed; if not
132
# changed, skip this one
134
# TODO: if verbose, get a list of changes; if we're running
135
# forward then the delta is as compared to the previous
136
# version, otherwise as compared to the *next* version to be
137
# enumerated; in both cases must treat 0 specially as the
140
rev = branch.get_revision(revision_id)
142
show_one_log(revno, rev, delta, show_ids, to_file, show_timezone)
112
148
from tree import EmptyTree
113
149
prev_tree = EmptyTree()
114
for revno, revision_id in which_revs():
115
print >>to_file, '-' * 60
116
print >>to_file, 'revno:', revno
117
rev = branch.get_revision(revision_id)
119
print >>to_file, 'revision-id:', revision_id
120
print >>to_file, 'committer:', rev.committer
121
print >>to_file, 'timestamp: %s' % (format_date(rev.timestamp, rev.timezone or 0,
124
if revision_id != rev.revision_id:
125
raise BzrCheckError("retrieved wrong revision: %r"
126
% (revision_id, rev.revision_id))
128
print >>to_file, 'message:'
130
print >>to_file, ' (no message)'
132
for l in rev.message.split('\n'):
133
print >>to_file, ' ' + l
135
# Don't show a list of changed files if we were asked about
139
this_tree = branch.revision_tree(revision_id)
140
delta = compare_trees(prev_tree, this_tree, want_unchanged=False)
141
delta.show(to_file, show_ids)
142
prev_tree = this_tree
150
for revno, revision_id in which_revs:
144
151
precursor = revision_id
153
if revision_id != rev.revision_id:
154
raise BzrCheckError("retrieved wrong revision: %r"
155
% (revision_id, rev.revision_id))
158
this_tree = branch.revision_tree(revision_id)
159
delta = compare_trees(prev_tree, this_tree, want_unchanged=False)
160
prev_tree = this_tree
166
def show_one_log(revno, rev, delta, show_ids, to_file, show_timezone):
167
from osutils import format_date
169
print >>to_file, '-' * 60
170
print >>to_file, 'revno:', revno
172
print >>to_file, 'revision-id:', rev.revision_id
173
print >>to_file, 'committer:', rev.committer
174
print >>to_file, 'timestamp: %s' % (format_date(rev.timestamp, rev.timezone or 0,
177
print >>to_file, 'message:'
179
print >>to_file, ' (no message)'
181
for l in rev.message.split('\n'):
182
print >>to_file, ' ' + l
185
delta.show(to_file, show_ids)