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