Update merge status after merge:merge is submitted

When preparing a reference, we set the merge state to PENDING before
emitting the merge:merge function.  If any exception occurs when
submitting the merge:merge job, the buildset is left PENDING and is
never retried because prepareRef() early exit in such case.

Move the merge_state change after the job has been submitted. An
exception would let the state as is (ie NEW) and thus indicate it should
be retried.

Closes-Bug: #1358517
Change-Id: I4d91a15aaae878ed231d50ab5f4f7a65f0d0e830
1 file changed