comparison mercurial/commands.py @ 9640:9e76232fbfbe

diff: add --stat for diffstat output diff/qdiff --stat invokes patch.diffstat() on the diff output. When in interactive mode, the output's maximum width is determined by the terminal's width.
author Brodie Rao <me+hg@dackz.net>
date Sun, 25 Oct 2009 02:52:35 +0200
parents 926eba48eac9
children 7d17794f08a9
comparison
equal deleted inserted replaced
9639:5384a22ab698 9640:9e76232fbfbe
1083 format. For more information, read 'hg help diffs'. 1083 format. For more information, read 'hg help diffs'.
1084 """ 1084 """
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')
1091 raise util.Abort(msg) 1092 raise util.Abort(msg)
1092 elif change: 1093 elif change:
1093 node2 = repo.lookup(change) 1094 node2 = repo.lookup(change)
1094 node1 = repo[node2].parents()[0].node() 1095 node1 = repo[node2].parents()[0].node()
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
1105 1113
1106 Print the changeset header and diffs for one or more revisions. 1114 Print the changeset header and diffs for one or more revisions.
3258 _('ignore white space when comparing lines')), 3266 _('ignore white space when comparing lines')),
3259 ('b', 'ignore-space-change', None, 3267 ('b', 'ignore-space-change', None,
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 = [
3267 ('s', 'similarity', '', 3276 ('s', 'similarity', '',
3268 _('guess renamed files by similarity (0<=s<=100)')) 3277 _('guess renamed files by similarity (0<=s<=100)'))