##// END OF EJS Templates
diff: do not split function name if character encoding is unknown...
Yuya Nishihara -
r36432:44c4a38b default
parent child Browse files
Show More
@@ -13,6 +13,7 b' import zlib'
13
13
14 from .i18n import _
14 from .i18n import _
15 from . import (
15 from . import (
16 encoding,
16 error,
17 error,
17 policy,
18 policy,
18 pycompat,
19 pycompat,
@@ -348,7 +349,11 b' def _unidiff(t1, t2, opts=defaultopts):'
348 # alphanumeric char.
349 # alphanumeric char.
349 for i in xrange(astart - 1, lastpos - 1, -1):
350 for i in xrange(astart - 1, lastpos - 1, -1):
350 if l1[i][0:1].isalnum():
351 if l1[i][0:1].isalnum():
351 func = ' ' + l1[i].rstrip()[:40]
352 func = b' ' + l1[i].rstrip()
353 # split long function name if ASCII. otherwise we have no
354 # idea where the multi-byte boundary is, so just leave it.
355 if encoding.isasciistr(func):
356 func = func[:41]
352 lastfunc[1] = func
357 lastfunc[1] = func
353 break
358 break
354 # by recording this hunk's starting point as the next place to
359 # by recording this hunk's starting point as the next place to
@@ -386,3 +386,73 b' If [diff] git is set to true, but the us'
386 }
386 }
387
387
388 $ cd ..
388 $ cd ..
389
390 Long function names should be abbreviated, but multi-byte character shouldn't
391 be broken up
392
393 $ hg init longfunc
394 $ cd longfunc
395
396 >>> with open('a', 'wb') as f:
397 ... f.write(b'a' * 39 + b'bb' + b'\n')
398 ... f.write(b' .\n' * 3)
399 ... f.write(b' 0 b\n')
400 ... f.write(b' .\n' * 3)
401 ... f.write(b'a' * 39 + b'\xc3\xa0' + b'\n')
402 ... f.write(b' .\n' * 3)
403 ... f.write(b' 0 a with grave (single code point)\n')
404 ... f.write(b' .\n' * 3)
405 ... f.write(b'a' * 39 + b'a\xcc\x80' + b'\n')
406 ... f.write(b' .\n' * 3)
407 ... f.write(b' 0 a with grave (composition)\n')
408 ... f.write(b' .\n' * 3)
409 $ hg ci -qAm0
410
411 >>> with open('a', 'wb') as f:
412 ... f.write(b'a' * 39 + b'bb' + b'\n')
413 ... f.write(b' .\n' * 3)
414 ... f.write(b' 1 b\n')
415 ... f.write(b' .\n' * 3)
416 ... f.write(b'a' * 39 + b'\xc3\xa0' + b'\n')
417 ... f.write(b' .\n' * 3)
418 ... f.write(b' 1 a with grave (single code point)\n')
419 ... f.write(b' .\n' * 3)
420 ... f.write(b'a' * 39 + b'a\xcc\x80' + b'\n')
421 ... f.write(b' .\n' * 3)
422 ... f.write(b' 1 a with grave (composition)\n')
423 ... f.write(b' .\n' * 3)
424 $ hg ci -m1
425
426 $ hg diff -c1 --nodates --show-function
427 diff -r 3e92dd6fa812 -r a256341606cb a
428 --- a/a
429 +++ b/a
430 @@ -2,7 +2,7 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab
431 .
432 .
433 .
434 - 0 b
435 + 1 b
436 .
437 .
438 .
439 @@ -10,7 +10,7 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\xc3\xa0 (esc)
440 .
441 .
442 .
443 - 0 a with grave (single code point)
444 + 1 a with grave (single code point)
445 .
446 .
447 .
448 @@ -18,7 +18,7 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\xcc\x80 (esc)
449 .
450 .
451 .
452 - 0 a with grave (composition)
453 + 1 a with grave (composition)
454 .
455 .
456 .
457
458 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now