Clone an existing repository to a new bare repository.

def clone(cls, srcpath, destpath):
        """Clone an existing repository to a new bare repository."""
        # Mercurial will not create intermediate directories for clones.
        try:
            os.makedirs(destpath)
        except OSError as e:
            if not e.errno == errno.EEXIST:
                raise
        cmd = [HG, 'clone', '--quiet', '--noupdate', srcpath, destpath]
        subprocess.check_call(cmd)
        return cls(destpath)