  We give a new derivation of mean-field percolation critical behaviour from
the triangle condition that is quantitatively much better than previous proofs
when the triangle diagram $\nabla_{p_c}$ is large. In contrast to earlier
methods, our approach continues to yield bounds of reasonable order when the
triangle diagram $\nabla_p$ is unbounded but diverges slowly as $p \uparrow
p_c$, as is expected to occur in percolation on $\mathbb{Z}^d$ at the
upper-critical dimension $d=6$. Indeed, we show in particular that if the
triangle diagram diverges polylogarithmically as $p \uparrow p_c$ then
mean-field critical behaviour holds to within a polylogarithmic factor. We
apply the methods we develop to deduce that for long-range percolation on the
hierarchical lattice, mean-field critical behaviour holds to within
polylogarithmic factors at the upper-critical dimension.
  As part of the proof, we introduce a new method for comparing diagrammatic
sums on general transitive graphs that may be of independent interest.
