# HG changeset patch # User Isaac Jurado # Date 1397913085 -7200 # Node ID 9846b40d01e78fe9d95abe6adc73dd0af31bc375 # Parent d924e387604f4a1b90469de773517841eba40c80 churn: compute padding with unicode strings Most UTF-8 aware terminals convert multibyte sequences into a single displayed characters. Because the first column is padded by counting bytes, the second column is not perfectly aligned in the presence of non ASCII characters. diff -r d924e387604f -r 9846b40d01e7 hgext/churn.py --- a/hgext/churn.py Thu Apr 17 19:39:04 2014 -0400 +++ b/hgext/churn.py Sat Apr 19 15:11:25 2014 +0200 @@ -10,6 +10,7 @@ from mercurial.i18n import _ from mercurial import patch, cmdutil, scmutil, util, templater, commands +from mercurial import encoding import os import time, datetime @@ -124,7 +125,7 @@ Aliases will be split from the rightmost "=". ''' def pad(s, l): - return (s + " " * l)[:l] + return s + " " * (l - encoding.colwidth(s)) amap = {} aliases = opts.get('aliases') diff -r d924e387604f -r 9846b40d01e7 tests/test-churn.t --- a/tests/test-churn.t Thu Apr 17 19:39:04 2014 -0400 +++ b/tests/test-churn.t Sat Apr 19 15:11:25 2014 +0200 @@ -159,4 +159,16 @@ user4@x.com 2 ***************************** with space 1 ************** +Test multibyte sequences in names + + $ echo bar >> bar + $ hg --encoding utf-8 ci -m'changed bar' -u 'El NiƱo ' + $ hg --encoding utf-8 churn -ct '{author|person}' + user1 4 ********************************************************** + user3 3 ******************************************** + user2 2 ***************************** + user4 2 ***************************** + El Ni\xc3\xb1o 1 *************** (esc) + with space 1 *************** + $ cd ..