Mercurial > hg
comparison mercurial/templatefilters.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 | 9f1e6ab76069 |
children | 434139080ed4 |
comparison
equal
deleted
inserted
replaced
6133:779f2309d67a | 6134:7b937b26adf7 |
---|---|
98 '''get name of author, or else username.''' | 98 '''get name of author, or else username.''' |
99 f = author.find('<') | 99 f = author.find('<') |
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() |
110 num_lines = len(lines) | 106 num_lines = len(lines) |
111 def indenter(): | 107 def indenter(): |
143 "permissions": permissions, | 139 "permissions": permissions, |
144 "person": person, | 140 "person": person, |
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), |
152 "user": lambda x: util.shortuser(x), | 148 "user": lambda x: util.shortuser(x), |
153 "stringescape": lambda x: x.encode('string_escape'), | 149 "stringescape": lambda x: x.encode('string_escape'), |