diff tests/test-diff-unified.t @ 36444:44c4a38bf563

diff: do not split function name if character encoding is unknown Only ASCII characters can be split reliably at any byte positions, so let's just leave long multi-byte sequence long. It's probably less bad than putting an invalid byte sequence into a diff. This doesn't try to split the first ASCII slice from multi-byte sequence because a combining character may follow.
author Yuya Nishihara <yuya@tcha.org>
date Fri, 23 Feb 2018 23:09:58 +0900
parents 897726622877
children 22f19da5736e
line wrap: on
line diff
--- a/tests/test-diff-unified.t	Sun Feb 25 11:20:35 2018 +0900
+++ b/tests/test-diff-unified.t	Fri Feb 23 23:09:58 2018 +0900
@@ -386,3 +386,73 @@
    }
 
   $ cd ..
+
+Long function names should be abbreviated, but multi-byte character shouldn't
+be broken up
+
+  $ hg init longfunc
+  $ cd longfunc
+
+  >>> with open('a', 'wb') as f:
+  ...     f.write(b'a' * 39 + b'bb' + b'\n')
+  ...     f.write(b' .\n' * 3)
+  ...     f.write(b' 0 b\n')
+  ...     f.write(b' .\n' * 3)
+  ...     f.write(b'a' * 39 + b'\xc3\xa0' + b'\n')
+  ...     f.write(b' .\n' * 3)
+  ...     f.write(b' 0 a with grave (single code point)\n')
+  ...     f.write(b' .\n' * 3)
+  ...     f.write(b'a' * 39 + b'a\xcc\x80' + b'\n')
+  ...     f.write(b' .\n' * 3)
+  ...     f.write(b' 0 a with grave (composition)\n')
+  ...     f.write(b' .\n' * 3)
+  $ hg ci -qAm0
+
+  >>> with open('a', 'wb') as f:
+  ...     f.write(b'a' * 39 + b'bb' + b'\n')
+  ...     f.write(b' .\n' * 3)
+  ...     f.write(b' 1 b\n')
+  ...     f.write(b' .\n' * 3)
+  ...     f.write(b'a' * 39 + b'\xc3\xa0' + b'\n')
+  ...     f.write(b' .\n' * 3)
+  ...     f.write(b' 1 a with grave (single code point)\n')
+  ...     f.write(b' .\n' * 3)
+  ...     f.write(b'a' * 39 + b'a\xcc\x80' + b'\n')
+  ...     f.write(b' .\n' * 3)
+  ...     f.write(b' 1 a with grave (composition)\n')
+  ...     f.write(b' .\n' * 3)
+  $ hg ci -m1
+
+  $ hg diff -c1 --nodates --show-function
+  diff -r 3e92dd6fa812 -r a256341606cb a
+  --- a/a
+  +++ b/a
+  @@ -2,7 +2,7 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab
+    .
+    .
+    .
+  - 0 b
+  + 1 b
+    .
+    .
+    .
+  @@ -10,7 +10,7 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\xc3\xa0 (esc)
+    .
+    .
+    .
+  - 0 a with grave (single code point)
+  + 1 a with grave (single code point)
+    .
+    .
+    .
+  @@ -18,7 +18,7 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\xcc\x80 (esc)
+    .
+    .
+    .
+  - 0 a with grave (composition)
+  + 1 a with grave (composition)
+    .
+    .
+    .
+
+  $ cd ..