# Bootstrap an empty repository to the current state of the database
from __future__ import with_statement
import os, tempfile, threading

import pysvn

#from .share import svndriven
from .custom import REPOSITORY
from . import hook
from bazbase import structure

def bootstrap():
    hook.begin()

    try:
        for p in structure.list_all_props():
            hook.psetattr(p,'flavor',p.flavor)
            hook.psetattr(p,'default',p.default)
        for e in structure.list_all_elements():
            hook.esetattr(e,'parent',e.parent,bootstrapping=True)
            for p in e:
                hook.setprop(e,p,e[p].value)
    except:
        hook.abort()
        raise
    else:
        hook.prepare()
        hook.commit()
