Sorry to hear that but as others have noted, it is good to know what is going on and now you can focus your mind and body on treatment and recovery.
Modern hip replacement is a godsend and will give you so much back in a very very short time post op. I have friends that did it and were our skiing 3 months later nevermind walking and getting around pain free.
For the fasting thing - can't say much about it as a protocol as haven't done it but two observations that may or may not be helpful.
1. Ask the doc if the fasting is to get as quickly as possible to Op ready weight or if it is something that he/she recommends post op and in terms of long term diet. It may make sense as a path of least resistance to get to the Op ready weight but I don't think it's an easy long term diet to maintain as it puts major constraints on so many social behaviours (get togethers, dinners, days out, etc...) not to mention other physiological considerations.
2. Calories in / calories out + balance in what is constituting those calories is key. The brain has an annoying way of telling the body that hurting itself is good with bad calories and bad balance. There is legit sugar, fats, and other processed foods withdrawal symptoms to deal with but in the space of 3 days or so most are likely to pass. You don't have to shock the system and go cold turkey with things like sugar or going from burgers and pasta to salad and eggs. You can weed out the worst balanced calories but keep some of the others in as part of that transition. It will make it easier and help the brain to accommodate the change. Takes the edge off it and should help IMO.