Mercurial > kallithea
changeset 6947:c326db109854
vcs: add support for Mercurial annotate in Mercurial 4.4
Mercurial fctx.annotate() returns tuples with two elements: info about the
annotate line and the actual line. The code is changed to clarify that.
After Mercurial 4.4 with https://www.mercurial-scm.org/repo/hg/rev/2e32c6a31cc7 ,
the info is no longer a tuple but an attr object. Assume fctx is available as
an attribute, but catch exceptions and fall back to indexing as before.
That can't easily be done in hgcompat, so we do it inline.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Mon, 23 Oct 2017 00:57:28 +0200 |
parents | f1acd7c28157 |
children | e6ce604d1ae0 |
files | kallithea/lib/vcs/backends/hg/changeset.py |
diffstat | 1 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/vcs/backends/hg/changeset.py Fri Oct 13 20:44:01 2017 +0200 +++ b/kallithea/lib/vcs/backends/hg/changeset.py Mon Oct 23 00:57:28 2017 +0200 @@ -294,10 +294,14 @@ """ fctx = self._get_filectx(path) - for i, annotate_data in enumerate(fctx.annotate(linenumber=False)): + for i, (aline, l) in enumerate(fctx.annotate(linenumber=False)): ln_no = i + 1 - sha = hex(annotate_data[0][0].node()) - yield (ln_no, sha, lambda: self.repository.get_changeset(sha), annotate_data[1],) + try: + fctx = aline.fctx + except AttributeError: # aline.fctx was introduced in Mercurial 4.4 + fctx = aline[0] + sha = hex(fctx.node()) + yield (ln_no, sha, lambda: self.repository.get_changeset(sha), l) def fill_archive(self, stream=None, kind='tgz', prefix=None, subrepos=False):