Mercurial > hg
comparison mercurial/commands.py @ 771:0de223012086
Fixes for annotate
Handle files that aren't in the repo
Handle empty files
author | mpm@selenic.com |
---|---|
date | Sat, 23 Jul 2005 14:11:49 -0500 |
parents | b3820ce0e88a |
children | d77c1031fd17 |
comparison
equal
deleted
inserted
replaced
770:b3820ce0e88a | 771:0de223012086 |
---|---|
377 else: | 377 else: |
378 node = repo.dirstate.parents()[0] | 378 node = repo.dirstate.parents()[0] |
379 change = repo.changelog.read(node) | 379 change = repo.changelog.read(node) |
380 mmap = repo.manifest.read(change[0]) | 380 mmap = repo.manifest.read(change[0]) |
381 for src, abs, rel in walk(repo, pats, opts): | 381 for src, abs, rel in walk(repo, pats, opts): |
382 if abs not in mmap: | |
383 ui.warn("warning: %s is not in the repository!\n" % rel) | |
384 continue | |
385 | |
382 lines = repo.file(abs).annotate(mmap[abs]) | 386 lines = repo.file(abs).annotate(mmap[abs]) |
383 pieces = [] | 387 pieces = [] |
384 | 388 |
385 for o, f in opmap: | 389 for o, f in opmap: |
386 if opts[o]: | 390 if opts[o]: |
387 l = [f(n) for n, dummy in lines] | 391 l = [f(n) for n, dummy in lines] |
388 m = max(map(len, l)) | 392 if l: |
389 pieces.append(["%*s" % (m, x) for x in l]) | 393 m = max(map(len, l)) |
390 | 394 pieces.append(["%*s" % (m, x) for x in l]) |
391 for p, l in zip(zip(*pieces), lines): | 395 |
392 ui.write("%s: %s" % (" ".join(p), l[1])) | 396 if pieces: |
397 for p, l in zip(zip(*pieces), lines): | |
398 ui.write("%s: %s" % (" ".join(p), l[1])) | |
393 | 399 |
394 def cat(ui, repo, file1, rev=None, **opts): | 400 def cat(ui, repo, file1, rev=None, **opts): |
395 """output the latest or given revision of a file""" | 401 """output the latest or given revision of a file""" |
396 r = repo.file(relpath(repo, [file1])[0]) | 402 r = repo.file(relpath(repo, [file1])[0]) |
397 if rev: | 403 if rev: |