273 # --follow is deprecated and now just an alias for -f/--file |
273 # --follow is deprecated and now just an alias for -f/--file |
274 # to mimic the behavior of Mercurial before version 1.5 |
274 # to mimic the behavior of Mercurial before version 1.5 |
275 opts['file'] = True |
275 opts['file'] = True |
276 |
276 |
277 datefunc = ui.quiet and util.shortdate or util.datestr |
277 datefunc = ui.quiet and util.shortdate or util.datestr |
278 getdate = util.cachefunc(lambda x: datefunc(x[0].date())) |
|
279 hexfn = ui.debugflag and hex or short |
278 hexfn = ui.debugflag and hex or short |
280 |
279 |
281 opmap = [('user', ' ', lambda x: ui.shortuser(x[0].user())), |
280 opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser), |
282 ('number', ' ', lambda x: str(x[0].rev())), |
281 ('number', ' ', lambda x: x[0].rev(), str), |
283 ('changeset', ' ', lambda x: hexfn(x[0].node())), |
282 ('changeset', ' ', lambda x: hexfn(x[0].node()), str), |
284 ('date', ' ', getdate), |
283 ('date', ' ', lambda x: x[0].date(), util.cachefunc(datefunc)), |
285 ('file', ' ', lambda x: x[0].path()), |
284 ('file', ' ', lambda x: x[0].path(), str), |
286 ('line_number', ':', lambda x: str(x[1])), |
285 ('line_number', ':', lambda x: x[1], str), |
287 ] |
286 ] |
288 |
287 |
289 if (not opts.get('user') and not opts.get('changeset') |
288 if (not opts.get('user') and not opts.get('changeset') |
290 and not opts.get('date') and not opts.get('file')): |
289 and not opts.get('date') and not opts.get('file')): |
291 opts['number'] = True |
290 opts['number'] = True |
292 |
291 |
293 linenumber = opts.get('line_number') is not None |
292 linenumber = opts.get('line_number') is not None |
294 if linenumber and (not opts.get('changeset')) and (not opts.get('number')): |
293 if linenumber and (not opts.get('changeset')) and (not opts.get('number')): |
295 raise util.Abort(_('at least one of -n/-c is required for -l')) |
294 raise util.Abort(_('at least one of -n/-c is required for -l')) |
296 |
295 |
297 funcmap = [(func, sep) for op, sep, func in opmap if opts.get(op)] |
296 def makefunc(get, fmt): |
|
297 return lambda x: fmt(get(x)) |
|
298 funcmap = [(makefunc(get, fmt), sep) for op, sep, get, fmt in opmap |
|
299 if opts.get(op)] |
298 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column |
300 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column |
299 |
301 |
300 def bad(x, y): |
302 def bad(x, y): |
301 raise util.Abort("%s: %s" % (x, y)) |
303 raise util.Abort("%s: %s" % (x, y)) |
302 |
304 |