[PATCH] (updated) Use the first line of commit message in "log --line"
Matthieu Moy
Matthieu.Moy at imag.fr
Wed May 31 12:43:29 BST 2006
"Michael Ellerman" <michael at ellerman.id.au> writes:
> I guess I'm having a really slow day, but I still don't understand why
> it's preferable to split into a list of two elements, then return a
> list containing only the first, then join the one element list with
> the empty string?
>
>>>> message = 'foo'
>>>> message.split('\n', 1)[0]
> 'foo'
>>>> message = 'foo\nbar'
>>>> message.split('\n', 1)[0]
> 'foo'
>>>> message = ''
>>>> message.split('\n', 1)[0]
> ''
True. The following patch should be OK then.
--
Matthieu
=== modified file 'bzrlib/log.py'
--- bzrlib/log.py
+++ bzrlib/log.py
@@ -461,7 +461,7 @@
out.append("%d:" % revno)
out.append(self.truncate(self.short_committer(rev), 20))
out.append(self.date_string(rev))
- out.append(self.message(rev).replace('\n', ' '))
+ out.append(rev.get_summary())
return self.truncate(" ".join(out).rstrip('\n'), max_chars)
=== modified file 'bzrlib/revision.py'
--- bzrlib/revision.py
+++ bzrlib/revision.py
@@ -101,6 +101,11 @@
reversed_result.reverse()
return reversed_result
+ def get_summary(self):
+ """Get the first line of the log message for this revision.
+ """
+ return self.message.split('\n', 1)[0]
+
def is_ancestor(revision_id, candidate_id, branch):
"""Return true if candidate_id is an ancestor of revision_id.
=== modified file 'bzrlib/tests/blackbox/test_too_much.py'
--- bzrlib/tests/blackbox/test_too_much.py
+++ bzrlib/tests/blackbox/test_too_much.py
@@ -831,7 +831,8 @@
max_width = terminal_width() - 1
for line in log_out.splitlines():
self.assert_(len(line) <= max_width, len(line))
- self.assert_("this is my new commit and" in log_out)
+ self.assert_("this is my new commit and" not in log_out)
+ self.assert_("this is my new commit" in log_out)
progress("file with spaces in name")
mkdir('sub directory')
More information about the bazaar
mailing list