Mercurial > hgrepos > DevTools > mercurial-extensions
changeset 240:f3a4f1bc87ad
Count physical lines within quoted strings also
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Sat, 03 Nov 2018 23:13:53 +0100 |
| parents | bed05593eb8c |
| children | 75ae41055a0e |
| files | extensions/timestamps.py |
| diffstat | 1 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/extensions/timestamps.py Sat Nov 03 22:58:08 2018 +0100 +++ b/extensions/timestamps.py Sat Nov 03 23:13:53 2018 +0100 @@ -387,7 +387,7 @@ c = fp.read(1) record = [] field = [] - lineno = 1 + lineno = 1 # physical line number merge_block = '' while c: if c in '\r\n': @@ -439,6 +439,18 @@ # the next character will be read below: # just stay at the trailing `@' # + elif c2 in '\r\n': + if c2 == '\r': + # + # handle CR-LF ('\r\n') combination: skip a '\n' that + # follows directly + # + c3 = fp.peek(1) + if c3 and c3[0] == '\n': + fp.read(1) + lineno += 1 + sf.append('\n') + c2 = fp.read(1) else: sf.append(c2) c2 = fp.read(1)
