Mercurial > hg
comparison mercurial/commands.py @ 1320:5f277e73778f
Fix up representation of dates in hgweb.
Date display is now uniform both on the command line and via the web
interface.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Thu, 22 Sep 2005 22:46:50 -0700 |
parents | 5a15df632e6a |
children | b47f96a178a3 |
comparison
equal
deleted
inserted
replaced
1319:5a15df632e6a | 1320:5f277e73778f |
---|---|
27 def relpath(repo, args): | 27 def relpath(repo, args): |
28 cwd = repo.getcwd() | 28 cwd = repo.getcwd() |
29 if cwd: | 29 if cwd: |
30 return [util.normpath(os.path.join(cwd, x)) for x in args] | 30 return [util.normpath(os.path.join(cwd, x)) for x in args] |
31 return args | 31 return args |
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 | 32 |
47 def matchpats(repo, cwd, pats=[], opts={}, head=''): | 33 def matchpats(repo, cwd, pats=[], opts={}, head=''): |
48 return util.matcher(repo.root, cwd, pats or ['.'], opts.get('include'), | 34 return util.matcher(repo.root, cwd, pats or ['.'], opts.get('include'), |
49 opts.get('exclude'), head) | 35 opts.get('exclude'), head) |
50 | 36 |
276 return | 262 return |
277 | 263 |
278 if node2: | 264 if node2: |
279 change = repo.changelog.read(node2) | 265 change = repo.changelog.read(node2) |
280 mmap2 = repo.manifest.read(change[0]) | 266 mmap2 = repo.manifest.read(change[0]) |
281 date2 = datestr(change) | 267 date2 = util.datestr(change) |
282 def read(f): | 268 def read(f): |
283 return repo.file(f).read(mmap2[f]) | 269 return repo.file(f).read(mmap2[f]) |
284 else: | 270 else: |
285 date2 = datestr() | 271 date2 = util.datestr() |
286 if not node1: | 272 if not node1: |
287 node1 = repo.dirstate.parents()[0] | 273 node1 = repo.dirstate.parents()[0] |
288 def read(f): | 274 def read(f): |
289 return repo.wfile(f).read() | 275 return repo.wfile(f).read() |
290 | 276 |
294 hexfunc = ui.verbose and hex or short | 280 hexfunc = ui.verbose and hex or short |
295 r = [hexfunc(node) for node in [node1, node2] if node] | 281 r = [hexfunc(node) for node in [node1, node2] if node] |
296 | 282 |
297 change = repo.changelog.read(node1) | 283 change = repo.changelog.read(node1) |
298 mmap = repo.manifest.read(change[0]) | 284 mmap = repo.manifest.read(change[0]) |
299 date1 = datestr(change) | 285 date1 = util.datestr(change) |
300 | 286 |
301 for f in c: | 287 for f in c: |
302 to = None | 288 to = None |
303 if f in mmap: | 289 if f in mmap: |
304 to = repo.file(f).read(mmap[f]) | 290 to = repo.file(f).read(mmap[f]) |
331 if ui.quiet: | 317 if ui.quiet: |
332 ui.write("%d:%s\n" % (rev, short(changenode))) | 318 ui.write("%d:%s\n" % (rev, short(changenode))) |
333 return | 319 return |
334 | 320 |
335 changes = log.read(changenode) | 321 changes = log.read(changenode) |
336 date = datestr(changes) | 322 date = util.datestr(changes) |
337 | 323 |
338 parents = [(log.rev(p), ui.verbose and hex(p) or short(p)) | 324 parents = [(log.rev(p), ui.verbose and hex(p) or short(p)) |
339 for p in log.parents(changenode) | 325 for p in log.parents(changenode) |
340 if ui.debugflag or p != nullid] | 326 if ui.debugflag or p != nullid] |
341 if not ui.debugflag and len(parents) == 1 and parents[0][0] == rev-1: | 327 if not ui.debugflag and len(parents) == 1 and parents[0][0] == rev-1: |