Mercurial > public > mercurial-scm > hg
diff mercurial/commands.py @ 15528:a84698badf0b
annotate: support diff whitespace filtering flags (issue3030)
splitblock() was added to handle blocks returned by bdiff.blocks() which differ
only by blank lines but are not made only of blank lines. I do not know exactly
how it could happen but mdiff.blocks() threshold behaviour makes me think it
can if those blocks are made of very popular lines mixed with popular blank
lines. If it is proven to be wrong, the function can be dropped.
The first implementation made annotate share diff configuration entries. But it
looks like users will user -w/b for annotate but not for diff, on both the
command line and hgweb. Since the latter cannot use command line entries, we
introduce a new [annotate] section duplicating the diff whitespace options.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Fri, 18 Nov 2011 12:04:31 +0100 |
parents | 646759147717 |
children | db0e277bdd37 |
line wrap: on
line diff
--- a/mercurial/commands.py Sun Nov 20 19:14:36 2011 +0100 +++ b/mercurial/commands.py Fri Nov 18 12:04:31 2011 +0100 @@ -106,15 +106,19 @@ ('', 'nodates', None, _('omit dates from diff headers')) ] -diffopts2 = [ - ('p', 'show-function', None, _('show which function each change is in')), - ('', 'reverse', None, _('produce a diff that undoes the changes')), +diffwsopts = [ ('w', 'ignore-all-space', None, _('ignore white space when comparing lines')), ('b', 'ignore-space-change', None, _('ignore changes in the amount of white space')), ('B', 'ignore-blank-lines', None, _('ignore changes whose lines are all blank')), + ] + +diffopts2 = [ + ('p', 'show-function', None, _('show which function each change is in')), + ('', 'reverse', None, _('produce a diff that undoes the changes')), + ] + diffwsopts + [ ('U', 'unified', '', _('number of lines of context to show'), _('NUM')), ('', 'stat', None, _('output diffstat-style summary of changes')), @@ -215,7 +219,7 @@ ('n', 'number', None, _('list the revision number (default)')), ('c', 'changeset', None, _('list the changeset')), ('l', 'line-number', None, _('show line number at the first appearance')) - ] + walkopts, + ] + diffwsopts + walkopts, _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...')) def annotate(ui, repo, *pats, **opts): """show changeset information by line for each file @@ -270,13 +274,15 @@ m = scmutil.match(ctx, pats, opts) m.bad = bad follow = not opts.get('no_follow') + diffopts = patch.diffopts(ui, opts, section='annotate') for abs in ctx.walk(m): fctx = ctx[abs] if not opts.get('text') and util.binary(fctx.data()): ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs)) continue - lines = fctx.annotate(follow=follow, linenumber=linenumber) + lines = fctx.annotate(follow=follow, linenumber=linenumber, + diffopts=diffopts) pieces = [] for f, sep in funcmap: