# HG changeset patch # User Mads Kiilerich # Date 2018-05-11 14:26:48 # Node ID b3ef9012be54b05574dca9d6c8fb7de8c658e392 # Parent 205c0ed5b628d4cde325e5fd10466a2df6c0f42d hg: fix continuation binding of callback variables The get_file_annotate generator yields a callback. That callback happened to look at the current state of the generator. It happened to work anyway, apparently because the callback always was called immediately, before the generator state changed. But for example if the get_file_annotate was buffered into a list, the callback would return the same result each time. Instead, bind the generator iterator variables as named parameter values for the callback function. That will make sure the callback always returns the right value. 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 @@ -305,7 +305,7 @@ class MercurialChangeset(BaseChangeset): 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) + yield (ln_no, sha, lambda sha=sha, l=l: self.repository.get_changeset(sha), l) def fill_archive(self, stream=None, kind='tgz', prefix=None, subrepos=False):