Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 37069:b33b91ca2ec2
annotate: pack line content into annotateline object (API)
Just for code readability. We can do that since the annotateline type is
no longer used while computing the history.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 18 Mar 2018 12:28:19 +0900 |
parents | b235bde38a83 |
children | f0b6fbea00cf |
comparison
equal
deleted
inserted
replaced
37068:b235bde38a83 | 37069:b33b91ca2ec2 |
---|---|
394 continue | 394 continue |
395 formats = [] | 395 formats = [] |
396 pieces = [] | 396 pieces = [] |
397 | 397 |
398 for f, sep in funcmap: | 398 for f, sep in funcmap: |
399 l = [f(n) for n, dummy in lines] | 399 l = [f(n) for n in lines] |
400 if fm.isplain(): | 400 if fm.isplain(): |
401 sizes = [encoding.colwidth(x) for x in l] | 401 sizes = [encoding.colwidth(x) for x in l] |
402 ml = max(sizes) | 402 ml = max(sizes) |
403 formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes]) | 403 formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes]) |
404 else: | 404 else: |
405 formats.append(['%s' for x in l]) | 405 formats.append(['%s' for x in l]) |
406 pieces.append(l) | 406 pieces.append(l) |
407 | 407 |
408 for f, p, (n, l) in zip(zip(*formats), zip(*pieces), lines): | 408 for f, p, n in zip(zip(*formats), zip(*pieces), lines): |
409 fm.startitem() | 409 fm.startitem() |
410 fm.context(fctx=n.fctx) | 410 fm.context(fctx=n.fctx) |
411 fm.write(fields, "".join(f), *p) | 411 fm.write(fields, "".join(f), *p) |
412 if n.skip: | 412 if n.skip: |
413 fmt = "* %s" | 413 fmt = "* %s" |
414 else: | 414 else: |
415 fmt = ": %s" | 415 fmt = ": %s" |
416 fm.write('line', fmt, l) | 416 fm.write('line', fmt, n.text) |
417 | 417 |
418 if not lines[-1][1].endswith('\n'): | 418 if not lines[-1].text.endswith('\n'): |
419 fm.plain('\n') | 419 fm.plain('\n') |
420 fm.end() | 420 fm.end() |
421 | 421 |
422 rootfm.end() | 422 rootfm.end() |
423 | 423 |