Show More
@@ -5,8 +5,9 b'' | |||
|
5 | 5 | # This software may be used and distributed according to the terms |
|
6 | 6 | # of the GNU General Public License, incorporated herein by reference. |
|
7 | 7 | |
|
8 | import os, time | |
|
9 | 8 | from revlog import * |
|
9 | from demandload import demandload | |
|
10 | demandload(globals(), "os time util") | |
|
10 | 11 | |
|
11 | 12 | class changelog(revlog): |
|
12 | 13 | def __init__(self, opener): |
@@ -20,11 +21,15 b' class changelog(revlog):' | |||
|
20 | 21 | l = text[:last].splitlines() |
|
21 | 22 | manifest = bin(l[0]) |
|
22 | 23 | user = l[1] |
|
23 | date = l[2] | |
|
24 | if " " not in date: | |
|
25 | date += " 0" # some tools used -d without a timezone | |
|
24 | date = l[2].split(' ') | |
|
25 | time = int(date.pop(0)) | |
|
26 | try: | |
|
27 | # various tools did silly things with the time zone field. | |
|
28 | timezone = int(date[0]) | |
|
29 | except: | |
|
30 | timezone = 0 | |
|
26 | 31 | files = l[3:] |
|
27 |
return (manifest, user, |
|
|
32 | return (manifest, user, (time, timezone), files, desc) | |
|
28 | 33 | |
|
29 | 34 | def read(self, node): |
|
30 | 35 | return self.extract(self.revision(node)) |
@@ -44,9 +49,7 b' class changelog(revlog):' | |||
|
44 | 49 | if abs(offset) >= 43200: |
|
45 | 50 | raise ValueError('impossible time zone offset: %d' % offset) |
|
46 | 51 | else: |
|
47 | if time.daylight: offset = time.altzone | |
|
48 | else: offset = time.timezone | |
|
49 | date = "%d %d" % (time.time(), offset) | |
|
52 | date = "%d %d" % util.makedate() | |
|
50 | 53 | list.sort() |
|
51 | 54 | l = [hex(manifest), user, date] + list + ["", desc] |
|
52 | 55 | text = "\n".join(l) |
@@ -264,7 +264,7 b' def dodiff(fp, ui, repo, node1, node2, f' | |||
|
264 | 264 | if node2: |
|
265 | 265 | change = repo.changelog.read(node2) |
|
266 | 266 | mmap2 = repo.manifest.read(change[0]) |
|
267 | date2 = util.datestr(change) | |
|
267 | date2 = util.datestr(change[2]) | |
|
268 | 268 | def read(f): |
|
269 | 269 | return repo.file(f).read(mmap2[f]) |
|
270 | 270 | else: |
@@ -282,7 +282,7 b' def dodiff(fp, ui, repo, node1, node2, f' | |||
|
282 | 282 | |
|
283 | 283 | change = repo.changelog.read(node1) |
|
284 | 284 | mmap = repo.manifest.read(change[0]) |
|
285 | date1 = util.datestr(change) | |
|
285 | date1 = util.datestr(change[2]) | |
|
286 | 286 | |
|
287 | 287 | for f in c: |
|
288 | 288 | to = None |
@@ -319,7 +319,7 b' def show_changeset(ui, repo, rev=0, chan' | |||
|
319 | 319 | return |
|
320 | 320 | |
|
321 | 321 | changes = log.read(changenode) |
|
322 | date = util.datestr(changes) | |
|
322 | date = util.datestr(changes[2]) | |
|
323 | 323 | |
|
324 | 324 | parents = [(log.rev(p), ui.verbose and hex(p) or short(p)) |
|
325 | 325 | for p in log.parents(changenode) |
@@ -27,7 +27,7 b' def age(x):' | |||
|
27 | 27 | return "%d %s" % (c, plural(t, c)) |
|
28 | 28 | |
|
29 | 29 | now = time.time() |
|
30 |
then = |
|
|
30 | then = x[2][0] | |
|
31 | 31 | delta = max(1, int(now - then)) |
|
32 | 32 | |
|
33 | 33 | scales = [["second", 1], |
@@ -155,13 +155,13 b' class templater:' | |||
|
155 | 155 | common_filters = { |
|
156 | 156 | "escape": cgi.escape, |
|
157 | 157 | "age": age, |
|
158 | "date": util.datestr, | |
|
158 | "date": lambda x: util.datestr(x[2]), | |
|
159 | 159 | "addbreaks": nl2br, |
|
160 | 160 | "obfuscate": obfuscate, |
|
161 | 161 | "short": (lambda x: x[:12]), |
|
162 | 162 | "firstline": (lambda x: x.splitlines(1)[0]), |
|
163 | 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 | 167 | class hgweb: |
@@ -185,7 +185,7 b' class hgweb:' | |||
|
185 | 185 | self.allowpull = self.repo.ui.configbool("web", "allowpull", True) |
|
186 | 186 | |
|
187 | 187 | def date(self, cs): |
|
188 | return util.datestr(cs) | |
|
188 | return util.datestr(cs[2]) | |
|
189 | 189 | |
|
190 | 190 | def listfiles(self, files, mf): |
|
191 | 191 | for f in files[:self.maxfiles]: |
@@ -544,21 +544,17 b' def filechunkiter(f, size = 65536):' | |||
|
544 | 544 | yield s |
|
545 | 545 | s = f.read(size) |
|
546 | 546 | |
|
547 | def datestr(change=None, format='%c'): | |
|
548 | """represent a change date as a localized time. | |
|
549 | a change date is a 'unixtime offset' string, where unixtime is | |
|
550 | seconds since the epoch, and offset is seconds away from UTC.""" | |
|
551 | if change is None: | |
|
547 | def makedate(): | |
|
552 | 548 |
|
|
553 | 549 |
|
|
554 | 550 |
|
|
555 | else: | |
|
556 | t, tz = change[2].split(' ') | |
|
557 | try: | |
|
558 | # a conversion tool was sticking non-integer offsets into repos | |
|
559 | tz = int(tz) | |
|
560 | except ValueError: | |
|
561 | tz = 0 | |
|
551 | return t, tz | |
|
552 | ||
|
553 | def datestr(date=None, format='%c'): | |
|
554 | """represent a (unixtime, offset) tuple as a localized time. | |
|
555 | unixtime is seconds since the epoch, and offset is the time zone's | |
|
556 | number of seconds away from UTC.""" | |
|
557 | t, tz = date or makedate() | |
|
562 | 558 | return ("%s %+03d%02d" % |
|
563 | 559 | (time.strftime(format, time.gmtime(float(t) - tz)), |
|
564 | 560 | -tz / 3600, |
General Comments 0
You need to be logged in to leave comments.
Login now