Rev 3954: show tags in log --short/--line (Ian Clatworthy) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Jan 23 04:28:42 GMT 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3954
revision-id: pqm at pqm.ubuntu.com-20090123042837-r1lyxrbk6nd5pp3g
parent: pqm at pqm.ubuntu.com-20090122221456-p57kr0fane0s4iv8
parent: ian.clatworthy at canonical.com-20090123022942-yuqntutz88zsze1v
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2009-01-23 04:28:37 +0000
message:
show tags in log --short/--line (Ian Clatworthy)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/log.py log.py-20050505065812-c40ce11702fe5fb1
bzrlib/tests/test_log.py testlog.py-20050728115707-1a514809d7d49309
------------------------------------------------------------
revno: 3953.1.1
revision-id: ian.clatworthy at canonical.com-20090123022942-yuqntutz88zsze1v
parent: pqm at pqm.ubuntu.com-20090122221456-p57kr0fane0s4iv8
parent: ian.clatworthy at canonical.com-20090123020302-8064ye1bqry09c30
committer: Ian Clatworthy <ian.clatworthy at canonical.com>
branch nick: ianc-integration
timestamp: Fri 2009-01-23 12:29:42 +1000
message:
show tags in log --short/--line
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/log.py log.py-20050505065812-c40ce11702fe5fb1
bzrlib/tests/test_log.py testlog.py-20050728115707-1a514809d7d49309
------------------------------------------------------------
revno: 3946.3.4
revision-id: ian.clatworthy at canonical.com-20090123020302-8064ye1bqry09c30
parent: ian.clatworthy at canonical.com-20090123015949-rbju3vhsb33xsqba
committer: Ian Clatworthy <ian.clatworthy at canonical.com>
branch nick: bzr.log-tags-in-short-line
timestamp: Fri 2009-01-23 12:03:02 +1000
message:
minor cleanup
modified:
bzrlib/log.py log.py-20050505065812-c40ce11702fe5fb1
------------------------------------------------------------
revno: 3946.3.3
revision-id: ian.clatworthy at canonical.com-20090123015949-rbju3vhsb33xsqba
parent: ian.clatworthy at canonical.com-20090119190908-nvwsm36u03sc5tah
committer: Ian Clatworthy <ian.clatworthy at canonical.com>
branch nick: bzr.log-tags-in-short-line
timestamp: Fri 2009-01-23 11:59:49 +1000
message:
feedback from jelmer re position of tags in --line
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/log.py log.py-20050505065812-c40ce11702fe5fb1
bzrlib/tests/test_log.py testlog.py-20050728115707-1a514809d7d49309
------------------------------------------------------------
revno: 3946.3.2
revision-id: ian.clatworthy at canonical.com-20090119190908-nvwsm36u03sc5tah
parent: ian.clatworthy at canonical.com-20090119182212-pl143nxuskb2moun
committer: Ian Clatworthy <ian.clatworthy at canonical.com>
branch nick: bzr.log-tags-in-short-line
timestamp: Tue 2009-01-20 05:09:08 +1000
message:
add tests & NEWS item
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/log.py log.py-20050505065812-c40ce11702fe5fb1
bzrlib/tests/test_log.py testlog.py-20050728115707-1a514809d7d49309
------------------------------------------------------------
revno: 3946.3.1
revision-id: ian.clatworthy at canonical.com-20090119182212-pl143nxuskb2moun
parent: pqm at pqm.ubuntu.com-20090119130916-zr1sbw0hn7rbip3y
committer: Ian Clatworthy <ian.clatworthy at canonical.com>
branch nick: bzr.log-tags-in-short-line
timestamp: Tue 2009-01-20 04:22:12 +1000
message:
extend ShortLogFormatter & LineLogFormatter to support tags
modified:
bzrlib/log.py log.py-20050505065812-c40ce11702fe5fb1
=== modified file 'NEWS'
--- a/NEWS 2009-01-22 22:14:56 +0000
+++ b/NEWS 2009-01-23 02:29:42 +0000
@@ -22,6 +22,11 @@
merging from trunk and completes much faster. To see all merged
revisions, use the new ``-v`` flag. (Ian Clatworthy)
+ * ``bzr log --line`` now shows any tags after the date and before
+ the commit message. If you have scripts which parse the output
+ from this command, you may need to adjust them accordingly.
+ (Ian Clatworthy)
+
NEW FEATURES:
IMPROVEMENTS:
@@ -29,6 +34,12 @@
* ``bzr init`` will now print a little less verbose output.
(Marius Kruger)
+ * ``bzr log --short`` and ``bzr log --line`` now show tags, if any,
+ for each revision. The tags are shown comma-separated inside
+ ``{}``. For short format, the tags appear at the end of line
+ before the optional ``[merge]`` indicator. For line format,
+ the tags appear after the date. (Ian Clatworthy)
+
* Rule-based preferences can now accept multiple patterns for a set of
rules. (Marius Kruger)
=== modified file 'bzrlib/log.py'
--- a/bzrlib/log.py 2009-01-20 21:03:00 +0000
+++ b/bzrlib/log.py 2009-01-23 02:29:42 +0000
@@ -830,6 +830,7 @@
class ShortLogFormatter(LogFormatter):
supports_delta = True
+ supports_tags = True
supports_single_merge_revision = True
def log_revision(self, revision):
@@ -837,13 +838,17 @@
is_merge = ''
if len(revision.rev.parent_ids) > 1:
is_merge = ' [merge]'
- to_file.write("%5s %s\t%s%s\n" % (revision.revno,
+ tags = ''
+ if revision.tags:
+ tags = ' {%s}' % (', '.join(revision.tags))
+
+ to_file.write("%5s %s\t%s%s%s\n" % (revision.revno,
self.short_author(revision.rev),
format_date(revision.rev.timestamp,
revision.rev.timezone or 0,
self.show_timezone, date_fmt="%Y-%m-%d",
show_offset=False),
- is_merge))
+ tags, is_merge))
if self.show_ids:
to_file.write(' revision-id:%s\n'
% (revision.rev.revision_id,))
@@ -862,6 +867,7 @@
class LineLogFormatter(LogFormatter):
+ supports_tags = True
supports_single_merge_revision = True
def __init__(self, *args, **kwargs):
@@ -886,15 +892,16 @@
def log_revision(self, revision):
self.to_file.write(self.log_string(revision.revno, revision.rev,
- self._max_chars))
+ self._max_chars, revision.tags))
self.to_file.write('\n')
- def log_string(self, revno, rev, max_chars):
+ def log_string(self, revno, rev, max_chars, tags=None):
"""Format log info into one string. Truncate tail of string
:param revno: revision number or None.
Revision numbers counts from 1.
- :param rev: revision info object
+ :param rev: revision object
:param max_chars: maximum length of resulting string
+ :param tags: list of tags or None
:return: formatted truncated string
"""
out = []
@@ -903,6 +910,9 @@
out.append("%s:" % revno)
out.append(self.truncate(self.short_author(rev), 20))
out.append(self.date_string(rev))
+ if tags:
+ tag_str = '{%s}' % (', '.join(tags))
+ out.append(tag_str)
out.append(rev.get_summary())
return self.truncate(" ".join(out).rstrip('\n'), max_chars)
=== modified file 'bzrlib/tests/test_log.py'
--- a/bzrlib/tests/test_log.py 2009-01-16 22:32:24 +0000
+++ b/bzrlib/tests/test_log.py 2009-01-23 02:29:42 +0000
@@ -290,22 +290,34 @@
""",
sio.getvalue())
+ def _prepare_tree_with_merges(self, with_tags=False):
+ wt = self.make_branch_and_memory_tree('.')
+ wt.lock_write()
+ self.addCleanup(wt.unlock)
+ wt.add('')
+ wt.commit('rev-1', rev_id='rev-1',
+ timestamp=1132586655, timezone=36000,
+ committer='Joe Foo <joe at foo.com>')
+ wt.commit('rev-merged', rev_id='rev-2a',
+ timestamp=1132586700, timezone=36000,
+ committer='Joe Foo <joe at foo.com>')
+ wt.set_parent_ids(['rev-1', 'rev-2a'])
+ wt.branch.set_last_revision_info(1, 'rev-1')
+ wt.commit('rev-2', rev_id='rev-2b',
+ timestamp=1132586800, timezone=36000,
+ committer='Joe Foo <joe at foo.com>')
+ if with_tags:
+ branch = wt.branch
+ branch.tags.set_tag('v0.2', 'rev-2b')
+ wt.commit('rev-3', rev_id='rev-3',
+ timestamp=1132586900, timezone=36000,
+ committer='Jane Foo <jane at foo.com>')
+ branch.tags.set_tag('v1.0rc1', 'rev-3')
+ branch.tags.set_tag('v1.0', 'rev-3')
+ return wt
+
def test_short_log_with_merges(self):
- wt = self.make_branch_and_memory_tree('.')
- wt.lock_write()
- self.addCleanup(wt.unlock)
- wt.add('')
- wt.commit('rev-1', rev_id='rev-1',
- timestamp=1132586655, timezone=36000,
- committer='Joe Foo <joe at foo.com>')
- wt.commit('rev-merged', rev_id='rev-2a',
- timestamp=1132586700, timezone=36000,
- committer='Joe Foo <joe at foo.com>')
- wt.set_parent_ids(['rev-1', 'rev-2a'])
- wt.branch.set_last_revision_info(1, 'rev-1')
- wt.commit('rev-2', rev_id='rev-2b',
- timestamp=1132586800, timezone=36000,
- committer='Joe Foo <joe at foo.com>')
+ wt = self._prepare_tree_with_merges()
logfile = self.make_utf8_encoded_stringio()
formatter = log.ShortLogFormatter(to_file=logfile)
log.show_log(wt.branch, formatter)
@@ -357,6 +369,24 @@
""",
logfile.getvalue())
+ def test_short_log_with_tags(self):
+ wt = self._prepare_tree_with_merges(with_tags=True)
+ logfile = self.make_utf8_encoded_stringio()
+ formatter = log.ShortLogFormatter(to_file=logfile)
+ log.show_log(wt.branch, formatter)
+ self.assertEqualDiff("""\
+ 3 Jane Foo\t2005-11-22 {v1.0, v1.0rc1}
+ rev-3
+
+ 2 Joe Foo\t2005-11-22 {v0.2} [merge]
+ rev-2
+
+ 1 Joe Foo\t2005-11-22
+ rev-1
+
+""",
+ logfile.getvalue())
+
def test_short_log_single_merge_revision(self):
wt = self.make_branch_and_memory_tree('.')
wt.lock_write()
@@ -739,22 +769,34 @@
""",
sio.getvalue())
+ def _prepare_tree_with_merges(self, with_tags=False):
+ wt = self.make_branch_and_memory_tree('.')
+ wt.lock_write()
+ self.addCleanup(wt.unlock)
+ wt.add('')
+ wt.commit('rev-1', rev_id='rev-1',
+ timestamp=1132586655, timezone=36000,
+ committer='Joe Foo <joe at foo.com>')
+ wt.commit('rev-merged', rev_id='rev-2a',
+ timestamp=1132586700, timezone=36000,
+ committer='Joe Foo <joe at foo.com>')
+ wt.set_parent_ids(['rev-1', 'rev-2a'])
+ wt.branch.set_last_revision_info(1, 'rev-1')
+ wt.commit('rev-2', rev_id='rev-2b',
+ timestamp=1132586800, timezone=36000,
+ committer='Joe Foo <joe at foo.com>')
+ if with_tags:
+ branch = wt.branch
+ branch.tags.set_tag('v0.2', 'rev-2b')
+ wt.commit('rev-3', rev_id='rev-3',
+ timestamp=1132586900, timezone=36000,
+ committer='Jane Foo <jane at foo.com>')
+ branch.tags.set_tag('v1.0rc1', 'rev-3')
+ branch.tags.set_tag('v1.0', 'rev-3')
+ return wt
+
def test_line_log_single_merge_revision(self):
- wt = self.make_branch_and_memory_tree('.')
- wt.lock_write()
- self.addCleanup(wt.unlock)
- wt.add('')
- wt.commit('rev-1', rev_id='rev-1',
- timestamp=1132586655, timezone=36000,
- committer='Joe Foo <joe at foo.com>')
- wt.commit('rev-merged', rev_id='rev-2a',
- timestamp=1132586700, timezone=36000,
- committer='Joe Foo <joe at foo.com>')
- wt.set_parent_ids(['rev-1', 'rev-2a'])
- wt.branch.set_last_revision_info(1, 'rev-1')
- wt.commit('rev-2', rev_id='rev-2b',
- timestamp=1132586800, timezone=36000,
- committer='Joe Foo <joe at foo.com>')
+ wt = self._prepare_tree_with_merges()
logfile = self.make_utf8_encoded_stringio()
formatter = log.LineLogFormatter(to_file=logfile)
revspec = revisionspec.RevisionSpec.from_string('1.1.1')
@@ -766,6 +808,17 @@
""",
logfile.getvalue())
+ def test_line_log_with_tags(self):
+ wt = self._prepare_tree_with_merges(with_tags=True)
+ logfile = self.make_utf8_encoded_stringio()
+ formatter = log.LineLogFormatter(to_file=logfile)
+ log.show_log(wt.branch, formatter)
+ self.assertEqualDiff("""\
+3: Jane Foo 2005-11-22 {v1.0, v1.0rc1} rev-3
+2: Joe Foo 2005-11-22 {v0.2} rev-2
+1: Joe Foo 2005-11-22 rev-1
+""",
+ logfile.getvalue())
class TestGetViewRevisions(tests.TestCaseWithTransport):
More information about the bazaar-commits
mailing list