Handle multiple codebases in Grid and Transposed Grid views

Should fix http://trac.buildbot.net/ticket/2466.

In current implementation builds will be in the same row/column if they have same codebases and same revisions inside codebases.