def initialize_on_transport(self, transport): """See ControlDir.initialize_on_transport().""" from . import lazy_check_versions lazy_check_versions() from breezy.transport.local import LocalTransport import os import subvertpy from subvertpy import repos ERR_REPOS_BAD_ARGS = getattr(subvertpy, "ERR_REPOS_BAD_ARGS", 165002) # For subvertpy < 0.8.6 if not isinstance(transport, LocalTransport): raise UninitializableOnRemoteTransports(self) local_path = transport.local_abspath(".").rstrip("/").encode( osutils._fs_enc) assert type(local_path) == str try: repos.create(local_path) except subvertpy.SubversionException, (_, num): if num == subvertpy.ERR_DIR_NOT_EMPTY: raise errors.BzrError("Directory is not empty") if num == ERR_REPOS_BAD_ARGS: raise errors.AlreadyControlDirError(local_path) raise
def initialize_on_transport(self, transport): """See ControlDir.initialize_on_transport().""" from . import lazy_check_versions lazy_check_versions() from breezy.transport.local import LocalTransport import os import subvertpy from subvertpy import repos # For subvertpy < 0.8.6 ERR_REPOS_BAD_ARGS = getattr(subvertpy, "ERR_REPOS_BAD_ARGS", 165002) if not isinstance(transport, LocalTransport): raise UninitializableOnRemoteTransports(self) local_path = transport.local_abspath(".").rstrip("/").encode( osutils._fs_enc) try: repos.create(local_path) except subvertpy.SubversionException as e: if e.args[1] == subvertpy.ERR_DIR_NOT_EMPTY: raise errors.BzrError("Directory is not empty") if e.args[1] == ERR_REPOS_BAD_ARGS: raise errors.AlreadyControlDirError(local_path) raise # All revision property changes revprop_hook = os.path.join(local_path, b"hooks", b"pre-revprop-change") open(revprop_hook, 'w').write("#!/bin/sh") os.chmod(revprop_hook, os.stat(revprop_hook).st_mode | 0o111) return self.open(transport, _found=True)
def from_objects(cls, repository, revision_id, time, timezone, target_branch, local_target_branch=None, public_branch=None, message=None): from breezy.plugins.svn.repository import SvnRepository submit_branch = _mod_branch.Branch.open(target_branch) if not isinstance(submit_branch.repository, SvnRepository): raise errors.BzrError("Not a Subversion repository") submit_branch.lock_read() try: submit_revision_id = submit_branch.last_revision() repository.fetch(submit_branch.repository, submit_revision_id) graph = repository.get_graph() ancestor_id = graph.find_unique_lca(revision_id, submit_revision_id) patch = cls._generate_diff(repository, submit_branch.repository, revision_id, ancestor_id) finally: submit_branch.unlock() return cls(revision_id, None, time, timezone, target_branch, patch, None, public_branch, message)
def check_pysqlite_version(sqlite3): """Check that sqlite library is compatible. """ if (sqlite3.sqlite_version_info[0] < 3 or (sqlite3.sqlite_version_info[0] == 3 and sqlite3.sqlite_version_info[1] < 3)): trace.warning('Needs at least sqlite 3.3.x') raise errors.BzrError("incompatible sqlite library")
def _revision_identifier(self): """What revision did the user select? :return: None for the last revision. Otherwise the revision identifier as a string. """ if self.other_radio.isChecked(): result = str(self.other_revision.text()) if result: return result else: msg = gettext("No other revision specified.") raise errors.BzrError(msg) # Default is the tip revision return None
def set_default_stack_on(self, value): raise errors.BzrError("Cannot set configuration")
def __init__(self, branch, controldir, location, ui_mode = None): super(QBzrSwitchWindow, self).__init__( gettext("Switch"), name = "switch", default_size = (400, 400), ui_mode = ui_mode, dialog = True, parent = None, hide_progress=False, ) self.branch = branch gbSwitch = QtWidgets.QGroupBox(gettext("Switch checkout"), self) switch_box = QtWidgets.QFormLayout(gbSwitch) branchbase = None boundloc = branch.get_bound_location() if boundloc is not None: label = gettext("Heavyweight checkout:") branchbase = branch.base else: if controldir.root_transport.base != branch.controldir.root_transport.base: label = gettext("Lightweight checkout:") boundloc = branch.controldir.root_transport.base branchbase = controldir.root_transport.base else: raise errors.BzrError("This branch is not checkout.") switch_box.addRow(label, QtWidgets.QLabel(url_for_display(branchbase))) switch_box.addRow(gettext("Checkout of branch:"), QtWidgets.QLabel(url_for_display(boundloc))) self.boundloc = url_for_display(boundloc) throb_hbox = QtWidgets.QHBoxLayout() self.throbber = ThrobberWidget(self) throb_hbox.addWidget(self.throbber) self.throbber.hide() switch_box.addRow(throb_hbox) switch_hbox = QtWidgets.QHBoxLayout() branch_label = QtWidgets.QLabel(gettext("Switch to branch:")) branch_combo = QtWidgets.QComboBox() branch_combo.setEditable(True) self.branch_combo = branch_combo if location is not None: branch_combo.addItem(osutils.abspath(location)) elif boundloc is not None: branch_combo.addItem(url_for_display(boundloc)) browse_button = QtWidgets.QPushButton(gettext("Browse")) browse_button.clicked[bool].connect(self.browse_clicked) switch_hbox.addWidget(branch_label) switch_hbox.addWidget(branch_combo) switch_hbox.addWidget(browse_button) switch_hbox.setStretchFactor(branch_label,0) switch_hbox.setStretchFactor(branch_combo,1) switch_hbox.setStretchFactor(browse_button,0) switch_box.addRow(switch_hbox) create_branch_box = QtWidgets.QCheckBox(gettext("Create Branch before switching")) create_branch_box.setChecked(False) switch_box.addRow(create_branch_box) self.create_branch_box = create_branch_box layout = QtWidgets.QVBoxLayout(self) layout.addWidget(gbSwitch) layout.addWidget(self.make_default_status_box()) layout.addWidget(self.buttonbox) self.branch_combo.setFocus()
and sqlite3.sqlite_version_info[1] < 3)): trace.warning('Needs at least sqlite 3.3.x') raise errors.BzrError("incompatible sqlite library") try: try: import sqlite3 check_pysqlite_version(sqlite3) except (ImportError, errors.BzrError) as e: from pysqlite2 import dbapi2 as sqlite3 check_pysqlite_version(sqlite3) except: trace.warning('Needs at least Python2.5 or Python2.4 with the pysqlite2 ' 'module') raise errors.BzrError("missing sqlite library") def _connect_sqlite3_file(path): return sqlite3.connect(path, timeout=20.0, isolation_level=None) connect_cachefile = _connect_sqlite3_file class CacheTable(object): """Simple base class for SQLite-based caches.""" def __init__(self, cache_db=None): if cache_db is None: self.cachedb = sqlite3.connect(":memory:") else:
def test_generic_BzrError(self): self.assertTranslationEqual((b'error', b'BzrError', b"some text"), errors.BzrError(msg="some text"))