Rev 2757: (Lukáš Lalinský) Display the author instead of the committer in bzr log and bzr annotate in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Aug 28 08:20:30 BST 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2757
revision-id: pqm at pqm.ubuntu.com-20070828072028-0fvw3cajmigl3h2j
parent: pqm at pqm.ubuntu.com-20070828063300-c92waanwl08dowu9
parent: ian.clatworthy at internode.on.net-20070828064319-g8nl209v23jx0i62
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2007-08-28 08:20:28 +0100
message:
(Lukáš Lalinský) Display the author instead of the committer in bzr log and bzr annotate
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/annotate.py annotate.py-20050922133147-7c60541d2614f022
bzrlib/log.py log.py-20050505065812-c40ce11702fe5fb1
bzrlib/revision.py revision.py-20050309040759-e77802c08f3999d5
bzrlib/tests/test_annotate.py test_annotate.py-20061213215015-sttc9agsxomls7q0-1
bzrlib/tests/test_log.py testlog.py-20050728115707-1a514809d7d49309
bzrlib/tests/test_revision.py testrevision.py-20050804210559-46f5e1eb67b01289
------------------------------------------------------------
revno: 2755.1.1
merged: ian.clatworthy at internode.on.net-20070828064319-g8nl209v23jx0i62
parent: pqm at pqm.ubuntu.com-20070828055422-9h8abp4darakavba
parent: lalinsky at gmail.com-20070816185842-e81rd1i655ityoj6
committer: Ian Clatworthy <ian.clatworthy at internode.on.net>
branch nick: ianc-integration
timestamp: Tue 2007-08-28 16:43:19 +1000
message:
(Lukáš Lalinský) Display the author instead of the committer in bzr log and bzr annotate
------------------------------------------------------------
revno: 2671.2.6.1.8
merged: lalinsky at gmail.com-20070816185842-e81rd1i655ityoj6
parent: lalinsky at gmail.com-20070816185022-nra7t01mk81d47rm
committer: Lukáš Lalinsky <lalinsky at gmail.com>
branch nick: author-2
timestamp: Thu 2007-08-16 20:58:42 +0200
message:
Add tests for LogFormatter.short_committer and LogFormatter.short_author.
------------------------------------------------------------
revno: 2671.2.6.1.7
merged: lalinsky at gmail.com-20070816185022-nra7t01mk81d47rm
parent: lalinsky at gmail.com-20070816133017-3xzc60egty99j1mf
committer: Lukáš Lalinsky <lalinsky at gmail.com>
branch nick: author-2
timestamp: Thu 2007-08-16 20:50:22 +0200
message:
Rename get_author to get_apparent_author, revert the long log back to displaying the committer.
------------------------------------------------------------
revno: 2671.2.6.1.6
merged: lalinsky at gmail.com-20070816133017-3xzc60egty99j1mf
parent: lalinsky at gmail.com-20070816131713-cpssirivmrcsj7yt
committer: Lukáš Lalinsky <lalinsky at gmail.com>
branch nick: author-2
timestamp: Thu 2007-08-16 15:30:17 +0200
message:
Update NEWS.
------------------------------------------------------------
revno: 2671.2.6.1.5
merged: lalinsky at gmail.com-20070816131713-cpssirivmrcsj7yt
parent: lalinsky at gmail.com-20070816131533-z6q24zlopxgys5vd
parent: pqm at pqm.ubuntu.com-20070816100939-8cm630hgejoaur5a
committer: Lukáš Lalinsky <lalinsky at gmail.com>
branch nick: author-2
timestamp: Thu 2007-08-16 15:17:13 +0200
message:
Merge bzr.dev.
------------------------------------------------------------
revno: 2671.2.6.1.4
merged: lalinsky at gmail.com-20070816131533-z6q24zlopxgys5vd
parent: lalinsky at gmail.com-20070815141132-pz74tddh5clr867k
committer: Lukáš Lalinsky <lalinsky at gmail.com>
branch nick: author-2
timestamp: Thu 2007-08-16 15:15:33 +0200
message:
Replace the committer with the author in log, the committer is displayed only in the long format and only if it's different from the author.
------------------------------------------------------------
revno: 2671.2.6.1.3
merged: lalinsky at gmail.com-20070815141132-pz74tddh5clr867k
parent: lalinsky at gmail.com-20070815140315-g6sqgjo6cro598aq
committer: Lukáš Lalinsky <lalinsky at gmail.com>
branch nick: author-2
timestamp: Wed 2007-08-15 16:11:32 +0200
message:
Use the author name in annotate.
------------------------------------------------------------
revno: 2671.2.6.1.2
merged: lalinsky at gmail.com-20070815140315-g6sqgjo6cro598aq
parent: lalinsky at gmail.com-20070815135854-kgxau08gxooz5zya
committer: Lukáš Lalinsky <lalinsky at gmail.com>
branch nick: author-2
timestamp: Wed 2007-08-15 16:03:15 +0200
message:
Add Revision.get_author to return the author's name, either from the property 'author' or the name of the committer.
------------------------------------------------------------
revno: 2671.2.6.1.1
merged: lalinsky at gmail.com-20070815135854-kgxau08gxooz5zya
parent: lalinsky at gmail.com-20070808054343-598cls6ybso02utp
committer: Lukáš Lalinsky <lalinsky at gmail.com>
branch nick: author-2
timestamp: Wed 2007-08-15 15:58:54 +0200
message:
Strip leading whitespace from the commit message before using the first line as a commit summary.
=== modified file 'NEWS'
--- a/NEWS 2007-08-28 05:58:53 +0000
+++ b/NEWS 2007-08-28 07:20:28 +0000
@@ -17,7 +17,9 @@
FEATURES:
* New option ``--author`` in ``bzr commit`` to specify the author of the
- change, if it's different from the committer. (Lukáš Lalinský)
+ change, if it's different from the committer. ``bzr log`` and
+ ``bzr annotate`` display the author instead of the committer.
+ (Lukáš Lalinský)
BUG FIXES:
=== modified file 'bzrlib/annotate.py'
--- a/bzrlib/annotate.py 2007-07-06 20:25:52 +0000
+++ b/bzrlib/annotate.py 2007-08-16 18:50:22 +0000
@@ -99,7 +99,7 @@
def _annotate_file(branch, rev_id, file_id):
"""Yield the origins for each line of a file.
- This includes detailed information, such as the committer name, and
+ This includes detailed information, such as the author name, and
date string for the commit, rather than just the revision id.
"""
revision_id_to_revno = branch.get_revision_id_to_revno_map()
@@ -129,7 +129,7 @@
time.gmtime(rev.timestamp + tz))
# a lazy way to get something like the email address
# TODO: Get real email address
- author = rev.committer
+ author = rev.get_apparent_author()
try:
author = extract_email_address(author)
except errors.NoEmailInUsername:
=== modified file 'bzrlib/log.py'
--- a/bzrlib/log.py 2007-08-16 04:42:31 +0000
+++ b/bzrlib/log.py 2007-08-16 18:50:22 +0000
@@ -592,6 +592,9 @@
def short_committer(self, rev):
return re.sub('<.*@.*>', '', rev.committer).strip(' ')
+ def short_author(self, rev):
+ return re.sub('<.*@.*>', '', rev.get_apparent_author()).strip(' ')
+
class LongLogFormatter(LogFormatter):
@@ -624,11 +627,11 @@
print >>to_file, indent + 'revision-id:', revision.rev.revision_id
for parent_id in revision.rev.parent_ids:
print >>to_file, indent + 'parent:', parent_id
- print >>to_file, indent + 'committer:', revision.rev.committer
author = revision.rev.properties.get('author', None)
if author is not None:
print >>to_file, indent + 'author:', author
+ print >>to_file, indent + 'committer:', revision.rev.committer
branch_nick = revision.rev.properties.get('branch-nick', None)
if branch_nick is not None:
@@ -670,7 +673,7 @@
if len(revision.rev.parent_ids) > 1:
is_merge = ' [merge]'
print >>to_file, "%5s %s\t%s%s" % (revision.revno,
- self.short_committer(revision.rev),
+ self.short_author(revision.rev),
format_date(revision.rev.timestamp,
revision.rev.timezone or 0,
self.show_timezone, date_fmt="%Y-%m-%d",
@@ -737,7 +740,7 @@
if revno:
# show revno only when is not None
out.append("%s:" % revno)
- out.append(self.truncate(self.short_committer(rev), 20))
+ out.append(self.truncate(self.short_author(rev), 20))
out.append(self.date_string(rev))
out.append(rev.get_summary())
return self.truncate(" ".join(out).rstrip('\n'), max_chars)
=== modified file 'bzrlib/revision.py'
--- a/bzrlib/revision.py 2007-08-20 13:07:12 +0000
+++ b/bzrlib/revision.py 2007-08-28 06:43:19 +0000
@@ -114,7 +114,15 @@
def get_summary(self):
"""Get the first line of the log message for this revision.
"""
- return self.message.split('\n', 1)[0]
+ return self.message.lstrip().split('\n', 1)[0]
+
+ def get_apparent_author(self):
+ """Return the apparent author of this revision.
+
+ If the revision properties contain the author name,
+ return it. Otherwise return the committer name.
+ """
+ return self.properties.get('author', self.committer)
def is_ancestor(revision_id, candidate_id, branch):
=== modified file 'bzrlib/tests/test_annotate.py'
--- a/bzrlib/tests/test_annotate.py 2007-07-08 13:50:13 +0000
+++ b/bzrlib/tests/test_annotate.py 2007-08-15 14:11:32 +0000
@@ -338,6 +338,30 @@
annotate.annotate_file(tree1.branch, 'rev-2', 'b-id', to_file=to_file)
self.assertContainsRe('2 p.rez | bye\n', to_file.getvalue())
+ def test_annotate_author_or_committer(self):
+ tree1 = self.make_branch_and_tree('tree1')
+
+ self.build_tree_contents([('tree1/a', 'hello')])
+ tree1.add(['a'], ['a-id'])
+ tree1.commit('a', rev_id='rev-1',
+ committer='Committer <committer at example.com>',
+ timestamp=1166046000.00, timezone=0)
+
+ self.build_tree_contents([('tree1/b', 'bye')])
+ tree1.add(['b'], ['b-id'])
+ tree1.commit('b', rev_id='rev-2',
+ committer='Committer <committer at example.com>',
+ author='Author <author at example.com>',
+ timestamp=1166046000.00, timezone=0)
+
+ to_file = StringIO()
+ annotate.annotate_file(tree1.branch, 'rev-1', 'a-id', to_file=to_file)
+ self.assertEqual('1 committ | hello\n', to_file.getvalue())
+
+ to_file = StringIO()
+ annotate.annotate_file(tree1.branch, 'rev-2', 'b-id', to_file=to_file)
+ self.assertEqual('2 author@ | bye\n', to_file.getvalue())
+
class TestReannotate(tests.TestCase):
=== modified file 'bzrlib/tests/test_log.py'
--- a/bzrlib/tests/test_log.py 2007-08-16 17:36:50 +0000
+++ b/bzrlib/tests/test_log.py 2007-08-28 06:43:19 +0000
@@ -18,7 +18,7 @@
from cStringIO import StringIO
from bzrlib import log
-from bzrlib.tests import TestCaseWithTransport
+from bzrlib.tests import TestCase, TestCaseWithTransport
from bzrlib.log import (show_log,
get_view_revisions,
LogRevision,
@@ -28,6 +28,7 @@
LineLogFormatter)
from bzrlib.branch import Branch
from bzrlib.errors import InvalidRevisionNumber
+from bzrlib.revision import Revision
class LogCatcher(LogFormatter):
@@ -200,20 +201,21 @@
b.nick='test'
open('a', 'wb').write('hello moto\n')
wt.add('a')
- wt.commit('simple log message', rev_id='a1'
- , timestamp=1132586655.459960938, timezone=-6*3600
- , committer='Joe Foo <joe at foo.com>')
+ wt.commit('simple log message', rev_id='a1',
+ timestamp=1132586655.459960938, timezone=-6*3600,
+ committer='Joe Foo <joe at foo.com>')
open('b', 'wb').write('goodbye\n')
wt.add('b')
- wt.commit('multiline\nlog\nmessage\n', rev_id='a2'
- , timestamp=1132586842.411175966, timezone=-6*3600
- , committer='Joe Foo <joe at foo.com>')
+ wt.commit('multiline\nlog\nmessage\n', rev_id='a2',
+ timestamp=1132586842.411175966, timezone=-6*3600,
+ committer='Joe Foo <joe at foo.com>',
+ author='Joe Bar <joe at bar.com>')
open('c', 'wb').write('just another manic monday\n')
wt.add('c')
- wt.commit('single line with trailing newline\n', rev_id='a3'
- , timestamp=1132587176.835228920, timezone=-6*3600
- , committer = 'Joe Foo <joe at foo.com>')
+ wt.commit('single line with trailing newline\n', rev_id='a3',
+ timestamp=1132587176.835228920, timezone=-6*3600,
+ committer = 'Joe Foo <joe at foo.com>')
return b
@@ -229,7 +231,7 @@
3 Joe Foo\t2005-11-21
single line with trailing newline
- 2 Joe Foo\t2005-11-21
+ 2 Joe Bar\t2005-11-21
multiline
log
message
@@ -244,14 +246,17 @@
def normalize_log(self,log):
"""Replaces the variable lines of logs with fixed lines"""
+ author = 'author: Dolor Sit <test at example.com>'
committer = 'committer: Lorem Ipsum <test at example.com>'
lines = log.splitlines(True)
for idx,line in enumerate(lines):
stripped_line = line.lstrip()
indent = ' ' * (len(line) - len(stripped_line))
- if stripped_line.startswith('committer:'):
+ if stripped_line.startswith('author:'):
+ lines[idx] = indent + author + '\n'
+ elif stripped_line.startswith('committer:'):
lines[idx] = indent + committer + '\n'
- if stripped_line.startswith('timestamp:'):
+ elif stripped_line.startswith('timestamp:'):
lines[idx] = indent + 'timestamp: Just now\n'
return ''.join(lines)
@@ -414,6 +419,7 @@
single line with trailing newline
------------------------------------------------------------
revno: 2
+author: Joe Bar <joe at bar.com>
committer: Joe Foo <joe at foo.com>
branch nick: test
timestamp: Mon 2005-11-21 09:27:22 -0600
@@ -450,8 +456,8 @@
self.assertEqualDiff(sio.getvalue(), '''\
------------------------------------------------------------
revno: 1
-committer: Lorem Ipsum <test at example.com>
author: John Doe <jdoe at example.com>
+committer: Lorem Ipsum <test at example.com>
branch nick: test_author_log
timestamp: Wed 2005-11-23 12:08:27 +1000
message:
@@ -523,7 +529,7 @@
show_log(b, lf)
self.assertEqualDiff(sio.getvalue(), """\
3: Joe Foo 2005-11-21 single line with trailing newline
-2: Joe Foo 2005-11-21 multiline
+2: Joe Bar 2005-11-21 multiline
1: Joe Foo 2005-11-21 simple log message
""")
@@ -791,3 +797,20 @@
log.show_changed_revisions(tree.branch, [], ['bar-id'], s)
self.assertContainsRe(s.getvalue(), 'bar')
self.assertNotContainsRe(s.getvalue(), 'foo')
+
+
+class TestLogFormatter(TestCase):
+
+ def test_short_committer(self):
+ rev = Revision('a-id')
+ rev.committer = 'John Doe <jdoe at example.com>'
+ lf = LogFormatter(None)
+ self.assertEqual('John Doe', lf.short_committer(rev))
+
+ def test_short_author(self):
+ rev = Revision('a-id')
+ rev.committer = 'John Doe <jdoe at example.com>'
+ lf = LogFormatter(None)
+ self.assertEqual('John Doe', lf.short_author(rev))
+ rev.properties['author'] = 'John Smith <jsmith at example.com>'
+ self.assertEqual('John Smith', lf.short_author(rev))
=== modified file 'bzrlib/tests/test_revision.py'
--- a/bzrlib/tests/test_revision.py 2007-08-14 09:44:20 +0000
+++ b/bzrlib/tests/test_revision.py 2007-08-28 06:43:19 +0000
@@ -309,3 +309,22 @@
self.assertEqual(False, revision.is_reserved_id(
'arch:a at example.com/c--b--v--r'))
self.assertEqual(False, revision.is_reserved_id(None))
+
+
+class TestRevisionMethods(TestCase):
+
+ def test_get_summary(self):
+ r = revision.Revision('1')
+ r.message = 'a'
+ self.assertEqual('a', r.get_summary())
+ r.message = 'a\nb'
+ self.assertEqual('a', r.get_summary())
+ r.message = '\na\nb'
+ self.assertEqual('a', r.get_summary())
+
+ def test_get_apparent_author(self):
+ r = revision.Revision('1')
+ r.committer = 'A'
+ self.assertEqual('A', r.get_apparent_author())
+ r.properties['author'] = 'B'
+ self.assertEqual('B', r.get_apparent_author())
More information about the bazaar-commits
mailing list