comparison mercurial/commands.py @ 6134:7b937b26adf7

Make annotae/grep print short dates with -q/--quiet. Move shortdate() from templatefilters to util to avoid code duplication.
author Thomas Arendsen Hein <thomas@intevation.de>
date Sat, 16 Feb 2008 13:33:38 +0100
parents 779f2309d67a
children 989467e8e3a9
comparison
equal deleted inserted replaced
6133:779f2309d67a 6134:7b937b26adf7
76 76
77 Without the -a option, annotate will avoid processing files it 77 Without the -a option, annotate will avoid processing files it
78 detects as binary. With -a, annotate will generate an annotation 78 detects as binary. With -a, annotate will generate an annotation
79 anyway, probably with undesirable results. 79 anyway, probably with undesirable results.
80 """ 80 """
81 getdate = util.cachefunc(lambda x: util.datestr(x[0].date())) 81 datefunc = ui.quiet and util.shortdate or util.datestr
82 getdate = util.cachefunc(lambda x: datefunc(x[0].date()))
82 83
83 if not pats: 84 if not pats:
84 raise util.Abort(_('at least one file name or pattern required')) 85 raise util.Abort(_('at least one file name or pattern required'))
85 86
86 opmap = [('user', lambda x: ui.shortuser(x[0].user())), 87 opmap = [('user', lambda x: ui.shortuser(x[0].user())),
1026 for i in xrange(blo, bhi): 1027 for i in xrange(blo, bhi):
1027 yield ('+', b[i]) 1028 yield ('+', b[i])
1028 1029
1029 prev = {} 1030 prev = {}
1030 def display(fn, rev, states, prevstates): 1031 def display(fn, rev, states, prevstates):
1032 datefunc = ui.quiet and util.shortdate or util.datestr
1031 found = False 1033 found = False
1032 filerevmatches = {} 1034 filerevmatches = {}
1033 r = prev.get(fn, -1) 1035 r = prev.get(fn, -1)
1034 if opts['all']: 1036 if opts['all']:
1035 iter = difflinestates(states, prevstates) 1037 iter = difflinestates(states, prevstates)
1042 if opts['all']: 1044 if opts['all']:
1043 cols.append(change) 1045 cols.append(change)
1044 if opts['user']: 1046 if opts['user']:
1045 cols.append(ui.shortuser(get(r)[1])) 1047 cols.append(ui.shortuser(get(r)[1]))
1046 if opts.get('date'): 1048 if opts.get('date'):
1047 cols.append(util.datestr(get(r)[2])) 1049 cols.append(datefunc(get(r)[2]))
1048 if opts['files_with_matches']: 1050 if opts['files_with_matches']:
1049 c = (fn, r) 1051 c = (fn, r)
1050 if c in filerevmatches: 1052 if c in filerevmatches:
1051 continue 1053 continue
1052 filerevmatches[c] = 1 1054 filerevmatches[c] = 1
2740 "^annotate": 2742 "^annotate":
2741 (annotate, 2743 (annotate,
2742 [('r', 'rev', '', _('annotate the specified revision')), 2744 [('r', 'rev', '', _('annotate the specified revision')),
2743 ('f', 'follow', None, _('follow file copies and renames')), 2745 ('f', 'follow', None, _('follow file copies and renames')),
2744 ('a', 'text', None, _('treat all files as text')), 2746 ('a', 'text', None, _('treat all files as text')),
2745 ('u', 'user', None, _('list the author')), 2747 ('u', 'user', None, _('list the author (long with -v)')),
2746 ('d', 'date', None, _('list the date')), 2748 ('d', 'date', None, _('list the date (short with -q)')),
2747 ('n', 'number', None, _('list the revision number (default)')), 2749 ('n', 'number', None, _('list the revision number (default)')),
2748 ('c', 'changeset', None, _('list the changeset')), 2750 ('c', 'changeset', None, _('list the changeset')),
2749 ('l', 'line-number', None, 2751 ('l', 'line-number', None,
2750 _('show line number at the first appearance')) 2752 _('show line number at the first appearance'))
2751 ] + walkopts, 2753 ] + walkopts,
2894 ('i', 'ignore-case', None, _('ignore case when matching')), 2896 ('i', 'ignore-case', None, _('ignore case when matching')),
2895 ('l', 'files-with-matches', None, 2897 ('l', 'files-with-matches', None,
2896 _('print only filenames and revs that match')), 2898 _('print only filenames and revs that match')),
2897 ('n', 'line-number', None, _('print matching line numbers')), 2899 ('n', 'line-number', None, _('print matching line numbers')),
2898 ('r', 'rev', [], _('search in given revision range')), 2900 ('r', 'rev', [], _('search in given revision range')),
2899 ('u', 'user', None, _('print user who committed change')), 2901 ('u', 'user', None, _('list the author (long with -v)')),
2900 ('d', 'date', None, _('list the date')), 2902 ('d', 'date', None, _('list the date (short with -q)')),
2901 ] + walkopts, 2903 ] + walkopts,
2902 _('hg grep [OPTION]... PATTERN [FILE]...')), 2904 _('hg grep [OPTION]... PATTERN [FILE]...')),
2903 "heads": 2905 "heads":
2904 (heads, 2906 (heads,
2905 [('', 'style', '', _('display using template map file')), 2907 [('', 'style', '', _('display using template map file')),