Confinement in TCV electron cyclotron heated discharges was studied as a function of plasma shape, i.e. as a function of elongation, 1.1 < kappa < 2.15, and triangularity, -0.65 less than or equal to delta less than or equal to 0.55. The electron energy confinement time was found to increase with elongation, owing in part to the increase of plasma current with elongation. The beneficial effect of negative triangularities was most effective at low power and tended to decrease at the higher powers used. The large variety of sawtooth types observed in TCV for different power deposition locations, from on-axis to the q = 1 region, was simulated with a model that included local power deposition, a growing m/n = 1 island (convection and reconnection), plasma rotation and finite heat diffusivity across flux surfaces. Furthermore, a model with local magnetic shear reproduced the experimental observation that the sawtooth period is at a maximum when the heating is close to the q = 1 surface.