37
37
NoRepositoryPresent,
41
from bzrlib.transport import get_transport
42
from bzrlib.transport import (
43
do_catching_redirections,
42
46
from bzrlib.upgrade import upgrade
44
48
from bzrlib.urlutils import (
675
679
:param url: URL to open
676
680
:return: ControlDir instance
682
def redirected(transport, e, redirection_notice):
683
self._opener_policy.checkOneURL(e.target)
684
redirected_transport = transport._redirected_to(e.source, e.target)
685
if redirected_transport is None:
686
raise NotBranchError(e.source)
687
self._logger.info('%s is%s redirected to %s',
688
transport.base, e.permanently, redirected_transport.base)
689
return redirected_transport
690
def find_format(transport):
692
for prober_kls in self.probers:
693
prober = prober_kls()
695
return transport, prober.probe_transport(transport)
696
except NotBranchError, e:
678
700
transport = get_transport(url)
679
for prober_kls in self.probers:
680
prober = prober_kls()
682
format = prober.probe_transport(transport)
683
except NotBranchError:
686
return format.open(transport)
688
raise NotBranchError("Not a valid branch")
701
transport, format = do_catching_redirections(find_format, transport,
703
return format.open(transport)
690
705
def _doImport(self):
691
706
self._logger.info("Starting job.")
700
715
remote_branch = opener.open(
701
716
self.source_details.url, self._open_dir)
717
except TooManyRedirections:
718
self._logger.info("Too many redirections.")
719
return CodeImportWorkerExitCode.FAILURE_INVALID
702
720
except NotBranchError:
703
721
self._logger.info("No branch found at remote location.")
704
722
return CodeImportWorkerExitCode.FAILURE_INVALID