All pastes #78154 Raw Edit

Miscellany

public text v1 · immutable
·published 2006-07-03 20:46 UTC
rendered paste body
#!/usr/bin/env python
                 
mtn_epochs = [   
                 ("org.openembedded.dev","epoch"),
                 ("org.openembedded.oz354x", "epoch"),
                 ("org.openembedded.documentation", "epoch"),
                 ("org.openembedded.oz354fam083", "epoch")
             ]
             
known_revs = [
             ]

    
def backup_db(dbname):
    """
    Create a backup
    """
    print "Creating a backup of %s" % dbname
    os.system("cp %s monotone_025_data_backup.mtn")
    os.system("cp % rosterify_base.mtn")

    return "rosterify_base.mtn"
    
    
def verify_db(dbname):
    """
    Verify that the db is uptodate with the published one
    """
    pass
    
def rosterify(basedb):
    """
    Rosterify the db now
    """
    os.system("mtn --db %s db migrate", basedb)
    os.system("mtn --db %s db rosterify", basedb)


def find_private(dbname):
    """
    Find the private revisions of the db
    """
    return []

def kill_common(dbname):
    """
    Kill common revs from the DB
    """
    for rev in known_revs:
        os.system("""mtn --db %s db execute "DELETE FROM revision_certs WHERE id = '%s'""" % (dbname,rev) )

def verify_new(dbname,private):
    """
    Check that only private data survived
    """
    pass

def update_epochs(dbname):
    """
    Update the epochs in the database
    """

    for (branch,epoch) in mtn_epochs:
        os.system("mtn --db %s db set_epoch %s %s" % (dbname,branch,epoch) )

if __name__ == "__main__":
    if len(sys.argv) != 2:
        print "Error not enough commands: call with base database"
        return

    base_db = backup_db(sys.argv[1])
    verify_db(base_db)
    privates = find_private(base_db)
    rosterify(base_db)
    kill_common(base_db)
    verify_new(base_db,privates)
    update_epochs(base_db)