1
# Copyright (C) 2005 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
def show_log(branch, show_timezone='original', verbose=False,
20
"""Write out human-readable log of commits to this branch.
23
'original' (committer's timezone),
24
'utc' (universal time), or
25
'local' (local user's timezone)
28
If true show added/changed/deleted/renamed files.
31
If true, show revision and file ids.
34
File to send log to; by default stdout.
36
from osutils import format_date
37
from errors import BzrCheckError
38
from diff import diff_trees
39
from textui import show_status
45
branch._need_readlock()
48
for revision_id in branch.revision_history():
51
rev = branch.get_revision(revision_id)
53
print 'revision-id:', revision_id
54
print 'committer:', rev.committer
55
print 'timestamp: %s' % (format_date(rev.timestamp, rev.timezone or 0,
58
## opportunistic consistency check, same as check_patch_chaining
59
if rev.precursor != precursor:
60
raise BzrCheckError("mismatched precursor!")
66
for l in rev.message.split('\n'):
69
if verbose and precursor:
70
# TODO: Group as added/deleted/renamed instead
72
print 'changed files:'
73
tree = branch.revision_tree(revision_id)
74
prevtree = branch.revision_tree(precursor)
76
for file_state, fid, old_name, new_name, kind in \
77
diff_trees(prevtree, tree, ):
78
if file_state == 'A' or file_state == 'M':
79
show_status(file_state, kind, new_name)
80
elif file_state == 'D':
81
show_status(file_state, kind, old_name)
82
elif file_state == 'R':
83
show_status(file_state, kind,
84
old_name + ' => ' + new_name)
87
precursor = revision_id