##// END OF EJS Templates
diff: add --stat for diffstat output...
Brodie Rao -
r9640:9e76232f default
parent child Browse files
Show More
@@ -0,0 +1,31 b''
1 #!/bin/sh
2
3 hg init repo
4 cd repo
5 i=0; while (( $i < 213 )); do echo a >> a; i=$(($i + 1)); done
6 hg add a
7
8 echo '% wide diffstat'
9 hg diff --stat
10
11 echo '% diffstat width'
12 COLUMNS=24 hg diff --config ui.interactive=true --stat
13
14 hg ci -m adda
15
16 cat >> a <<EOF
17 a
18 a
19 a
20 EOF
21
22 echo '% narrow diffstat'
23 hg diff --stat
24
25 hg ci -m appenda
26
27 printf '%b' '\x00' > b
28 hg add b
29
30 echo '% binary diffstat'
31 hg diff --stat
@@ -0,0 +1,12 b''
1 % wide diffstat
2 a | 213 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 1 files changed, 213 insertions(+), 0 deletions(-)
4 % diffstat width
5 a | 213 ++++++++++++++
6 1 files changed, 213 insertions(+), 0 deletions(-)
7 % narrow diffstat
8 a | 3 +++
9 1 files changed, 3 insertions(+), 0 deletions(-)
10 % binary diffstat
11 b | 0
12 1 files changed, 0 insertions(+), 0 deletions(-)
@@ -420,11 +420,19 b' class queue(object):'
420
420
421 def printdiff(self, repo, node1, node2=None, files=None,
421 def printdiff(self, repo, node1, node2=None, files=None,
422 fp=None, changes=None, opts={}):
422 fp=None, changes=None, opts={}):
423 stat = opts.get('stat')
424 if stat:
425 opts['unified'] = '0'
426
423 m = cmdutil.match(repo, files, opts)
427 m = cmdutil.match(repo, files, opts)
424 chunks = patch.diff(repo, node1, node2, m, changes, self.diffopts())
428 chunks = patch.diff(repo, node1, node2, m, changes, self.diffopts())
425 write = fp is None and repo.ui.write or fp.write
429 write = fp is None and repo.ui.write or fp.write
426 for chunk in chunks:
430 if stat:
427 write(chunk)
431 width = self.ui.interactive() and util.termwidth() or 80
432 write(patch.diffstat(util.iterlines(chunks), width=width))
433 else:
434 for chunk in chunks:
435 write(chunk)
428
436
429 def mergeone(self, repo, mergeq, head, patch, rev):
437 def mergeone(self, repo, mergeq, head, patch, rev):
430 # first try just applying the patch
438 # first try just applying the patch
@@ -1085,6 +1085,7 b' def diff(ui, repo, *pats, **opts):'
1085
1085
1086 revs = opts.get('rev')
1086 revs = opts.get('rev')
1087 change = opts.get('change')
1087 change = opts.get('change')
1088 stat = opts.get('stat')
1088
1089
1089 if revs and change:
1090 if revs and change:
1090 msg = _('cannot specify --rev and --change at the same time')
1091 msg = _('cannot specify --rev and --change at the same time')
@@ -1095,10 +1096,17 b' def diff(ui, repo, *pats, **opts):'
1095 else:
1096 else:
1096 node1, node2 = cmdutil.revpair(repo, revs)
1097 node1, node2 = cmdutil.revpair(repo, revs)
1097
1098
1099 if stat:
1100 opts['unified'] = '0'
1101
1098 m = cmdutil.match(repo, pats, opts)
1102 m = cmdutil.match(repo, pats, opts)
1099 it = patch.diff(repo, node1, node2, match=m, opts=patch.diffopts(ui, opts))
1103 it = patch.diff(repo, node1, node2, match=m, opts=patch.diffopts(ui, opts))
1100 for chunk in it:
1104 if stat:
1101 ui.write(chunk)
1105 width = ui.interactive() and util.termwidth() or 80
1106 ui.write(patch.diffstat(util.iterlines(it), width=width))
1107 else:
1108 for chunk in it:
1109 ui.write(chunk)
1102
1110
1103 def export(ui, repo, *changesets, **opts):
1111 def export(ui, repo, *changesets, **opts):
1104 """dump the header and diffs for one or more changesets
1112 """dump the header and diffs for one or more changesets
@@ -3260,7 +3268,8 b' diffopts2 = ['
3260 _('ignore changes in the amount of white space')),
3268 _('ignore changes in the amount of white space')),
3261 ('B', 'ignore-blank-lines', None,
3269 ('B', 'ignore-blank-lines', None,
3262 _('ignore changes whose lines are all blank')),
3270 _('ignore changes whose lines are all blank')),
3263 ('U', 'unified', '', _('number of lines of context to show'))
3271 ('U', 'unified', '', _('number of lines of context to show')),
3272 ('', 'stat', None, _('output diffstat-style summary of changes')),
3264 ]
3273 ]
3265
3274
3266 similarityopts = [
3275 similarityopts = [
@@ -167,7 +167,7 b' add: include, exclude, dry-run'
167 annotate: rev, follow, text, user, date, number, changeset, line-number, include, exclude
167 annotate: rev, follow, text, user, date, number, changeset, line-number, include, exclude
168 clone: noupdate, rev, pull, uncompressed, ssh, remotecmd
168 clone: noupdate, rev, pull, uncompressed, ssh, remotecmd
169 commit: addremove, close-branch, include, exclude, message, logfile, date, user
169 commit: addremove, close-branch, include, exclude, message, logfile, date, user
170 diff: rev, change, text, git, nodates, show-function, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, include, exclude
170 diff: rev, change, text, git, nodates, show-function, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, include, exclude
171 export: output, switch-parent, text, git, nodates
171 export: output, switch-parent, text, git, nodates
172 forget: include, exclude
172 forget: include, exclude
173 init: ssh, remotecmd
173 init: ssh, remotecmd
@@ -241,6 +241,7 b' options:'
241 -b --ignore-space-change ignore changes in the amount of white space
241 -b --ignore-space-change ignore changes in the amount of white space
242 -B --ignore-blank-lines ignore changes whose lines are all blank
242 -B --ignore-blank-lines ignore changes whose lines are all blank
243 -U --unified number of lines of context to show
243 -U --unified number of lines of context to show
244 --stat output diffstat-style summary of changes
244 -I --include include names matching the given patterns
245 -I --include include names matching the given patterns
245 -X --exclude exclude names matching the given patterns
246 -X --exclude exclude names matching the given patterns
246
247
General Comments 0
You need to be logged in to leave comments. Login now