1
# based on Robert Collins code
3
"""Show all 'heads' in shared repository"""
6
from bzrlib.commands import Command, display_command, register_command
9
class cmd_heads(Command):
10
"""Show all revisions in shared repository that does not have descendants.
12
encoding_type = "replace"
16
from bzrlib.errors import NoRepositoryPresent
17
from bzrlib.osutils import format_date
18
import bzrlib.repository
21
r = bzrlib.repository.Repository.open('.')
22
except NoRepositoryPresent, e:
23
print ("You need to run this command "
24
"from the root of shared repository")
27
g = r.get_revision_graph()
28
possible_heads = set(g.keys())
30
for parents in g.values():
31
not_heads.update(set(parents))
33
heads = possible_heads.difference(not_heads)
40
show_timezone = 'original'
44
rev = r.get_revision(head)
45
# borrowed from LonLogFormatter
46
print >>to_file, indent+'committer:', rev.committer
48
print >>to_file, indent+'branch nick: %s' % \
49
rev.properties['branch-nick']
52
date_str = format_date(rev.timestamp,
55
print >>to_file, indent+'timestamp: %s' % date_str
57
print >>to_file, indent+'message:'
59
print >>to_file, indent+' (no message)'
61
message = rev.message.rstrip('\r\n')
62
for l in message.split('\n'):
63
print >>to_file, indent+' ' + l
67
print 'No heads found'
71
register_command(cmd_heads)