Quantifying the effects of migration and mutation on adaptation and demography in spatially heterogeneous environments