Changeset - b3ef9012be54
[Not reviewed]
default
0 1 0
Mads Kiilerich - 8 years ago 2018-05-11 14:26:48
mads@kiilerich.com
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.
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/vcs/backends/hg/changeset.py
Show inline comments
 
@@ -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):
0 comments (0 inline, 0 general)