John Swinney cautioned Nicola Sturgeon against calling for a second independence referendum on the day of the Brexit result.