# HG changeset patch # User Siddharth Agarwal # Date 1495679973 25200 # Node ID 1df80eff24cfbde6654149bd8aa969f246672405 # Parent 05abc47f3746df52c6c6f2f05b412a3805bb7845 annotate: add a new experimental --skip option to skip revs This option is most useful for mechanical code modifications, especially ones that retain the same number of lines. diff -r 05abc47f3746 -r 1df80eff24cf mercurial/commands.py --- a/mercurial/commands.py Wed May 24 19:07:14 2017 -0700 +++ b/mercurial/commands.py Wed May 24 19:39:33 2017 -0700 @@ -262,7 +262,8 @@ ('d', 'date', None, _('list the date (short with -q)')), ('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')) + ('l', 'line-number', None, _('show line number at the first appearance')), + ('', 'skip', [], _('revision to not display (EXPERIMENTAL)'), _('REV')), ] + diffwsopts + walkopts + formatteropts, _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'), inferrepo=True) @@ -368,6 +369,10 @@ follow = not opts.get('no_follow') diffopts = patch.difffeatureopts(ui, opts, section='annotate', whitespace=True) + skiprevs = opts.get('skip') + if skiprevs: + skiprevs = scmutil.revrange(repo, skiprevs) + for abs in ctx.walk(m): fctx = ctx[abs] if not opts.get('text') and fctx.isbinary(): @@ -375,7 +380,7 @@ continue lines = fctx.annotate(follow=follow, linenumber=linenumber, - diffopts=diffopts) + skiprevs=skiprevs, diffopts=diffopts) if not lines: continue formats = [] diff -r 05abc47f3746 -r 1df80eff24cf mercurial/context.py --- a/mercurial/context.py Wed May 24 19:07:14 2017 -0700 +++ b/mercurial/context.py Wed May 24 19:39:33 2017 -0700 @@ -949,7 +949,8 @@ return p[1] return filectx(self._repo, self._path, fileid=-1, filelog=self._filelog) - def annotate(self, follow=False, linenumber=False, diffopts=None): + def annotate(self, follow=False, linenumber=False, skiprevs=None, + diffopts=None): '''returns a list of tuples of ((ctx, number), line) for each line in the file, where ctx is the filectx of the node where that line was last changed; if linenumber parameter is true, number is @@ -1044,7 +1045,10 @@ if ready: visit.pop() curr = decorate(f.data(), f) - curr = _annotatepair([hist[p] for p in pl], f, curr, False, + skipchild = False + if skiprevs is not None: + skipchild = f._changeid in skiprevs + curr = _annotatepair([hist[p] for p in pl], f, curr, skipchild, diffopts) for p in pl: if needed[p] == 1: diff -r 05abc47f3746 -r 1df80eff24cf tests/test-annotate.t --- a/tests/test-annotate.t Wed May 24 19:07:14 2017 -0700 +++ b/tests/test-annotate.t Wed May 24 19:39:33 2017 -0700 @@ -217,6 +217,77 @@ 3 b:5: b5 7 b:7: d +--skip nothing (should be the same as no --skip at all) + + $ hg annotate -nlf b --skip '1::0' + 0 a:1: a + 6 b:2: z + 1 a:3: a + 3 b:4: b4 + 4 b:5: c + 3 b:5: b5 + 7 b:7: d + +--skip a modified line + + $ hg annotate -nlf b --skip 6 + 0 a:1: a + 1 a:2: z + 1 a:3: a + 3 b:4: b4 + 4 b:5: c + 3 b:5: b5 + 7 b:7: d + +--skip added lines (and test multiple skip) + + $ hg annotate -nlf b --skip 3 + 0 a:1: a + 6 b:2: z + 1 a:3: a + 1 a:3: b4 + 4 b:5: c + 1 a:3: b5 + 7 b:7: d + + $ hg annotate -nlf b --skip 4 + 0 a:1: a + 6 b:2: z + 1 a:3: a + 3 b:4: b4 + 1 a:3: c + 3 b:5: b5 + 7 b:7: d + + $ hg annotate -nlf b --skip 3 --skip 4 + 0 a:1: a + 6 b:2: z + 1 a:3: a + 1 a:3: b4 + 1 a:3: c + 1 a:3: b5 + 7 b:7: d + + $ hg annotate -nlf b --skip 'merge()' + 0 a:1: a + 6 b:2: z + 1 a:3: a + 3 b:4: b4 + 4 b:5: c + 3 b:5: b5 + 3 b:5: d + +--skip everything -- use the revision the file was introduced in + + $ hg annotate -nlf b --skip 'all()' + 0 a:1: a + 0 a:1: z + 0 a:1: a + 0 a:1: b4 + 0 a:1: c + 0 a:1: b5 + 0 a:1: d + Issue2807: alignment of line numbers with -l $ echo more >> b diff -r 05abc47f3746 -r 1df80eff24cf tests/test-completion.t --- a/tests/test-completion.t Wed May 24 19:07:14 2017 -0700 +++ b/tests/test-completion.t Wed May 24 19:39:33 2017 -0700 @@ -217,7 +217,7 @@ Show all commands + options $ hg debugcommands add: include, exclude, subrepos, dry-run - annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, ignore-all-space, ignore-space-change, ignore-blank-lines, include, exclude, template + annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, include, exclude, template clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd, insecure commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos diff: rev, change, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, root, include, exclude, subrepos