Switch to unified view

a/scripts/refresh-all-repos.py b/scripts/refresh-all-repos.py
...
...
20
        q_project['shortname'] = options.project
20
        q_project['shortname'] = options.project
21
    elif options.project_regex:
21
    elif options.project_regex:
22
        q_project['shortname'] = {'$regex': options.project_regex}
22
        q_project['shortname'] = {'$regex': options.project_regex}
23
23
24
    log.info('Refreshing repositories')
24
    log.info('Refreshing repositories')
25
    if options.clean:
25
    if options.clean_all:
26
        log.info('Removing all repository objects')
26
        log.info('Removing all repository objects')
27
        M.repo.CommitDoc.m.remove({})
27
        M.repo.CommitDoc.m.remove({})
28
        M.repo.TreeDoc.m.remove({})
28
        M.repo.TreeDoc.m.remove({})
29
        M.repo.TreesDoc.m.remove({})
29
        M.repo.TreesDoc.m.remove({})
30
        M.repo.DiffInfoDoc.m.remove({})
30
        M.repo.DiffInfoDoc.m.remove({})
...
...
46
                if not hasattr(app, 'repo'): continue
46
                if not hasattr(app, 'repo'): continue
47
                try:
47
                try:
48
                    c.app.repo._impl._setup_hooks()
48
                    c.app.repo._impl._setup_hooks()
49
                except:
49
                except:
50
                    log.exception('Error setting up hooks for %r', c.app.repo)
50
                    log.exception('Error setting up hooks for %r', c.app.repo)
51
52
                if options.clean:
53
                    ci_ids = list(c.app.repo.all_commit_ids())
54
                    log.info("Deleting mongo data for %i commits...", len(ci_ids))
55
                    tree_ids = [
56
                            tree_id for doc in
57
                            M.repo.TreesDoc.m.find({"_id": {"$in": ci_ids}},
58
                                                   {"tree_ids": 1})
59
                            for tree_id in doc.get("tree_ids", [])]
60
61
                    i = M.repo.CommitDoc.m.find({"_id": {"$in": ci_ids}}).count()
62
                    log.info("Deleting %i CommitDoc docs...", i)
63
                    M.repo.CommitDoc.m.remove({"_id": {"$in": ci_ids}})
64
65
                    i = M.repo.TreesDoc.m.find({"_id": {"$in": ci_ids}}).count()
66
                    log.info("Deleting %i TreesDoc docs...", i)
67
                    M.repo.TreesDoc.m.remove({"_id": {"$in": ci_ids}})
68
69
                    i = M.repo.TreeDoc.m.find({"_id": {"$in": tree_ids}}).count()
70
                    log.info("Deleting %i TreeDoc docs...", i)
71
                    M.repo.TreeDoc.m.remove({"_id": {"$in": tree_ids}})
72
73
                    i = M.repo.LastCommitDoc.m.find({"object_id": {"$in": tree_ids}}).count()
74
                    log.info("Deleting %i LastCommitDoc docs...", i)
75
                    M.repo.LastCommitDoc.m.remove({"object_id": {"$in": tree_ids}})
76
77
                    i = M.repo.DiffInfoDoc.m.find({"_id": {"$in": ci_ids}}).count()
78
                    log.info("Deleting %i DiffInfoDoc docs...", i)
79
                    M.repo.DiffInfoDoc.m.remove({"_id": {"$in": ci_ids}})
80
81
                    i = M.repo.CommitRunDoc.m.find({"commit_ids": {"$in": ci_ids}}).count()
82
                    log.info("Deleting %i CommitRunDoc docs...", i)
83
                    M.repo.CommitRunDoc.m.remove({"commit_ids": {"$in": ci_ids}})
84
51
                try:
85
                try:
52
                    if options.all:
86
                    if options.all:
53
                        log.info('Refreshing ALL commits in %r', c.app.repo)
87
                        log.info('Refreshing ALL commits in %r', c.app.repo)
54
                    else:
88
                    else:
55
                        log.info('Refreshing NEW commits in %r', c.app.repo)
89
                        log.info('Refreshing NEW commits in %r', c.app.repo)
...
...
74
            help='Restrict update to projects for which the shortname matches '
108
            help='Restrict update to projects for which the shortname matches '
75
            'the provided regex.')
109
            'the provided regex.')
76
    parser.add_argument('--mount_point', default='', dest='mount_point',
110
    parser.add_argument('--mount_point', default='', dest='mount_point',
77
            help='Restrict update to repos at the given tool mount point. ')
111
            help='Restrict update to repos at the given tool mount point. ')
78
    parser.add_argument('--clean', action='store_true', dest='clean',
112
    parser.add_argument('--clean', action='store_true', dest='clean',
113
            default=False, help='Remove repo-related mongo docs (for '
114
            'project(s) being refreshed only) before doing the refresh.')
115
    parser.add_argument('--clean-all', action='store_true', dest='clean_all',
79
            default=False, help='Remove all repo-related mongo docs before '
116
            default=False, help='Remove ALL repo-related mongo docs before '
80
            'refresh.')
117
            'refresh.')
81
    parser.add_argument('--all', action='store_true', dest='all', default=False,
118
    parser.add_argument('--all', action='store_true', dest='all', default=False,
82
            help='Refresh all commits (not just the ones that are new).')
119
            help='Refresh all commits (not just the ones that are new).')
83
    parser.add_argument('--notify', action='store_true', dest='notify',
120
    parser.add_argument('--notify', action='store_true', dest='notify',
84
            default=False, help='Send email notifications of new commits.')
121
            default=False, help='Send email notifications of new commits.')