improved __getstate__ __setstate__ of hg