Show More
@@ -30,20 +30,6 b' def relpath(repo, args):' | |||
|
30 | 30 | return [util.normpath(os.path.join(cwd, x)) for x in args] |
|
31 | 31 | return args |
|
32 | 32 | |
|
33 | def datestr(change=None): | |
|
34 | if change is None: | |
|
35 | t = time.time() | |
|
36 | if time.daylight: tz = time.altzone | |
|
37 | else: tz = time.timezone | |
|
38 | else: | |
|
39 | t, tz = change[2].split(' ') | |
|
40 | try: | |
|
41 | # a conversion tool was sticking non-integer offsets into repos | |
|
42 | tz = int(tz) | |
|
43 | except ValueError: | |
|
44 | tz = 0 | |
|
45 | return time.asctime(time.gmtime(float(t) - tz)) + " %+05d" % (int(tz)/-36) | |
|
46 | ||
|
47 | 33 | def matchpats(repo, cwd, pats=[], opts={}, head=''): |
|
48 | 34 | return util.matcher(repo.root, cwd, pats or ['.'], opts.get('include'), |
|
49 | 35 | opts.get('exclude'), head) |
@@ -278,11 +264,11 b' def dodiff(fp, ui, repo, node1, node2, f' | |||
|
278 | 264 | if node2: |
|
279 | 265 | change = repo.changelog.read(node2) |
|
280 | 266 | mmap2 = repo.manifest.read(change[0]) |
|
281 | date2 = datestr(change) | |
|
267 | date2 = util.datestr(change) | |
|
282 | 268 | def read(f): |
|
283 | 269 | return repo.file(f).read(mmap2[f]) |
|
284 | 270 | else: |
|
285 | date2 = datestr() | |
|
271 | date2 = util.datestr() | |
|
286 | 272 | if not node1: |
|
287 | 273 | node1 = repo.dirstate.parents()[0] |
|
288 | 274 | def read(f): |
@@ -296,7 +282,7 b' def dodiff(fp, ui, repo, node1, node2, f' | |||
|
296 | 282 | |
|
297 | 283 | change = repo.changelog.read(node1) |
|
298 | 284 | mmap = repo.manifest.read(change[0]) |
|
299 | date1 = datestr(change) | |
|
285 | date1 = util.datestr(change) | |
|
300 | 286 | |
|
301 | 287 | for f in c: |
|
302 | 288 | to = None |
@@ -333,7 +319,7 b' def show_changeset(ui, repo, rev=0, chan' | |||
|
333 | 319 | return |
|
334 | 320 | |
|
335 | 321 | changes = log.read(changenode) |
|
336 | date = datestr(changes) | |
|
322 | date = util.datestr(changes) | |
|
337 | 323 | |
|
338 | 324 | parents = [(log.rev(p), ui.verbose and hex(p) or short(p)) |
|
339 | 325 | for p in log.parents(changenode) |
@@ -9,7 +9,7 b'' | |||
|
9 | 9 | import os, cgi, sys |
|
10 | 10 | from demandload import demandload |
|
11 | 11 | demandload(globals(), "mdiff time re socket zlib errno ui hg ConfigParser") |
|
12 | demandload(globals(), "zipfile tempfile StringIO tarfile BaseHTTPServer") | |
|
12 | demandload(globals(), "zipfile tempfile StringIO tarfile BaseHTTPServer util") | |
|
13 | 13 | from node import * |
|
14 | 14 | |
|
15 | 15 | def templatepath(): |
@@ -18,7 +18,7 b' def templatepath():' | |||
|
18 | 18 | if os.path.isdir(p): |
|
19 | 19 | return p |
|
20 | 20 | |
|
21 |
def age( |
|
|
21 | def age(x): | |
|
22 | 22 | def plural(t, c): |
|
23 | 23 | if c == 1: |
|
24 | 24 | return t |
@@ -27,7 +27,8 b' def age(t):' | |||
|
27 | 27 | return "%d %s" % (c, plural(t, c)) |
|
28 | 28 | |
|
29 | 29 | now = time.time() |
|
30 | delta = max(1, int(now - t)) | |
|
30 | then = int(x[2].split(' ')[0]) | |
|
31 | delta = max(1, int(now - then)) | |
|
31 | 32 | |
|
32 | 33 | scales = [["second", 1], |
|
33 | 34 | ["minute", 60], |
@@ -151,23 +152,18 b' class templater:' | |||
|
151 | 152 | yield tmpl |
|
152 | 153 | return |
|
153 | 154 | |
|
154 | def rfc822date(x): | |
|
155 | return time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime(x)) | |
|
156 | ||
|
157 | 155 | common_filters = { |
|
158 | 156 | "escape": cgi.escape, |
|
159 | 157 | "age": age, |
|
160 | "date": (lambda x: time.asctime(time.gmtime(x))), | |
|
158 | "date": util.datestr, | |
|
161 | 159 | "addbreaks": nl2br, |
|
162 | 160 | "obfuscate": obfuscate, |
|
163 | 161 | "short": (lambda x: x[:12]), |
|
164 | 162 | "firstline": (lambda x: x.splitlines(1)[0]), |
|
165 | 163 | "permissions": (lambda x: x and "-rwxr-xr-x" or "-rw-r--r--"), |
|
166 | "rfc822date": rfc822date, | |
|
164 | "rfc822date": lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S"), | |
|
167 | 165 | } |
|
168 | 166 | |
|
169 | ||
|
170 | ||
|
171 | 167 | class hgweb: |
|
172 | 168 | def __init__(self, repo, name=None): |
|
173 | 169 | if type(repo) == type(""): |
@@ -189,7 +185,7 b' class hgweb:' | |||
|
189 | 185 | self.allowpull = self.repo.ui.configbool("web", "allowpull", True) |
|
190 | 186 | |
|
191 | 187 | def date(self, cs): |
|
192 | return time.asctime(time.gmtime(float(cs[2].split(' ')[0]))) | |
|
188 | return util.datestr(cs) | |
|
193 | 189 | |
|
194 | 190 | def listfiles(self, files, mf): |
|
195 | 191 | for f in files[:self.maxfiles]: |
@@ -307,7 +303,6 b' class hgweb:' | |||
|
307 | 303 | n = cl.node(i) |
|
308 | 304 | changes = cl.read(n) |
|
309 | 305 | hn = hex(n) |
|
310 | t = float(changes[2].split(' ')[0]) | |
|
311 | 306 | |
|
312 | 307 | l.insert(0, {"parity": parity, |
|
313 | 308 | "author": changes[1], |
@@ -316,7 +311,7 b' class hgweb:' | |||
|
316 | 311 | "changelogtag": self.showtag("changelogtag",n), |
|
317 | 312 | "manifest": hex(changes[0]), |
|
318 | 313 | "desc": changes[4], |
|
319 |
"date": |
|
|
314 | "date": changes, | |
|
320 | 315 | "files": self.listfilediffs(changes[3], n), |
|
321 | 316 | "rev": i, |
|
322 | 317 | "node": hn}) |
@@ -368,7 +363,6 b' class hgweb:' | |||
|
368 | 363 | |
|
369 | 364 | count += 1 |
|
370 | 365 | hn = hex(n) |
|
371 | t = float(changes[2].split(' ')[0]) | |
|
372 | 366 | |
|
373 | 367 | yield self.t('searchentry', |
|
374 | 368 | parity=count & 1, |
@@ -378,7 +372,7 b' class hgweb:' | |||
|
378 | 372 | changelogtag=self.showtag("changelogtag",n), |
|
379 | 373 | manifest=hex(changes[0]), |
|
380 | 374 | desc=changes[4], |
|
381 |
date= |
|
|
375 | date=changes, | |
|
382 | 376 | files=self.listfilediffs(changes[3], n), |
|
383 | 377 | rev=i, |
|
384 | 378 | node=hn) |
@@ -399,7 +393,6 b' class hgweb:' | |||
|
399 | 393 | cl = self.repo.changelog |
|
400 | 394 | changes = cl.read(n) |
|
401 | 395 | p1 = cl.parents(n)[0] |
|
402 | t = float(changes[2].split(' ')[0]) | |
|
403 | 396 | |
|
404 | 397 | files = [] |
|
405 | 398 | mf = self.repo.manifest.read(changes[0]) |
@@ -425,7 +418,7 b' class hgweb:' | |||
|
425 | 418 | manifest=hex(changes[0]), |
|
426 | 419 | author=changes[1], |
|
427 | 420 | desc=changes[4], |
|
428 |
date= |
|
|
421 | date=changes, | |
|
429 | 422 | files=files, |
|
430 | 423 | archives=archivelist()) |
|
431 | 424 | |
@@ -443,7 +436,6 b' class hgweb:' | |||
|
443 | 436 | lr = fl.linkrev(n) |
|
444 | 437 | cn = cl.node(lr) |
|
445 | 438 | cs = cl.read(cl.node(lr)) |
|
446 | t = float(cs[2].split(' ')[0]) | |
|
447 | 439 | |
|
448 | 440 | l.insert(0, {"parity": parity, |
|
449 | 441 | "filenode": hex(n), |
@@ -451,7 +443,7 b' class hgweb:' | |||
|
451 | 443 | "file": f, |
|
452 | 444 | "node": hex(cn), |
|
453 | 445 | "author": cs[1], |
|
454 |
"date": |
|
|
446 | "date": cs, | |
|
455 | 447 | "parent": self.parents("filelogparent", |
|
456 | 448 | fl.parents(n), |
|
457 | 449 | fl.rev, file=f), |
@@ -471,7 +463,6 b' class hgweb:' | |||
|
471 | 463 | cl = self.repo.changelog |
|
472 | 464 | cn = cl.node(changerev) |
|
473 | 465 | cs = cl.read(cn) |
|
474 | t = float(cs[2].split(' ')[0]) | |
|
475 | 466 | mfn = cs[0] |
|
476 | 467 | |
|
477 | 468 | def lines(): |
@@ -489,7 +480,7 b' class hgweb:' | |||
|
489 | 480 | node=hex(cn), |
|
490 | 481 | manifest=hex(mfn), |
|
491 | 482 | author=cs[1], |
|
492 |
date= |
|
|
483 | date=cs, | |
|
493 | 484 | parent=self.parents("filerevparent", |
|
494 | 485 | fl.parents(n), fl.rev, file=f), |
|
495 | 486 | permissions=self.repo.manifest.readflags(mfn)[f]) |
@@ -504,7 +495,6 b' class hgweb:' | |||
|
504 | 495 | cl = self.repo.changelog |
|
505 | 496 | cn = cl.node(changerev) |
|
506 | 497 | cs = cl.read(cn) |
|
507 | t = float(cs[2].split(' ')[0]) | |
|
508 | 498 | mfn = cs[0] |
|
509 | 499 | |
|
510 | 500 | def annotate(**map): |
@@ -542,7 +532,7 b' class hgweb:' | |||
|
542 | 532 | node=hex(cn), |
|
543 | 533 | manifest=hex(mfn), |
|
544 | 534 | author=cs[1], |
|
545 |
date= |
|
|
535 | date=cs, | |
|
546 | 536 | parent=self.parents("fileannotateparent", |
|
547 | 537 | fl.parents(n), fl.rev, file=f), |
|
548 | 538 | permissions=self.repo.manifest.readflags(mfn)[f]) |
@@ -12,7 +12,7 b' platform-specific details from the core.' | |||
|
12 | 12 | |
|
13 | 13 | import os, errno |
|
14 | 14 | from demandload import * |
|
15 | demandload(globals(), "re cStringIO shutil popen2 tempfile threading") | |
|
15 | demandload(globals(), "re cStringIO shutil popen2 tempfile threading time") | |
|
16 | 16 | |
|
17 | 17 | def pipefilter(s, cmd): |
|
18 | 18 | '''filter string S through command CMD, returning its output''' |
@@ -543,3 +543,23 b' def filechunkiter(f, size = 65536):' | |||
|
543 | 543 | while len(s) >= 0: |
|
544 | 544 | yield s |
|
545 | 545 | s = f.read(size) |
|
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: | |
|
552 | t = time.time() | |
|
553 | if time.daylight: tz = time.altzone | |
|
554 | else: tz = time.timezone | |
|
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 | |
|
562 | return ("%s %+03d%02d" % | |
|
563 | (time.strftime(format, time.gmtime(float(t) - tz)), | |
|
564 | -tz / 3600, | |
|
565 | ((-tz % 3600) / 60))) |
General Comments 0
You need to be logged in to leave comments.
Login now