For a change in CI state, prevent pushing a new patch set

Check the state of a change during push and reject a new patch set
if a change is in one of CI states (STAGING, STAGED or INTEGRATING).

Task-number: QTQAINFRA-881
Change-Id: Iae73059f6378c45455373d071c107a30950fc3ee
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Ismo Haataja <ismo.haataja@digia.com>
Stop multiplying of review score boxes in the one page review

The one page review view didn't clear existing review score boxes
during page refresh. This caused multiplying. Existing boxes removed
now during refresh to keep just one set available.

Task-number: QTQAINFRA-861
Change-Id: Ifecc86e3c8b6ed9f740052a3bf79aba6ee468779
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Ismo Haataja <ismo.haataja@digia.com>
Do database operations before git operations when approving a build

Approving a build was done in following order:
* fast forwarded the destination branch to head of build branch on git
* rebuilding the staging branch on git
* updating status of approved changes on database, no transaction

If something went wrong during rebuilding the staging branch, database
update never happened, even git update did. This left database to
inconsistent state. Same could (partially) happen also during database
update because transaction was not used.

Now database transaction is created at very first and all database
operations are done. Then git merge and if that succeeds, transaction is
committed. In case of git problem, database transaction is rollbacked.

At the end, if build approving passed, two additional operations are done:
* notification emails sent (if there are any)
* and rebuilding the staging branch on git
These may fail also, but problems are just written to error log file, not
rejecting the actual build approval. Because we just can't anymore.

Task-number: QTQAINFRA-890
Change-Id: I7d0e060d3344b71af596d50b73a55a1e7624af3a
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Ismo Haataja <ismo.haataja@digia.com>
Fix replication triggering

Replication was not triggered because event of updated ref was not fired.

Task-number: QTQAINFRA-349
Change-Id: Ieaa62bf9703ce2de68b93050359703ff61ee199d
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Ismo Haataja <ismo.haataja@digia.com>
Notify reviewers about changes to commit message

Editing commit message directly from gerrit UI didn't send email to
reviewers. This was because email sending was missing the recipient
list. Added the reviewers as email recipients now.

Task-number: QTQAINFRA-884
Change-Id: Ib83e13a3709abbc54afb16cb74661acf14208d9f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Ismo Haataja <ismo.haataja@digia.com>
Shorten Search box

The Search box was too wide, shorter is enough. New length is
about 2/3 of the original one.

Task-number: QTQAINFRA-891
Change-Id: I4efba9af9b7d0564b74eb35a48d67c3ee82d986e
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Ismo Haataja <ismo.haataja@digia.com>
New css properties for top menu to get width adjusted properly

Added "display: inline-block" to prevent width getting too small and
thus hiding the login info, "min-width: 100%" to get width adjusted also
to wider browser window.

Task-number: QTQAINFRA-849
Change-Id: I10f7629462ed73272a9812951e3d51f923665e45
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Ismo Haataja <ismo.haataja@digia.com>
ChangeMergeQueue: Fix race condition

To the multiple triggers of submit action belong:

* ChangeMergeQueue.merge() method called from the UI
* ChangeMergeQueue.schedule() method called by background
ReloadSubmitQueueOp

active map in ChangeMergeQueue acts as a guard for submit job
scheduling. However schedule() ignores the fact that the submit
processing was already started for a specific branch and double
submit action is scheduled.

Specifically for cherry-pick submit strategy that cannot end
good and fails with database constraints violation or similar,
depending on the underlying database implementation.

Guard the background scheduling similar to the UI scheduling.

Defining unique index prevents the database corruption: [1], [2]
but not the collision between manual and background merge jobs.

[1] http://paste.openstack.org/show/83883
[2] http://paste.openstack.org/show/83888

Bug: issue 2034
Bug: issue 2383
Bug: issue 2702
Change-Id: I5b23f9d481351280e26412b82b525947338d9c00
(cherry picked from commit f26fdb499b26a2c02251546a7bb19703cc6c8bba)
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Ismo Haataja <ismo.haataja@digia.com>
Upgrade gwtorm to 1.7.3

Upgrade version of gwtorm to get JDBC transaction support.

Task-number: QTQAINFRA-896
Change-Id: Ia18fc5d0caa01d0c906efbd752bbf5e5b1b5b1bd
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Ismo Haataja <ismo.haataja@digia.com>
Top/bottom keyboard navigation keys added for diff review pages

'K' is used to move to top of diff review page (changes)
'J' is used to move to bottom of diff review page (changes)

Task-number: QTQAINFRA-902
Change-Id: I5a39a80b3595a8a1f652efb8c22ff3795ae55c9f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Ismo Haataja <ismo.haataja@digia.com>
Fixes for keyboard (and mouse) navigation in one page review

Navigation in one page review had some issues. Following fixes done:
* mouse click focuses the row clicked to enable keyboard navigation
* next line navigation key (j) moves to next file if last line of
  the file reached
* previous line navigation key (k) moves to previous file if first line
  of the file reached
* also next/previous keys for chunk/comment (n/p/N/P) move to next/previous
  file when necessary
* publish comment key (r) focuses the cover message edit box, instead of
  jumping to Publish Comments page

Task-number: QTQAINFRA-856
Change-Id: Ica9676a641d1a5d7d18c545369ff0e14471129e4
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Ismo Haataja <ismo.haataja@digia.com>
No initial focus to Cover Message editor in One Page Review

Setting initial focus to Cover Message editor made no sense because
it is in bottom of page, so usually not even visible and not logical
place to start review from. This also disabled keyboard navigation keys.
Now focus is not explicitly set and keyboard navigation works.

Task-number: QTQAINFRA-883
Change-Id: I5b80f7236d4863bb36a493fa43f2dcc58b2ffd43
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Ismo Haataja <ismo.haataja@digia.com>