Mercurial > hgrepos > DevTools > mercurial-extensions
changeset 196:d6ce48feffd5
Discard leading whitespace (' ', '\t') from fields.
But escape with '@' them if needed.
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Sat, 06 Oct 2018 15:21:40 +0200 |
| parents | f4f13a25fe3e |
| children | 514e564db240 |
| files | extensions/timestamps.py |
| diffstat | 1 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/extensions/timestamps.py Sat Oct 06 14:58:42 2018 +0200 +++ b/extensions/timestamps.py Sat Oct 06 15:21:40 2018 +0200 @@ -30,6 +30,8 @@ If fields contain a ``,`` or ``#`` or ``@``: put them into ``@``; eventually duplicate ``@`` characters within. + Leading white space is discarded from fields. If needed use ``@``. + (This is very roughly simalar to a Perforce checkpoint -- but with comma as fiel separator instead of a space.) @@ -289,8 +291,11 @@ :return: an escaped version or the original one """ + if fn.startswith(' ') or fn.startswith('\t') \ + or fn.endswith(' ') or fn.endswith('\t'): + return "@%s@" % fn.replace('@', "@@") if "," in fn or '@' in fn or '#' in fn: - return "@%s@" % fn.replace("@", "@@") + return "@%s@" % fn.replace('@', "@@") else: return fn @@ -372,6 +377,9 @@ c2 = db.read(1) comment.append(c2) field = comment + elif c in " \t": + if field: + field.append(c) else: field.append(c) c = db.read(1)
