# HG changeset patch # User Mads Kiilerich # Date 2017-10-23 00:57:28 # Node ID c326db1098547bee343517123485c5fdbf95fd18 # Parent f1acd7c281574b51d3d22e433a6c50bf39252197 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. diff --git a/kallithea/lib/vcs/backends/hg/changeset.py b/kallithea/lib/vcs/backends/hg/changeset.py --- a/kallithea/lib/vcs/backends/hg/changeset.py +++ b/kallithea/lib/vcs/backends/hg/changeset.py @@ -294,10 +294,14 @@ class MercurialChangeset(BaseChangeset): """ 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):