[Svnmerge] Patch for log message indentation
Alan Barrett
apb at cequrux.com
Tue Feb 28 01:58:39 PST 2006
On Tue, 28 Feb 2006, Giovanni Bajo wrote:
> > http://www.orcaware.com/pipermail/svnmerge/2006-February/000225.html
> >
> > Personally, I also find the indented style much easier to read and
> > would like to see his patch committed. If there is some opposition to
> > this, then we can always add a --logindent=n option, where n defaults
> > to 0.
>
> Fine by me. I don't think it's worth an additional command line option.
My patch has the unwanted effect of appending an extra blank line to
each log message. Please don't commit it as-is.
> >> +#LOG_LINE_PREFIX = ''
> >> +LOG_LINE_PREFIX = 2 * ' '
>
> Don't keep a commented line around.
It's intended as a hint to people who want to switch between the
indenting or non-indenting behaviours by editing the script.
> >> +def prefix_lines(prefix, lines):
> >> + """Given a string representing lines of text,
> >> + insert the specified prefix at the begining of each line,
> >> + and return the result."""
> >> + result = ""
> >> + for line in lines.split("\n"):
> >> + result = result + prefix + line + "\n"
> >> + return result
>
> The referenced patch concatenates strings in quadratic time using repeated
> "operator +". A faster version would be:
>
> return "\n".join([prefix + L for L in lines])
Thank you. I assume you meant
return "\n".join([prefix + L for L in lines.split("\n")])
Do you also have an efficient way of removing the last element of
lines.split("\n") if and only if it is empty? For example, given either
of these inputs:
"first line\nsecond line\n"
"first line\nsecond line"
I want to return this output:
" first line\n second line\n"
My existing code incorrectly returns this:
" first line\n second line\n \n"
and your more efficient suggestion above will, I think, return this:
" first line\n second line\n "
--apb (Alan Barrett)
More information about the Svnmerge
mailing list