def probe_transport(self, transport): try: external_url = transport.external_url() except errors.InProcessTransport: raise errors.NotBranchError(path=transport.base) scheme = external_url.split(":")[0] if scheme not in self._supported_schemes: raise errors.NotBranchError(path=transport.base) from breezy import urlutils external_url = urlutils.split_segment_parameters(external_url)[0] # Explicitly check for .hg directories here, so we avoid # loading foreign branches through Mercurial. if (external_url.startswith("http:") or external_url.startswith("https:")): if not has_hg_http_smart_server(transport, external_url): raise errors.NotBranchError(path=transport.base) else: if not has_hg_dumb_repository(transport): raise errors.NotBranchError(path=transport.base) lazy_load_mercurial() from mercurial import error as hg_errors import urllib2 from breezy.plugins.hg.dir import HgControlDirFormat format = HgControlDirFormat() try: format.open(transport) except hg_errors.RepoError, e: raise errors.NotBranchError(path=transport.base)
def open(self, transport, _found=False): import subvertpy try: return SvnRemoteAccess(transport, self) except subvertpy.SubversionException, (_, num): if num in (subvertpy.ERR_RA_DAV_REQUEST_FAILED, subvertpy.ERR_RA_DAV_NOT_VCC, subvertpy.ERR_RA_LOCAL_REPOS_OPEN_FAILED): raise errors.NotBranchError(transport.base) if num == subvertpy.ERR_XML_MALFORMED: # This *could* be an indication of an actual corrupt # svn server, but usually it just means a broken # xml page raise errors.NotBranchError(transport.base) raise
def open(self, transport, _create=False, _found=None): """Open this directory. :param _create: create the hg dir on the fly. private to HgControlDirFormat. """ # we dont grok readonly - hg isn't integrated with transport. try: url = transport.external_url() except errors.InProcessTransport: raise errors.NotBranchError(transport.base) url = urlutils.split_segment_parameters(url)[0] try: path = transport.local_abspath('.').encode('utf-8') except errors.NotLocalUrl: path = url.rstrip("/") supports_read_lock = False else: supports_read_lock = True lazy_load_mercurial() import mercurial.hg from breezy.plugins.hg.ui import ui repository = mercurial.hg.repository(ui(), path, create=_create) lock = HgLock(transport, repository, supports_read_lock) return HgDir(repository, transport, lock, self)
def supports_transport(self, transport): try: external_url = transport.external_url() except errors.InProcessTransport: raise errors.NotBranchError(path=transport.base) from breezy.plugins.hg import HgProber scheme = external_url.split(":")[0] if scheme not in HgProber._supported_schemes: return False return True
def import_branch(self, source, stop_revision=None, overwrite=False, name=None, lossy=False): """Create a new branch in this repository, possibly with the specified history, optionally importing revisions. :param source: Source branch :param stop_revision: Tip of new branch :return: Branch object """ from .errors import NotSvnBranchPath from .push import InterToSvnRepository with source.lock_read(): if stop_revision is None: stop_revision = source.last_revision() if stop_revision == NULL_REVISION: return self.create_branch() relpath = self._determine_relpath(name) target_branch_path = relpath.lstrip("/") repos = self.find_repository() with repos.lock_write(): inter = InterToSvnRepository(source.repository, repos) layout = repos.get_layout() try: project = layout.get_branch_project(target_branch_path) except NotSvnBranchPath: raise errors.NotBranchError(target_branch_path) inter.push_new_branch(layout, project, target_branch_path, stop_revision, push_metadata=(not lossy), overwrite=overwrite) return self.open_branch(name)
def probe_transport(klass, transport): if transport.has('_darcs/format'): return DarcsDirFormat() raise errors.NotBranchError(path=transport.base)
lazy_load_mercurial() from mercurial import error as hg_errors import urllib2 from breezy.plugins.hg.dir import HgControlDirFormat format = HgControlDirFormat() try: format.open(transport) except hg_errors.RepoError, e: raise errors.NotBranchError(path=transport.base) except hg_errors.Abort, e: trace.mutter('not a hg branch: %s', e) raise errors.NotBranchError(path=transport.base) except urllib2.HTTPError, e: trace.mutter('not a hg branch: %s', e) raise errors.NotBranchError(path=transport.base) return format @classmethod def known_formats(cls): from breezy.plugins.hg.dir import HgControlDirFormat return [HgControlDirFormat()] ControlDirFormat.register_prober(HgProber) ControlDirFormat._server_probers.insert(0, HgProber) controldir_network_format_registry.register_lazy("hg", "breezy.plugins.hg.dir", "HgControlDirFormat") breezy.controldir.format_registry.register_lazy("hg",
def probe_transport(klass, transport): if transport.has_any(['_darcs/format', '_darcs/inventory']): return DarcsDirFormat() raise errors.NotBranchError(path=transport.base)