[PATCH] Use the first line of commit message in "log --line"

John A Meinel john at arbash-meinel.com
Tue May 30 06:41:42 BST 2006


Michael Ellerman wrote:
> On Tue, 2006-05-30 at 10:07 +1000, Robert Collins wrote:
>> On Tue, 2006-05-30 at 09:56 +1000, Michael Ellerman wrote:
>>> On 5/30/06, Robert Collins <robertc at robertcollins.net> wrote:
>>>> firstline seems a little overcomplicated. A simpler version:
>>>> def firstline(self, string):
>>>> # using a type name as a variable name is frowned upon which is why we
>>>> # use string, not str
>>>>     return "".join(string.splitlines()[:1])
>>> return string.splitlines()[0]  ?
>>>
>>> cheers
>>>
>>>>> "".splitlines()[0]

...

>> While the message should always have content, its less safe ;)
> 
> Ah, weird, splitlines sucks :)
> 
>>>> ''.split('\n')[0]
> ''
> 
> cheers


Not really, we are indexing a list.

For performance reasons ''.join(string.split('\n', 1)[:1])

might be better. Then bzr doesn't have to split every line of the text
message, just the first one.
Though really it would seem that:
try:
  return string[:string.index('\n')]
except IndexError:
  return string

could work as well. Are we also desiring to remove the '\r' character?

John
=:->

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060530/819daaf7/attachment.pgp 


More information about the bazaar mailing list