If we wanted to call sys.setdefaultencoding(), we should call it once during hg or at the top of mercurial/__init__.py.
But we don't want to call sys.setdefaultencoding(). This topic has been discussed heavily over the years. The various answers at https://stackoverflow.com/questions/3828723/why-should-we-not-use-sys-setdefaultencodingutf-8-in-a-py-script have a lot of context and I won't rehash the reasons here.
May I ask what compelled you to want to do this? Any bug you encountered that was fixed by this change represents a place where Mercurial isn't handling encoding properly. We should fix the actual places where that is occurring. Because even if we switch to UTF-8 as the default string encoding, UTF-8 isn't used everywhere and the underlying encoding problem may still exist!
Any patch to introduce sys.setdefaultencoding() into the code base will likely never be accepted (unless it is doing something special like what HGUNICODEPEDANTRY is doing). So you may want to mark this code review as abandoned.