~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to scripts/code-import-worker.py

  • Committer: Curtis Hovey
  • Date: 2011-08-21 14:21:06 UTC
  • mto: This revision was merged to the branch mainline in revision 13745.
  • Revision ID: curtis.hovey@canonical.com-20110821142106-x93hajd6iguma8gx
Update test that was enforcing bad grammar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
from bzrlib.transport import get_transport
25
25
 
26
26
from canonical.config import config
 
27
from lp.codehosting import load_optional_plugin
27
28
from lp.codehosting.codeimport.worker import (
28
 
    BzrImportWorker, BzrSvnImportWorker, CSCVSImportWorker,
29
 
    CodeImportBranchOpenPolicy, CodeImportSourceDetails, GitImportWorker,
30
 
    HgImportWorker, get_default_bazaar_branch_store)
31
 
from lp.codehosting.safe_open import AcceptAnythingPolicy
32
 
from lp.services import scripts
33
 
 
34
 
 
35
 
opener_policies = {
36
 
    "anything": AcceptAnythingPolicy(),
37
 
    "default": CodeImportBranchOpenPolicy()
38
 
    }
 
29
    BzrSvnImportWorker, CSCVSImportWorker, CodeImportSourceDetails,
 
30
    GitImportWorker, HgImportWorker, get_default_bazaar_branch_store)
 
31
from canonical.launchpad import scripts
39
32
 
40
33
 
41
34
def force_bzr_to_use_urllib():
43
36
 
44
37
    We want this because pycurl rejects self signed certificates, which
45
38
    prevents a significant number of import branchs from updating.  Also see
46
 
    https://bugs.launchpad.net/bzr/+bug/516222.
 
39
    https://bugs.edge.launchpad.net/bzr/+bug/516222.
47
40
    """
48
41
    from bzrlib.transport import register_lazy_transport
49
42
    register_lazy_transport('http://', 'bzrlib.transport.http._urllib',
57
50
    def __init__(self):
58
51
        parser = OptionParser()
59
52
        scripts.logger_options(parser)
60
 
        parser.add_option(
61
 
            "--access-policy", type="choice", metavar="ACCESS_POLICY",
62
 
            choices=["anything", "default"], default="default",
63
 
            help="Access policy to use when accessing branches to import.")
64
 
        self.options, self.args = parser.parse_args()
65
 
        self.logger = scripts.logger(self.options, 'code-import-worker')
 
53
        options, self.args = parser.parse_args()
 
54
        self.logger = scripts.logger(options, 'code-import-worker')
66
55
 
67
56
    def main(self):
68
57
        force_bzr_to_use_urllib()
69
58
        source_details = CodeImportSourceDetails.fromArguments(self.args)
70
59
        if source_details.rcstype == 'git':
 
60
            load_optional_plugin('git')
71
61
            import_worker_cls = GitImportWorker
72
62
        elif source_details.rcstype == 'bzr-svn':
 
63
            load_optional_plugin('svn')
73
64
            import_worker_cls = BzrSvnImportWorker
74
65
        elif source_details.rcstype == 'hg':
 
66
            load_optional_plugin('hg')
75
67
            import_worker_cls = HgImportWorker
76
 
        elif source_details.rcstype == 'bzr':
77
 
            import_worker_cls = BzrImportWorker
78
68
        elif source_details.rcstype in ['cvs', 'svn']:
79
69
            import_worker_cls = CSCVSImportWorker
80
70
        else:
83
73
        import_worker = import_worker_cls(
84
74
            source_details,
85
75
            get_transport(config.codeimport.foreign_tree_store),
86
 
            get_default_bazaar_branch_store(), self.logger,
87
 
            opener_policies[self.options.access_policy])
 
76
            get_default_bazaar_branch_store(), self.logger)
88
77
        return import_worker.run()
89
78
 
90
79