##// END OF EJS Templates
diffstat: be more picky when marking file as 'binary' (issue2816)...
Patrick Mezard -
r15363:628a4a9e stable
parent child Browse files
Show More
@@ -1787,18 +1787,17 b' def diffstatdata(lines):'
1787 diffre = re.compile('^diff .*-r [a-z0-9]+\s(.*)$')
1787 diffre = re.compile('^diff .*-r [a-z0-9]+\s(.*)$')
1788
1788
1789 results = []
1789 results = []
1790 filename, adds, removes = None, 0, 0
1790 filename, adds, removes, isbinary = None, 0, 0, False
1791
1791
1792 def addresult():
1792 def addresult():
1793 if filename:
1793 if filename:
1794 isbinary = adds == 0 and removes == 0
1795 results.append((filename, adds, removes, isbinary))
1794 results.append((filename, adds, removes, isbinary))
1796
1795
1797 for line in lines:
1796 for line in lines:
1798 if line.startswith('diff'):
1797 if line.startswith('diff'):
1799 addresult()
1798 addresult()
1800 # set numbers to 0 anyway when starting new file
1799 # set numbers to 0 anyway when starting new file
1801 adds, removes = 0, 0
1800 adds, removes, isbinary = 0, 0, False
1802 if line.startswith('diff --git'):
1801 if line.startswith('diff --git'):
1803 filename = gitre.search(line).group(1)
1802 filename = gitre.search(line).group(1)
1804 elif line.startswith('diff -r'):
1803 elif line.startswith('diff -r'):
@@ -1808,6 +1807,9 b' def diffstatdata(lines):'
1808 adds += 1
1807 adds += 1
1809 elif line.startswith('-') and not line.startswith('---'):
1808 elif line.startswith('-') and not line.startswith('---'):
1810 removes += 1
1809 removes += 1
1810 elif (line.startswith('GIT binary patch') or
1811 line.startswith('Binary file')):
1812 isbinary = True
1811 addresult()
1813 addresult()
1812 return results
1814 return results
1813
1815
@@ -1832,7 +1834,7 b' def diffstat(lines, width=80, git=False)'
1832 return max(i * graphwidth // maxtotal, int(bool(i)))
1834 return max(i * graphwidth // maxtotal, int(bool(i)))
1833
1835
1834 for filename, adds, removes, isbinary in stats:
1836 for filename, adds, removes, isbinary in stats:
1835 if git and isbinary:
1837 if isbinary:
1836 count = 'Bin'
1838 count = 'Bin'
1837 else:
1839 else:
1838 count = adds + removes
1840 count = adds + removes
@@ -36,19 +36,21 b' Narrow diffstat:'
36 $ hg ci -m appenda
36 $ hg ci -m appenda
37
37
38 $ printf '\0' > c
38 $ printf '\0' > c
39 $ hg add c
39 $ touch d
40 $ hg add c d
40
41
41 Binary diffstat:
42 Binary diffstat:
42
43
43 $ hg diff --stat
44 $ hg diff --stat
44 c | 0
45 c | Bin
45 1 files changed, 0 insertions(+), 0 deletions(-)
46 1 files changed, 0 insertions(+), 0 deletions(-)
46
47
47 Binary git diffstat:
48 Binary git diffstat:
48
49
49 $ hg diff --stat --git
50 $ hg diff --stat --git
50 c | Bin
51 c | Bin
51 1 files changed, 0 insertions(+), 0 deletions(-)
52 d | 0
53 2 files changed, 0 insertions(+), 0 deletions(-)
52
54
53 $ hg ci -m createb
55 $ hg ci -m createb
54
56
@@ -58,7 +60,7 b' Binary git diffstat:'
58 Filename with spaces diffstat:
60 Filename with spaces diffstat:
59
61
60 $ hg diff --stat
62 $ hg diff --stat
61 file with spaces | 0
63 file with spaces | Bin
62 1 files changed, 0 insertions(+), 0 deletions(-)
64 1 files changed, 0 insertions(+), 0 deletions(-)
63
65
64 Filename with spaces git diffstat:
66 Filename with spaces git diffstat:
General Comments 0
You need to be logged in to leave comments. Login now