Exemple #1
0
 def testDoesntSendStackedInfoNotStacked(self):
     # Mirroring a non-stacked branch sends '' as the stacked-on location
     # to the master.
     source_branch = self.make_branch('source-branch', format='1.9')
     protocol_output = StringIO()
     to_mirror = self.makePullerWorker(
         source_branch.base,
         self.get_url('destdir'),
         protocol=PullerWorkerProtocol(protocol_output))
     to_mirror.mirror()
     stacked_on_url = self.getStackedOnUrlFromNetStringOutput(
         protocol_output.getvalue())
     self.assertEqual('', stacked_on_url)
Exemple #2
0
 def testSendsStackedInfo(self):
     # When the puller worker stacks a branch, it reports the stacked on
     # URL to the master.
     base_branch = self.make_branch('base_branch', format='1.9')
     stacked_branch = self.make_branch('stacked-branch', format='1.9')
     protocol_output = StringIO()
     to_mirror = self.makePullerWorker(
         stacked_branch.base,
         self.get_url('destdir'),
         protocol=PullerWorkerProtocol(protocol_output),
         policy=PrearrangedStackedBranchPolicy(base_branch.base))
     to_mirror.mirror()
     stacked_on_url = self.getStackedOnUrlFromNetStringOutput(
         protocol_output.getvalue())
     self.assertEqual(base_branch.base, stacked_on_url)
 def makePullerWorker(self,
                      src_dir=None,
                      dest_dir=None,
                      branch_type=None,
                      default_stacked_on_url=None,
                      protocol=None,
                      policy=None):
     """Anonymous creation method for PullerWorker."""
     if protocol is None:
         protocol = PullerWorkerProtocol(StringIO())
     if branch_type is None:
         if policy is None:
             policy = AcceptAnythingBranchMirrorerPolicy()
         opener = BranchMirrorer(policy, protocol)
     else:
         opener = None
     return PullerWorker(src_dir,
                         dest_dir,
                         branch_id=1,
                         unique_name='foo/bar/baz',
                         branch_type=branch_type,
                         default_stacked_on_url=default_stacked_on_url,
                         protocol=protocol,
                         branch_mirrorer=opener)
Exemple #4
0
    # There is no test for this (it would involve a great number of moving
    # parts) but it has been verified to work on production.  Also see
    # https://bugs.launchpad.net/bzr/+bug/82086
    from bzrlib.transport import register_lazy_transport
    register_lazy_transport('http://', 'bzrlib.transport.http._urllib',
                            'HttpTransport_urllib')
    register_lazy_transport('https://', 'bzrlib.transport.http._urllib',
                            'HttpTransport_urllib')


if __name__ == '__main__':
    parser = OptionParser()
    (options, arguments) = parser.parse_args()
    (source_url, destination_url, branch_id, unique_name, branch_type_name,
     default_stacked_on_url) = arguments

    branch_type = BranchType.items[branch_type_name]
    if branch_type == BranchType.IMPORTED and 'http_proxy' in os.environ:
        del os.environ['http_proxy']
    section_name = 'supermirror_%s_puller' % branch_type_map[branch_type]
    globalErrorUtility.configure(section_name)
    shut_up_deprecation_warning()
    force_bzr_to_use_urllib()

    resource.setrlimit(resource.RLIMIT_AS, (1500000000, 1500000000))

    protocol = PullerWorkerProtocol(sys.stdout)
    install_worker_ui_factory(protocol)
    PullerWorker(source_url, destination_url, int(branch_id), unique_name,
                 branch_type, default_stacked_on_url, protocol).mirror()
Exemple #5
0
 def setUp(self):
     TestCaseInTempDir.setUp(self)
     self.output = StringIO()
     self.protocol = PullerWorkerProtocol(self.output)
     self.factory = ObjectFactory()