diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -78,7 +78,8 @@ def annotate(ui, repo, *pats, **opts): detects as binary. With -a, annotate will generate an annotation anyway, probably with undesirable results. """ - getdate = util.cachefunc(lambda x: util.datestr(x[0].date())) + datefunc = ui.quiet and util.shortdate or util.datestr + getdate = util.cachefunc(lambda x: datefunc(x[0].date())) if not pats: raise util.Abort(_('at least one file name or pattern required')) @@ -1028,6 +1029,7 @@ def grep(ui, repo, pattern, *pats, **opt prev = {} def display(fn, rev, states, prevstates): + datefunc = ui.quiet and util.shortdate or util.datestr found = False filerevmatches = {} r = prev.get(fn, -1) @@ -1044,7 +1046,7 @@ def grep(ui, repo, pattern, *pats, **opt if opts['user']: cols.append(ui.shortuser(get(r)[1])) if opts.get('date'): - cols.append(util.datestr(get(r)[2])) + cols.append(datefunc(get(r)[2])) if opts['files_with_matches']: c = (fn, r) if c in filerevmatches: @@ -2742,8 +2744,8 @@ table = { [('r', 'rev', '', _('annotate the specified revision')), ('f', 'follow', None, _('follow file copies and renames')), ('a', 'text', None, _('treat all files as text')), - ('u', 'user', None, _('list the author')), - ('d', 'date', None, _('list the date')), + ('u', 'user', None, _('list the author (long with -v)')), + ('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, @@ -2896,8 +2898,8 @@ table = { _('print only filenames and revs that match')), ('n', 'line-number', None, _('print matching line numbers')), ('r', 'rev', [], _('search in given revision range')), - ('u', 'user', None, _('print user who committed change')), - ('d', 'date', None, _('list the date')), + ('u', 'user', None, _('list the author (long with -v)')), + ('d', 'date', None, _('list the date (short with -q)')), ] + walkopts, _('hg grep [OPTION]... PATTERN [FILE]...')), "heads": diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py --- a/mercurial/templatefilters.py +++ b/mercurial/templatefilters.py @@ -100,10 +100,6 @@ def person(author): if f == -1: return util.shortuser(author) return author[:f].rstrip() -def shortdate(date): - '''turn (timestamp, tzoff) tuple into iso 8631 date.''' - return util.datestr(date, format='%Y-%m-%d', timezone=False) - def indent(text, prefix): '''indent each non-empty line of text after first with prefix.''' lines = text.splitlines() @@ -145,7 +141,7 @@ filters = { "rfc822date": lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S"), "rfc3339date": lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S", True, "%+03d:%02d"), "short": lambda x: x[:12], - "shortdate": shortdate, + "shortdate": util.shortdate, "stringify": templater.stringify, "strip": lambda x: x.strip(), "urlescape": lambda x: urllib.quote(x), diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -1533,6 +1533,10 @@ def datestr(date=None, format='%a %b %d s += timezone_format % (-tz / 3600, ((-tz % 3600) / 60)) return s +def shortdate(date=None): + """turn (timestamp, tzoff) tuple into iso 8631 date.""" + return datestr(date, format='%Y-%m-%d', timezone=False) + def strdate(string, format, defaults=[]): """parse a localized time string and return a (unixtime, offset) tuple. if the string cannot be parsed, ValueError is raised."""