How Brexit talks nearly foundered on the Rock