Commit 5819eeb8 authored by Siddharth Agarwal's avatar Siddharth Agarwal
Browse files

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.
parent 05abc47f3746
......@@ -262,7 +262,8 @@ def addremove(ui, repo, *pats, **opts):
('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 @@ def annotate(ui, repo, *pats, **opts):
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 @@ def annotate(ui, repo, *pats, **opts):
continue
lines = fctx.annotate(follow=follow, linenumber=linenumber,
diffopts=diffopts)
skiprevs=skiprevs, diffopts=diffopts)
if not lines:
continue
formats = []
......
......@@ -949,7 +949,8 @@ class basefilectx(object):
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 @@ class basefilectx(object):
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:
......
......@@ -217,6 +217,77 @@ annotate after rename merge with -l
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
......
......@@ -217,7 +217,7 @@ Show an error if we use --options with an ambiguous abbreviation
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment