Import modules when used.  Taken from Mercurial.