Show More
@@ -78,7 +78,8 b' def annotate(ui, repo, *pats, **opts):' | |||||
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')) | |
@@ -1028,6 +1029,7 b' def grep(ui, repo, pattern, *pats, **opt' | |||||
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) | |
@@ -1044,7 +1046,7 b' def grep(ui, repo, pattern, *pats, **opt' | |||||
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( |
|
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: | |
@@ -2742,8 +2744,8 b' table = {' | |||||
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, | |
@@ -2896,8 +2898,8 b' table = {' | |||||
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, _(' |
|
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": |
@@ -100,10 +100,6 b' def person(author):' | |||||
100 | if f == -1: return util.shortuser(author) |
|
100 | if f == -1: return util.shortuser(author) | |
101 | return author[:f].rstrip() |
|
101 | return author[:f].rstrip() | |
102 |
|
102 | |||
103 | def shortdate(date): |
|
|||
104 | '''turn (timestamp, tzoff) tuple into iso 8631 date.''' |
|
|||
105 | return util.datestr(date, format='%Y-%m-%d', timezone=False) |
|
|||
106 |
|
||||
107 | def indent(text, prefix): |
|
103 | def indent(text, prefix): | |
108 | '''indent each non-empty line of text after first with prefix.''' |
|
104 | '''indent each non-empty line of text after first with prefix.''' | |
109 | lines = text.splitlines() |
|
105 | lines = text.splitlines() | |
@@ -145,7 +141,7 b' filters = {' | |||||
145 | "rfc822date": lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S"), |
|
141 | "rfc822date": lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S"), | |
146 | "rfc3339date": lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S", True, "%+03d:%02d"), |
|
142 | "rfc3339date": lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S", True, "%+03d:%02d"), | |
147 | "short": lambda x: x[:12], |
|
143 | "short": lambda x: x[:12], | |
148 | "shortdate": shortdate, |
|
144 | "shortdate": util.shortdate, | |
149 | "stringify": templater.stringify, |
|
145 | "stringify": templater.stringify, | |
150 | "strip": lambda x: x.strip(), |
|
146 | "strip": lambda x: x.strip(), | |
151 | "urlescape": lambda x: urllib.quote(x), |
|
147 | "urlescape": lambda x: urllib.quote(x), |
@@ -1533,6 +1533,10 b" def datestr(date=None, format='%a %b %d " | |||||
1533 | s += timezone_format % (-tz / 3600, ((-tz % 3600) / 60)) |
|
1533 | s += timezone_format % (-tz / 3600, ((-tz % 3600) / 60)) | |
1534 | return s |
|
1534 | return s | |
1535 |
|
1535 | |||
|
1536 | def shortdate(date=None): | |||
|
1537 | """turn (timestamp, tzoff) tuple into iso 8631 date.""" | |||
|
1538 | return datestr(date, format='%Y-%m-%d', timezone=False) | |||
|
1539 | ||||
1536 | def strdate(string, format, defaults=[]): |
|
1540 | def strdate(string, format, defaults=[]): | |
1537 | """parse a localized time string and return a (unixtime, offset) tuple. |
|
1541 | """parse a localized time string and return a (unixtime, offset) tuple. | |
1538 | if the string cannot be parsed, ValueError is raised.""" |
|
1542 | if the string cannot be parsed, ValueError is raised.""" |
General Comments 0
You need to be logged in to leave comments.
Login now