A deal to hand Mauritius the Chagos Islands and lease back a key military base has been months in the making.