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