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

Michael Ellerman michael at ellerman.id.au
Wed May 31 10:22:29 BST 2006


On 5/31/06, Matthieu Moy <Matthieu.Moy at imag.fr> wrote:
> Here's the updated patch.
>
> Regarding the "\n" escaping, my current decision is that it's not
> worth the trouble. -m is very handy for one-line summary, but the
> shell's multi-line edition or a real text editor is probably much
> better for multi-line messages anyway.
>
> I think it's ready for merging. We can consider adding a -s, --summary
> option later if people ask for it.
>
> --
> 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 ''.join(self.message.split('\n', 1)[:1])
> +

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]
''

??

cheers




More information about the bazaar mailing list