comparison mercurial/commands.py @ 32519:1df80eff24cf

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.
author Siddharth Agarwal <sid0@fb.com>
date Wed, 24 May 2017 19:39:33 -0700
parents 579df5aaa425
children 37d70ba1d9d1
comparison
equal deleted inserted replaced
32518:05abc47f3746 32519:1df80eff24cf
260 ('u', 'user', None, _('list the author (long with -v)')), 260 ('u', 'user', None, _('list the author (long with -v)')),
261 ('f', 'file', None, _('list the filename')), 261 ('f', 'file', None, _('list the filename')),
262 ('d', 'date', None, _('list the date (short with -q)')), 262 ('d', 'date', None, _('list the date (short with -q)')),
263 ('n', 'number', None, _('list the revision number (default)')), 263 ('n', 'number', None, _('list the revision number (default)')),
264 ('c', 'changeset', None, _('list the changeset')), 264 ('c', 'changeset', None, _('list the changeset')),
265 ('l', 'line-number', None, _('show line number at the first appearance')) 265 ('l', 'line-number', None, _('show line number at the first appearance')),
266 ('', 'skip', [], _('revision to not display (EXPERIMENTAL)'), _('REV')),
266 ] + diffwsopts + walkopts + formatteropts, 267 ] + diffwsopts + walkopts + formatteropts,
267 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'), 268 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
268 inferrepo=True) 269 inferrepo=True)
269 def annotate(ui, repo, *pats, **opts): 270 def annotate(ui, repo, *pats, **opts):
270 """show changeset information by line for each file 271 """show changeset information by line for each file
366 m = scmutil.match(ctx, pats, opts, badfn=bad) 367 m = scmutil.match(ctx, pats, opts, badfn=bad)
367 368
368 follow = not opts.get('no_follow') 369 follow = not opts.get('no_follow')
369 diffopts = patch.difffeatureopts(ui, opts, section='annotate', 370 diffopts = patch.difffeatureopts(ui, opts, section='annotate',
370 whitespace=True) 371 whitespace=True)
372 skiprevs = opts.get('skip')
373 if skiprevs:
374 skiprevs = scmutil.revrange(repo, skiprevs)
375
371 for abs in ctx.walk(m): 376 for abs in ctx.walk(m):
372 fctx = ctx[abs] 377 fctx = ctx[abs]
373 if not opts.get('text') and fctx.isbinary(): 378 if not opts.get('text') and fctx.isbinary():
374 fm.plain(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs)) 379 fm.plain(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
375 continue 380 continue
376 381
377 lines = fctx.annotate(follow=follow, linenumber=linenumber, 382 lines = fctx.annotate(follow=follow, linenumber=linenumber,
378 diffopts=diffopts) 383 skiprevs=skiprevs, diffopts=diffopts)
379 if not lines: 384 if not lines:
380 continue 385 continue
381 formats = [] 386 formats = []
382 pieces = [] 387 pieces = []
383 388