This look that he gives Mary when she says “there’s nothing I would not do to stop that (John leaving her) from happening” says it all.
Sherlock has DONE everything that he can to make sure that John stays his friend and to make sure that John is happy. He’s standing there internally bleeding, he was driving himself mad trying to help plan the wedding, he faked his death and left his friends for two years (and he was tortured during those two years), and he restarted his heart because he knew that John would not be safe with Mary. HE has done everything he can to make sure that John is happy and he doesn’t want to hear this shit from Mary.
He doesn’t want to hear her say “there’s nothing I would not do” because he has done it all. He has practically destroyed himself in order to keep John safe and happy. Look at him. He’s BLEEDING INTERNALLY right now! He doesn’t want to hear all of this shit that she would do because he has already done it all. There’s nothing that Mary would do that Sherlock hasn’t already tried to or done.
Sherlock has done everything for John and to hear Mary say “there’s nothing I would not do” to keep him, would be incredibly infuriating for him. He’s been so completely selfless for John and his WIFE won’t even be truthful to him. She shot John’s best friend and has lied to him since the day they met. Sherlock doesn’t want to hear anything that Mary’s got to say on the subject of being “selfless” for John. He knows what it’s like to be completely selfless for someone, no matter what, even if they’re not happy with YOU, all that matters is that they’re happy. Sherlock has grasped this concept, Mary has not.