'Sync the folders structure.
It does NOT sync the contents of those folders. nametrans rules
in both directions will be honored
Configuring nametrans on BOTH repositories could lead to infinite folder
creation cycles.'

def sync_folder_structure(self, local_repo, status_repo):

    if ((not self.should_create_folders()) and (not local_repo.should_create_folders())):
        return
    remote_repo = self
    (remote_hash, local_hash) = ({}, {})
    for folder in remote_repo.getfolders():
        remote_hash[folder.getname()] = folder
    for folder in local_repo.getfolders():
        local_hash[folder.getname()] = folder
    for (remote_name, remote_folder) in remote_hash.items():
        if (not local_repo.should_create_folders()):
            break
        local_name = remote_folder.getvisiblename().replace(remote_repo.getsep(), local_repo.getsep())
        if (remote_folder.sync_this and (not (local_name in local_hash.keys()))):
            try:
                local_repo.makefolder(local_name)
                local_repo.forgetfolders()
            except OfflineImapError as e:
                self.ui.error(e, exc_info()[2], ('Creating    folder    %s    on    repository    %s' % (local_name, local_repo)))
                raise
            status_repo.makefolder(local_name.replace(local_repo.getsep(), status_repo.getsep()))
    for (local_name, local_folder) in local_hash.items():
        if (not remote_repo.should_create_folders()):
            break
        remote_name = local_folder.getvisiblename().replace(local_repo.getsep(), remote_repo.getsep())
        if (local_folder.sync_this and (not (remote_name in remote_hash.keys()))):
            if (not remote_repo.should_sync_folder(remote_name)):
                self.ui.debug('', ("Not    creating    folder    '%s'    (repository    '%s')    as    it    would    be    filtered    out    on    that    repository." % (remote_name, self)))
                continue
            tmp_remotefolder = remote_repo.getfolder(remote_name)
            loop_name = tmp_remotefolder.getvisiblename().replace(remote_repo.getsep(), local_repo.getsep())
            if (local_name != loop_name):
                raise OfflineImapError(("INFINITE    FOLDER    CREATION    DETECTED!    Folder    '%s'    (repository    '%s')    would    be    created    as    folder    '%s'    (repository    '%s').    The    latter    becomes    '%s'    in    return,    leading    to    infinite    folder    creation    cycles.\n    SOLUTION:    1)    Do    set    your    nametrans    rules    on    both    repositories    so    they    lead    to    identical    names    if    applied    back    and    forth.    2)    Use    folderfilter    settings    on    a    repository    to    prevent    some    folders    from    being    created    on    the    other    side." % (local_folder.getname(), local_repo, remote_name, remote_repo, loop_name)), OfflineImapError.ERROR.REPO)
            try:
                remote_repo.makefolder(remote_name)
                self.forgetfolders()
            except OfflineImapError as e:
                self.ui.error(e, exc_info()[2], ('Creating    folder    %s    on    repository    %s' % (remote_name, remote_repo)))
                raise
            status_repo.makefolder(local_name.replace(local_repo.getsep(), status_repo.getsep()))
    return None
