Mexico was in such a direct state that it was a somewhat safe, calculated risk for the US to start a war and win it. Anything that leads to a stronger, more stable Mexico probably dissuades the US from going to war in the first place.
But for the sake of this scenario, I say Mexico has to do whatever it can to make the fight for California as long and drawn out as possible, doing a better job of rallying the loyalists together. Mexico had a bit of success in this theater and Southern California was more loyalist than the Northern California was, where there were more Americans settling.
In this case, even a stalemate is a victory of sorts for Mexico.