copy from xmpp-base hg