##// END OF EJS Templates
patch: restore the previous output of 'diff --stat'...
Steven Brown -
r14437:cbe13e6b default
parent child Browse files
Show More
@@ -1672,14 +1672,15 b' def trydiff(repo, revs, ctx1, ctx2, modi'
1672 1672 yield text
1673 1673
1674 1674 def diffstatsum(stats):
1675 maxfile, addtotal, removetotal, binary = 0, 0, 0, False
1675 maxfile, maxtotal, addtotal, removetotal, binary = 0, 0, 0, 0, False
1676 1676 for f, a, r, b in stats:
1677 1677 maxfile = max(maxfile, encoding.colwidth(f))
1678 maxtotal = max(maxtotal, a + r)
1678 1679 addtotal += a
1679 1680 removetotal += r
1680 1681 binary = binary or b
1681 1682
1682 return maxfile, addtotal, removetotal, binary
1683 return maxfile, maxtotal, addtotal, removetotal, binary
1683 1684
1684 1685 def diffstatdata(lines):
1685 1686 diffre = re.compile('^diff .*-r [a-z0-9]+\s(.*)$')
@@ -1712,8 +1713,7 b' def diffstatdata(lines):'
1712 1713 def diffstat(lines, width=80, git=False):
1713 1714 output = []
1714 1715 stats = diffstatdata(lines)
1715 maxname, totaladds, totalremoves, hasbinary = diffstatsum(stats)
1716 maxtotal = totaladds + totalremoves
1716 maxname, maxtotal, totaladds, totalremoves, hasbinary = diffstatsum(stats)
1717 1717
1718 1718 countwidth = len(str(maxtotal))
1719 1719 if hasbinary and countwidth < 3:
@@ -186,7 +186,7 b' def showdiffstat(repo, ctx, templ, **arg'
186 186 "modified files: +added/-removed lines"
187 187 """
188 188 stats = patch.diffstatdata(util.iterlines(ctx.diff()))
189 maxname, adds, removes, binary = patch.diffstatsum(stats)
189 maxname, maxtotal, adds, removes, binary = patch.diffstatsum(stats)
190 190 return '%s: +%s/-%s' % (len(stats), adds, removes)
191 191
192 192 def showextras(**args):
@@ -2,18 +2,22 b''
2 2 $ cd repo
3 3 $ i=0; while [ "$i" -lt 213 ]; do echo a >> a; i=`expr $i + 1`; done
4 4 $ hg add a
5 $ cp a b
6 $ hg add b
5 7
6 8 Wide diffstat:
7 9
8 10 $ hg diff --stat
9 11 a | 213 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
10 1 files changed, 213 insertions(+), 0 deletions(-)
12 b | 213 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
13 2 files changed, 426 insertions(+), 0 deletions(-)
11 14
12 15 diffstat width:
13 16
14 17 $ COLUMNS=24 hg diff --config ui.interactive=true --stat
15 18 a | 213 ++++++++++++++
16 1 files changed, 213 insertions(+), 0 deletions(-)
19 b | 213 ++++++++++++++
20 2 files changed, 426 insertions(+), 0 deletions(-)
17 21
18 22 $ hg ci -m adda
19 23
@@ -31,19 +35,19 b' Narrow diffstat:'
31 35
32 36 $ hg ci -m appenda
33 37
34 $ printf '\0' > b
35 $ hg add b
38 $ printf '\0' > c
39 $ hg add c
36 40
37 41 Binary diffstat:
38 42
39 43 $ hg diff --stat
40 b | 0
44 c | 0
41 45 1 files changed, 0 insertions(+), 0 deletions(-)
42 46
43 47 Binary git diffstat:
44 48
45 49 $ hg diff --stat --git
46 b | Bin
50 c | Bin
47 51 1 files changed, 0 insertions(+), 0 deletions(-)
48 52
49 53 $ hg ci -m createb
General Comments 0
You need to be logged in to leave comments. Login now