And part of the "deal" concluded with the treaty was that the victorious American forces would leave Mexico City and the rest of the territory we had taken during the war. That's a pretty good deal for them, we could have just kept it as a subjugated colony.
(Hisotrical fact: Mexico in 1846 had a much larger professional military than the USA. We whipped their a$$es back to their capital with hastily formed and trained volunteers and amateurs. Something they may wish to think about, should push come to shove again.)
The site of the Bear Flag revolt is still somewhat preserved in Sonoma. General Vallejo (pronounced Va-Lay-O if one is a true native Californian not Va_Lay_Ho) fortress like barracks and some other buildings still evident. An interesting place to visit.