Esempio n. 1
0
def list_command(args):
    "List repositories and store their names and attributes"
    store = SqliteStore(args.dir)
    host_info, projects = _host_info_and_projects(store, args)
    if projects:
        for prj in projects:
            store.add_project(host_info.id, prj, {})
        store.commit()
    elif host_info.lister_module:
        # Try to get lister
        lister = __import__(host_info.lister_module, fromlist=['list_repos'])
        with Timer('List repos at %s' % host_info.name):
            for repo in lister.list_repos(host_info, args.start_index, args.index_count):
                store.add_project(host_info.id, repo[0], repo[1])
            store.commit()
    else:
        print 'Warning: No lister available for %s' % host_info.name
Esempio n. 2
0
def import_command(args):
    "Process logs of repositories and put them into the database"
    store = SqliteStore(args.dir)
    host_info, projects = _host_info_and_projects(store, args)
    if not projects:
        projects = _projects_from_store(store, host_info)
    if not projects and not args.only_this_step:
        list_command(args)
        projects = _projects_from_store(store, host_info)
    if projects:
        for prj in projects:
            projectid, _ = store.add_project(host_info.id, prj)
            path = host_info.project_local_path(args.dir, prj)
            if not os.path.exists(os.path.join(path, '.hg')) and not args.only_this_step:
                source = host_info.project_remote_url(prj)
                mirror_repo(source, path)
            with Timer('Process logs %s' % (path)):
                import_log(store, projectid, path)