comparison mercurial/commands.py @ 10369:98a0421b9e52

commands: annotate follows by default, separate -f/--file option
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Sun, 07 Feb 2010 14:51:52 +0100
parents d757bc0c7865
children adf9505e8888
comparison
equal deleted inserted replaced
10368:f05e0d54f424 10369:98a0421b9e52
93 93
94 opmap = [('user', lambda x: ui.shortuser(x[0].user())), 94 opmap = [('user', lambda x: ui.shortuser(x[0].user())),
95 ('number', lambda x: str(x[0].rev())), 95 ('number', lambda x: str(x[0].rev())),
96 ('changeset', lambda x: short(x[0].node())), 96 ('changeset', lambda x: short(x[0].node())),
97 ('date', getdate), 97 ('date', getdate),
98 ('follow', lambda x: x[0].path()), 98 ('file', lambda x: x[0].path()),
99 ] 99 ]
100 100
101 if (not opts.get('user') and not opts.get('changeset') 101 if (not opts.get('user') and not opts.get('changeset')
102 and not opts.get('date') and not opts.get('follow')): 102 and not opts.get('date') and not opts.get('file')):
103 opts['number'] = 1 103 opts['number'] = 1
104 104
105 linenumber = opts.get('line_number') is not None 105 linenumber = opts.get('line_number') is not None
106 if (linenumber and (not opts.get('changeset')) and (not opts.get('number'))): 106 if (linenumber and (not opts.get('changeset')) and (not opts.get('number'))):
107 raise util.Abort(_('at least one of -n/-c is required for -l')) 107 raise util.Abort(_('at least one of -n/-c is required for -l'))
110 if linenumber: 110 if linenumber:
111 lastfunc = funcmap[-1] 111 lastfunc = funcmap[-1]
112 funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1]) 112 funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1])
113 113
114 ctx = repo[opts.get('rev')] 114 ctx = repo[opts.get('rev')]
115
116 m = cmdutil.match(repo, pats, opts) 115 m = cmdutil.match(repo, pats, opts)
116 follow = not opts.get('no_follow')
117 for abs in ctx.walk(m): 117 for abs in ctx.walk(m):
118 fctx = ctx[abs] 118 fctx = ctx[abs]
119 if not opts.get('text') and util.binary(fctx.data()): 119 if not opts.get('text') and util.binary(fctx.data()):
120 ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs)) 120 ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
121 continue 121 continue
122 122
123 lines = fctx.annotate(follow=opts.get('follow'), 123 lines = fctx.annotate(follow=follow, linenumber=linenumber)
124 linenumber=linenumber)
125 pieces = [] 124 pieces = []
126 125
127 for f in funcmap: 126 for f in funcmap:
128 l = [f(n) for n, dummy in lines] 127 l = [f(n) for n, dummy in lines]
129 if l: 128 if l:
3358 (addremove, similarityopts + walkopts + dryrunopts, 3357 (addremove, similarityopts + walkopts + dryrunopts,
3359 _('[OPTION]... [FILE]...')), 3358 _('[OPTION]... [FILE]...')),
3360 "^annotate|blame": 3359 "^annotate|blame":
3361 (annotate, 3360 (annotate,
3362 [('r', 'rev', '', _('annotate the specified revision')), 3361 [('r', 'rev', '', _('annotate the specified revision')),
3363 ('f', 'follow', None, _('follow file copies and renames')), 3362 ('', 'follow', None, _('follow copies and renames (DEPRECATED)')),
3363 ('', 'no-follow', None, _("don't follow copies and renames")),
3364 ('a', 'text', None, _('treat all files as text')), 3364 ('a', 'text', None, _('treat all files as text')),
3365 ('u', 'user', None, _('list the author (long with -v)')), 3365 ('u', 'user', None, _('list the author (long with -v)')),
3366 ('f', 'file', None, _('list the filename')),
3366 ('d', 'date', None, _('list the date (short with -q)')), 3367 ('d', 'date', None, _('list the date (short with -q)')),
3367 ('n', 'number', None, _('list the revision number (default)')), 3368 ('n', 'number', None, _('list the revision number (default)')),
3368 ('c', 'changeset', None, _('list the changeset')), 3369 ('c', 'changeset', None, _('list the changeset')),
3369 ('l', 'line-number', None, 3370 ('l', 'line-number', None,
3370 _('show line number at the first appearance')) 3371 _('show line number at the first appearance'))