Show More
@@ -396,7 +396,7 b' def annotate(ui, repo, *pats, **opts):' | |||||
396 | pieces = [] |
|
396 | pieces = [] | |
397 |
|
397 | |||
398 | for f, sep in funcmap: |
|
398 | for f, sep in funcmap: | |
399 |
l = [f(n) for n |
|
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) | |
@@ -405,7 +405,7 b' def annotate(ui, repo, *pats, **opts):' | |||||
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, |
|
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) | |
@@ -413,9 +413,9 b' def annotate(ui, repo, *pats, **opts):' | |||||
413 | fmt = "* %s" |
|
413 | fmt = "* %s" | |
414 | else: |
|
414 | else: | |
415 | fmt = ": %s" |
|
415 | fmt = ": %s" | |
416 |
fm.write('line', fmt, |
|
416 | fm.write('line', fmt, n.text) | |
417 |
|
417 | |||
418 |
if not lines[-1] |
|
418 | if not lines[-1].text.endswith('\n'): | |
419 | fm.plain('\n') |
|
419 | fm.plain('\n') | |
420 | fm.end() |
|
420 | fm.end() | |
421 |
|
421 |
@@ -968,11 +968,12 b' class basefilectx(object):' | |||||
968 | return filectx(self._repo, self._path, fileid=-1, filelog=self._filelog) |
|
968 | return filectx(self._repo, self._path, fileid=-1, filelog=self._filelog) | |
969 |
|
969 | |||
970 | def annotate(self, follow=False, skiprevs=None, diffopts=None): |
|
970 | def annotate(self, follow=False, skiprevs=None, diffopts=None): | |
971 |
"""Returns a list of |
|
971 | """Returns a list of annotateline objects for each line in the file | |
972 |
|
972 | |||
973 |
- |
|
973 | - line.fctx is the filectx of the node where that line was last changed | |
974 |
- |
|
974 | - line.lineno is the line number at the first appearance in the managed | |
975 | file |
|
975 | file | |
|
976 | - line.text is the data on that line (including newline character) | |||
976 | """ |
|
977 | """ | |
977 | getlog = util.lrucachefunc(lambda x: self._repo.file(x)) |
|
978 | getlog = util.lrucachefunc(lambda x: self._repo.file(x)) | |
978 |
|
979 |
@@ -368,6 +368,7 b' class annotateline(object):' | |||||
368 | lineno = attr.ib() |
|
368 | lineno = attr.ib() | |
369 | # Whether this annotation was the result of a skip-annotate. |
|
369 | # Whether this annotation was the result of a skip-annotate. | |
370 | skip = attr.ib(default=False) |
|
370 | skip = attr.ib(default=False) | |
|
371 | text = attr.ib(default=None) | |||
371 |
|
372 | |||
372 | @attr.s(slots=True, frozen=True) |
|
373 | @attr.s(slots=True, frozen=True) | |
373 | class _annotatedfile(object): |
|
374 | class _annotatedfile(object): | |
@@ -514,9 +515,8 b' def annotate(base, parents, skiprevs=Non' | |||||
514 | del pcache[f] |
|
515 | del pcache[f] | |
515 |
|
516 | |||
516 | a = hist[base] |
|
517 | a = hist[base] | |
517 |
return [ |
|
518 | return [annotateline(*r) for r in zip(a.fctxs, a.linenos, a.skips, | |
518 | for fctx, lineno, skip, line |
|
519 | mdiff.splitnewlines(a.text))] | |
519 | in zip(a.fctxs, a.linenos, a.skips, mdiff.splitnewlines(a.text))] |
|
|||
520 |
|
520 | |||
521 | def toposort(revs, parentsfunc, firstbranch=()): |
|
521 | def toposort(revs, parentsfunc, firstbranch=()): | |
522 | """Yield revisions from heads to roots one (topo) branch at a time. |
|
522 | """Yield revisions from heads to roots one (topo) branch at a time. |
@@ -945,13 +945,14 b' def annotate(web):' | |||||
945 | if fctx.isbinary(): |
|
945 | if fctx.isbinary(): | |
946 | mt = (mimetypes.guess_type(fctx.path())[0] |
|
946 | mt = (mimetypes.guess_type(fctx.path())[0] | |
947 | or 'application/octet-stream') |
|
947 | or 'application/octet-stream') | |
948 |
lines = [( |
|
948 | lines = [dagop.annotateline(fctx=fctx.filectx(fctx.filerev()), | |
|
949 | lineno=1, text='(binary:%s)' % mt)] | |||
949 | else: |
|
950 | else: | |
950 | lines = webutil.annotate(web.req, fctx, web.repo.ui) |
|
951 | lines = webutil.annotate(web.req, fctx, web.repo.ui) | |
951 |
|
952 | |||
952 | previousrev = None |
|
953 | previousrev = None | |
953 | blockparitygen = paritygen(1) |
|
954 | blockparitygen = paritygen(1) | |
954 |
for lineno, |
|
955 | for lineno, aline in enumerate(lines): | |
955 | f = aline.fctx |
|
956 | f = aline.fctx | |
956 | rev = f.rev() |
|
957 | rev = f.rev() | |
957 | if rev != previousrev: |
|
958 | if rev != previousrev: | |
@@ -971,7 +972,7 b' def annotate(web):' | |||||
971 | "blockhead": blockhead, |
|
972 | "blockhead": blockhead, | |
972 | "blockparity": blockparity, |
|
973 | "blockparity": blockparity, | |
973 | "targetline": aline.lineno, |
|
974 | "targetline": aline.lineno, | |
974 | "line": l, |
|
975 | "line": aline.text, | |
975 | "lineno": lineno + 1, |
|
976 | "lineno": lineno + 1, | |
976 | "lineid": "l%d" % (lineno + 1), |
|
977 | "lineid": "l%d" % (lineno + 1), | |
977 | "linenumber": "% 6d" % (lineno + 1), |
|
978 | "linenumber": "% 6d" % (lineno + 1), |
General Comments 0
You need to be logged in to leave comments.
Login now