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) |
32 |
46 |
33 def matchpats(repo, cwd, pats=[], opts={}, head=''): |
47 def matchpats(repo, cwd, pats=[], opts={}, head=''): |
34 return util.matcher(repo.root, cwd, pats or ['.'], opts.get('include'), |
48 return util.matcher(repo.root, cwd, pats or ['.'], opts.get('include'), |
35 opts.get('exclude'), head) |
49 opts.get('exclude'), head) |
36 |
50 |
249 pathname), |
263 pathname), |
250 mode) |
264 mode) |
251 |
265 |
252 def dodiff(fp, ui, repo, node1, node2, files=None, match=util.always, |
266 def dodiff(fp, ui, repo, node1, node2, files=None, match=util.always, |
253 changes=None, text=False): |
267 changes=None, text=False): |
254 def date(c): |
|
255 return time.asctime(time.gmtime(float(c[2].split(' ')[0]))) |
|
256 |
|
257 if not changes: |
268 if not changes: |
258 (c, a, d, u) = repo.changes(node1, node2, files, match=match) |
269 (c, a, d, u) = repo.changes(node1, node2, files, match=match) |
259 else: |
270 else: |
260 (c, a, d, u) = changes |
271 (c, a, d, u) = changes |
261 if files: |
272 if files: |
265 return |
276 return |
266 |
277 |
267 if node2: |
278 if node2: |
268 change = repo.changelog.read(node2) |
279 change = repo.changelog.read(node2) |
269 mmap2 = repo.manifest.read(change[0]) |
280 mmap2 = repo.manifest.read(change[0]) |
270 date2 = date(change) |
281 date2 = datestr(change) |
271 def read(f): |
282 def read(f): |
272 return repo.file(f).read(mmap2[f]) |
283 return repo.file(f).read(mmap2[f]) |
273 else: |
284 else: |
274 date2 = time.asctime() |
285 date2 = datestr() |
275 if not node1: |
286 if not node1: |
276 node1 = repo.dirstate.parents()[0] |
287 node1 = repo.dirstate.parents()[0] |
277 def read(f): |
288 def read(f): |
278 return repo.wfile(f).read() |
289 return repo.wfile(f).read() |
279 |
290 |
283 hexfunc = ui.verbose and hex or short |
294 hexfunc = ui.verbose and hex or short |
284 r = [hexfunc(node) for node in [node1, node2] if node] |
295 r = [hexfunc(node) for node in [node1, node2] if node] |
285 |
296 |
286 change = repo.changelog.read(node1) |
297 change = repo.changelog.read(node1) |
287 mmap = repo.manifest.read(change[0]) |
298 mmap = repo.manifest.read(change[0]) |
288 date1 = date(change) |
299 date1 = datestr(change) |
289 |
300 |
290 for f in c: |
301 for f in c: |
291 to = None |
302 to = None |
292 if f in mmap: |
303 if f in mmap: |
293 to = repo.file(f).read(mmap[f]) |
304 to = repo.file(f).read(mmap[f]) |
320 if ui.quiet: |
331 if ui.quiet: |
321 ui.write("%d:%s\n" % (rev, short(changenode))) |
332 ui.write("%d:%s\n" % (rev, short(changenode))) |
322 return |
333 return |
323 |
334 |
324 changes = log.read(changenode) |
335 changes = log.read(changenode) |
325 |
336 date = datestr(changes) |
326 t, tz = changes[2].split(' ') |
|
327 # a conversion tool was sticking non-integer offsets into repos |
|
328 try: |
|
329 tz = int(tz) |
|
330 except ValueError: |
|
331 tz = 0 |
|
332 date = time.asctime(time.gmtime(float(t) - tz)) + " %+05d" % (int(tz)/-36) |
|
333 |
337 |
334 parents = [(log.rev(p), ui.verbose and hex(p) or short(p)) |
338 parents = [(log.rev(p), ui.verbose and hex(p) or short(p)) |
335 for p in log.parents(changenode) |
339 for p in log.parents(changenode) |
336 if ui.debugflag or p != nullid] |
340 if ui.debugflag or p != nullid] |
337 if not ui.debugflag and len(parents) == 1 and parents[0][0] == rev-1: |
341 if not ui.debugflag and len(parents) == 1 and parents[0][0] == rev-1: |