Mercurial > hg > mercurial-crew
comparison mercurial/hgweb.py @ 1321:b47f96a178a3
Clean up date and timezone handling.
We used to pass changelog dates around as a "unixtime timezone" string
containing a pair of encoded ints. Now, they get passed around as a
(unixtime, timezone) tuple of numbers, which makes much more sense.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Thu, 22 Sep 2005 23:19:47 -0700 |
parents | 5f277e73778f |
children | 77cd8068dbf4 |
comparison
equal
deleted
inserted
replaced
1320:5f277e73778f | 1321:b47f96a178a3 |
---|---|
25 return t + "s" | 25 return t + "s" |
26 def fmt(t, c): | 26 def fmt(t, c): |
27 return "%d %s" % (c, plural(t, c)) | 27 return "%d %s" % (c, plural(t, c)) |
28 | 28 |
29 now = time.time() | 29 now = time.time() |
30 then = int(x[2].split(' ')[0]) | 30 then = x[2][0] |
31 delta = max(1, int(now - then)) | 31 delta = max(1, int(now - then)) |
32 | 32 |
33 scales = [["second", 1], | 33 scales = [["second", 1], |
34 ["minute", 60], | 34 ["minute", 60], |
35 ["hour", 3600], | 35 ["hour", 3600], |
153 return | 153 return |
154 | 154 |
155 common_filters = { | 155 common_filters = { |
156 "escape": cgi.escape, | 156 "escape": cgi.escape, |
157 "age": age, | 157 "age": age, |
158 "date": util.datestr, | 158 "date": lambda x: util.datestr(x[2]), |
159 "addbreaks": nl2br, | 159 "addbreaks": nl2br, |
160 "obfuscate": obfuscate, | 160 "obfuscate": obfuscate, |
161 "short": (lambda x: x[:12]), | 161 "short": (lambda x: x[:12]), |
162 "firstline": (lambda x: x.splitlines(1)[0]), | 162 "firstline": (lambda x: x.splitlines(1)[0]), |
163 "permissions": (lambda x: x and "-rwxr-xr-x" or "-rw-r--r--"), | 163 "permissions": (lambda x: x and "-rwxr-xr-x" or "-rw-r--r--"), |
164 "rfc822date": lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S"), | 164 "rfc822date": lambda x: util.datestr(x[2], "%a, %d %b %Y %H:%M:%S"), |
165 } | 165 } |
166 | 166 |
167 class hgweb: | 167 class hgweb: |
168 def __init__(self, repo, name=None): | 168 def __init__(self, repo, name=None): |
169 if type(repo) == type(""): | 169 if type(repo) == type(""): |
183 self.maxchanges = int(self.repo.ui.config("web", "maxchanges", 10)) | 183 self.maxchanges = int(self.repo.ui.config("web", "maxchanges", 10)) |
184 self.maxfiles = int(self.repo.ui.config("web", "maxfiles", 10)) | 184 self.maxfiles = int(self.repo.ui.config("web", "maxfiles", 10)) |
185 self.allowpull = self.repo.ui.configbool("web", "allowpull", True) | 185 self.allowpull = self.repo.ui.configbool("web", "allowpull", True) |
186 | 186 |
187 def date(self, cs): | 187 def date(self, cs): |
188 return util.datestr(cs) | 188 return util.datestr(cs[2]) |
189 | 189 |
190 def listfiles(self, files, mf): | 190 def listfiles(self, files, mf): |
191 for f in files[:self.maxfiles]: | 191 for f in files[:self.maxfiles]: |
192 yield self.t("filenodelink", node=hex(mf[f]), file=f) | 192 yield self.t("filenodelink", node=hex(mf[f]), file=f) |
193 if len(files) > self.maxfiles: | 193 if len(files) > self.maxfiles: |