Exemplo n.º 1
0
def main_branches(first):
    cmd_p("Main start: branches")
    print ("Total branches: "+str(len(svn_utils.svn_branches)))
    if (first == 0):
        svn_branches_log_update()
    svn_branches_log_xml(first)
    cmd_p("finish: branches")
Exemplo n.º 2
0
def main_tags(first):
    cmd_p("Main start: tags")
    print ("Total trunk: "+str(len(svn_utils.svn_tags)))
    if (first == 0):
        svn_tags_log_update()
    svn_tags_log_xml(first)
    cmd_p("finish: tags")
Exemplo n.º 3
0
def main_trunk(first):
    cmd_p("main start: trunk")
    print ("Total trunk: "+str(len(svn_utils.svn_projects)))
    if (first == 0):
        svn_log_update()
    svn_log_xml(first)
    cmd_p("finish: trunk")
def cmd_parser():
    svn_utils.cmd_p("\n*******start to parse cmd arguments***********\n")
    #args = parser.parse_args(['checkout', '-t', 'branches', 'trunk', 'tags', '-ux', 'true'])
    #args = parser.parse_args(['checkout', '-t', 'branches', '-ux', 'true'])
    args = parser.parse_args(['query','-f', 'true'])
    #args = parser.parse_args()
    svn_utils.cmd_p(args)
    args.func(args)
Exemplo n.º 5
0
def main_old_download_source_first():
    first = 0
    cmd_p("Main start")
    if (first == 0):
        sqlite_init()
        #svn_check_path()
    svn_update_path()
    svn_db_commits(first)
    svn_db_close
    cmd_p("finish")
Exemplo n.º 6
0
def svn_db_commits(first = 0):
    cwd()
    os.chdir("."+svn_xmls)
    for project in svn_projects:
        name = project['project']
        file_name = (name+".xml")
        cmd_p(("Start to commit the db in project: "+name))
        if os.path.exists(file_name):
            if first == 0:
                svn_xml_parse_first(file_name, name)
            else:
                svn_xml_parse_nonfirst(file_name, name)
        else:
            print "** "+name+" xml file not find ** "
Exemplo n.º 7
0
def svn_branches_xml_parse_nonfirst(xml_path, project):
    cmd_p("start to process xml file non first: "+xml_path)
    max = sqlite_commit_max(project)
    print "project="+project+" has max="+max
    dom = xml.dom.minidom.parse (xml_path)
    logs = dom.getElementsByTagName("log")
    for log in logs:
        les = log.getElementsByTagName("logentry")
        for le in les[0:]:
            if le.hasAttribute("revision"):
                revision = le.getAttribute("revision")
                if (int(revision) <= max):
                    print "** branches_"+project+" xml db no need to update exising commits"
                    break
                else:
                    svn_branches_commit_parse(le, project)
    cmd_p("branches_"+project+" xml db update finish")
Exemplo n.º 8
0
def svn_branches_xml_parse_first(xml_path, project):
    cmd_p("start to process xml file first: "+xml_path)
    cmd_p(os.getcwd())
    dom = xml.dom.minidom.parse (xml_path)
    logs = dom.getElementsByTagName("log")
    for log in logs:
        #print log.tagName
        les = log.getElementsByTagName("logentry")
        cmd_p(("logentry counts = ",len(les)))
        for le in les[0:]:
            #print le.toxml()
            if le.hasAttribute("revision"):
                svn_branches_commit_parse(le, project)
    cmd_p("branches_"+project+" xml db insert finish")
# To change this template, choose Tools | Templates
# and open the template in the editor.

__author__="jianhuashao"
__date__ ="$Sep 6, 2011 4:23:47 PM$"

import svn_utils
import svn_cmd_options

if __name__ == "__main__":
    svn_utils.cmd_p('-t trunk tags branches -ux true')
    svn_cmd_options.cmd_register()
    svn_cmd_options.cmd_parser()
    print "Hello World"
Exemplo n.º 10
0
def sqlite_init():
    conn = svn_utils.svn_get_conn()
    cmd_p("start to init the database")
    c = conn.cursor()
    c.executescript('''
        -- create table svn_project
        CREATE TABLE IF NOT EXISTS svn_project (
            project_id  INTEGER PRIMARY KEY,
            project_name TEXT UNIQUE NOT NULL,
            project_svn_address TEXT,
            project_description TEXT
        );
        -- create table svn_revision
        CREATE TABLE IF NOT EXISTS svn_revision (
            revision_id INTEGER PRIMARY KEY,
            project_id  INTEGER NOT NULL,
            revision INTEGER NOT NULL,
            UNIQUE (project_id, revision),
            FOREIGN KEY (project_id) REFERENCES svn_project(project_id)
        );
        -- create table svn_tags
        CREATE TABLE IF NOT EXISTS svn_tags (
            svn_tags_id INTEGER PRIMARY KEY,
            revision_id INTEGER UNIQUE NOT NULL,
            FOREIGN KEY (revision_id) REFERENCES svn_revision(revision_id)
        );
        -- create table svn_branches
        CREATE TABLE IF NOT EXISTS svn_branches (
            svn_branches_id INTEGER PRIMARY KEY,
            revision_id INTEGER UNIQUE NOT NULL,
            FOREIGN KEY (revision_id) REFERENCES svn_revision(revision_id)
        );
        -- create table svn_projects
        CREATE TABLE IF NOT EXISTS svn_projects (
            svn_projects_id INTEGER PRIMARY KEY,
            revision_id INTEGER UNIQUE NOT NULL,
            FOREIGN KEY (revision_id) REFERENCES svn_revision(revision_id)
        );
        -- create table svn_author
        CREATE TABLE IF NOT EXISTS svn_author (
            author_id  INTEGER PRIMARY KEY,
            author_name TEXT NOT NULL,
            UNIQUE (author_name)
        );
        -- create table svn_msg
        CREATE TABLE IF NOT EXISTS svn_msg (
            msg_id  INTEGER PRIMARY KEY,
            msg TEXT
        );
        -- create table svn_file_path
        CREATE TABLE IF NOT EXISTS svn_file_path (
            file_id  INTEGER PRIMARY KEY,
            file_path TEXT NOT NULL UNIQUE
        );
        -- create table svn_file_copy
        CREATE TABLE IF NOT EXISTS svn_file_copy (
            copy_id INTEGER PRIMARY KEY,
            revision_from_id INTEGER NOT NULL,
            revision_to_id INTEGER NOT NULL,
            file_from_id INTEGER NOT NULL,
            file_to_id  INTEGER NOT NULL,
            FOREIGN KEY (revision_from_id) REFERENCES svn_revision(revision_id),
            FOREIGN KEY (revision_to_id) REFERENCES svn_revision(revision_id),
            FOREIGN KEY (file_from_id) REFERENCES svn_file_path(file_id),
            FOREIGN KEY (file_to_id) REFERENCES svn_file_path(file_id)
        );
        -- create table svn_files
        CREATE TABLE IF NOT EXISTS svn_files (
            revision_id  INTEGER NOT NULL,
            file_id INTEGER NOT NULL,
            action TEXT,
            kind TEXT,
            copy_id INTEGER, 
            PRIMARY KEY (revision_id, file_id),
            FOREIGN KEY (revision_id) REFERENCES svn_revision(revision_id),
            FOREIGN KEY (file_id) REFERENCES svn_file_path(file_id),
            FOREIGN KEY (copy_id) REFERENCES svn_file_copy(copy_id)
        );
        -- create table svn_time
        CREATE TABLE IF NOT EXISTS svn_time (
            time_id INTEGER PRIMARY KEY,
            timestamp INTEGER
        );
        -- create table svn_commits
        CREATE TABLE IF NOT EXISTS svn_commits (
            revision_id INTEGER NOT NULL,
            author_id   INTEGER NOT_NULL,
            msg_id      INTEGER NOT_NULL,
            time_id     INTEGER NOT_NULL,
            PRIMARY KEY (revision_id),
            FOREIGN KEY (revision_id) REFERENCES svn_revision(revision_id),
            FOREIGN KEY (author_id) REFERENCES svn_author(author_id),
            FOREIGN KEY (msg_id) REFERENCES svn_msg(msg_id),
            FOREIGN KEY (time_id) REFERENCES svn_time(time_id)
        );
        ''')
    conn.commit()
    c.execute('''SELECT * FROM SQLITE_MASTER''')
    tables = c.fetchall()
    print ("database tables in total: ",len(tables))
    for row in tables:
        print "\t(["+row[0]+"],["+row[2]+"])"
    c.close()
    cmd_p("finish init databse")