Mercurial > hg-stable
changeset 17810:2894d180afa1
changelog: extract description cleaning logic in a dedicated function
The amend logic have use for it.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Thu, 18 Oct 2012 22:04:49 +0200 |
parents | a7462ca7f75e |
children | a8aba2921456 |
files | mercurial/changelog.py |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/changelog.py Thu Oct 18 22:35:28 2012 +0200 +++ b/mercurial/changelog.py Thu Oct 18 22:04:49 2012 +0200 @@ -49,6 +49,10 @@ items = [_string_escape('%s:%s' % (k, d[k])) for k in sorted(d)] return "\0".join(items) +def stripdesc(desc): + """strip trailing whitespace and leading and trailing empty lines""" + return '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n') + class appender(object): '''the changelog index must be updated last on disk, so we use this class to delay writes to it''' @@ -308,8 +312,7 @@ raise error.RevlogError(_("username %s contains a newline") % repr(user)) - # strip trailing whitespace and leading and trailing empty lines - desc = '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n') + desc = stripdesc(desc) if date: parseddate = "%d %d" % util.parsedate(date)