[Buildbot-commits] [Buildbot] #2406: GerritChangeSource & ChangeFilter issue:only 1 git project ChangeFilter can receive change using GerritChangeSource

Buildbot nobody at buildbot.net
Wed Dec 5 03:12:39 UTC 2012


#2406: GerritChangeSource & ChangeFilter issue:only 1 git project ChangeFilter can
receive change using GerritChangeSource
----------------------------+------------------------
Reporter:  clino            |       Owner:
    Type:  support-request  |      Status:  closed
Priority:  minor            |   Milestone:  undecided
 Version:  0.8.7            |  Resolution:  fixed
Keywords:  gerrit           |
----------------------------+------------------------
Changes (by dustin):

 * status:  new => closed
 * type:  defect => support-request
 * resolution:   => fixed


Comment:

 I *think* you're running into trouble with re-use of the {{{rpath}}}
 variable.  During the for loop, it has different values assigned to it, so
 by the time the ChangeFilters start filtering, the for loop is finished
 and {{{rpath}}} has whatever value it had on the last iteration.

 This is a bit of a common problem with Python and closures, unfortunately.

 The common fix is to pass keyword arguments to a lambda, like we had to do
 back in Python-1.6 (egads, I've been at this for a while!) before there
 were closures.  So, in this case, that might be (untested)
 {{{
 repository_fn=lambda repository, rpath=rpath : repository.find(rpath)!=-1
 }}}
 The {{{rpath}}} in the right side of the lambda refers to a variable local
 to the lambda body; the value of that variable is set at the time the
 lambda is created, to the value of the outer-scope {{{rpath}}} variable.

 Ponder that for a while, but I think it will fix you up.

-- 
Ticket URL: <http://trac.buildbot.net/ticket/2406#comment:8>
Buildbot <http://buildbot.net/>
Buildbot: build/test automation


More information about the Commits mailing list