def final_merge
wi = if h.workitem
h.workitem
elsif h.cmerge_type == 'ignore' || h.workitems.nil? || h.workitems.empty?
h.applied_workitem
else
wis = h.workitems
if %w[ highest lowest ].include?(h.cmerge)
wis = h.workitems.sort_by { |wi| wi['fei']['expid'] }
end
if
%w[ first highest ].include?(h.cmerge) &&
! %w[ stack union concat deep ].include?(h.cmerge_type)
then
wis = wis.reverse
end
as, bs = wis.partition { |wi| wi.delete('winner') }
wis = bs + as
merge_workitems(wis, h.cmerge_type)
end
if h.cmerge_type == 'stack'
wi['fields']['stack_attributes'] = compile_atts
end
wi
end