def show_bzr_error(unbound): """Decorator that shows bazaar exceptions. """ def convert(*args, **kwargs): try: unbound(*args, **kwargs) except errors.NotBranchError: error_dialog(_i18n('Directory is not a branch'), _i18n('You can perform this action only in a branch.')) except errors.LocalRequiresBoundBranch: error_dialog(_i18n('Directory is not a checkout'), _i18n('You can perform local commit only on checkouts.')) except errors.PointlessCommit: error_dialog(_i18n('No changes to commit'), _i18n('Try force commit if you want to commit anyway.')) except errors.PointlessMerge: info_dialog(_i18n('No changes to merge'), _i18n('Merge location is already fully merged in working tree.')) except errors.ConflictsInTree: error_dialog(_i18n('Conflicts in tree'), _i18n('You need to resolve the conflicts before committing.')) except errors.StrictCommitFailed: error_dialog(_i18n('Strict commit failed'), _i18n('There are unknown files in the working tree.\nPlease add or delete them.')) except errors.BoundBranchOutOfDate, errmsg: error_dialog(_i18n('Bound branch is out of date'), # FIXME: Really ? Internationalizing %s ?? --vila080505 _i18n('%s') % errmsg) except errors.NotVersionedError: error_dialog(_i18n('File not versioned'), _i18n('The selected file is not versioned.'))
def _on_checkout_clicked(self, button): """ Checkout button clicked handler. """ location = self._combo.get_child().get_text() if location is "": error_dialog(_i18n("Missing branch location"), _i18n("You must specify a branch location.")) return destination = self._filechooser.get_filename() try: revno = int(self._entry_revision.get_text()) except: revno = None nick = self._entry_nick.get_text() if nick is "": nick = os.path.basename(location.rstrip("/\\")) br_from = Branch.open(location) revision_id = br_from.get_rev_id(revno) lightweight = self._check_lightweight.get_active() to_location = destination + os.sep + nick os.mkdir(to_location) br_from.create_checkout(to_location, revision_id, lightweight) self._history.add_entry(location) self.response(Gtk.ResponseType.OK)
def _on_branch_clicked(self, button): """ Branch button clicked handler. """ location = self._remote_branch.get_url() if location is '': error_dialog(_i18n('Missing branch location'), _i18n('You must specify a branch location.')) return destination = self._filechooser.get_filename() try: revno = int(self._entry_revision.get_text()) except: revno = None nick = self._entry_nick.get_text() if nick is '': nick = os.path.basename(location.rstrip("/\\")) br_from = Branch.open(location) br_from.lock_read() try: revision_id = br_from.get_rev_id(revno) basis_dir = None to_location = destination + os.sep + nick to_transport = get_transport(to_location) to_transport.mkdir('.') try: # preserve whatever source format we have. dir = br_from.bzrdir.sprout(to_transport.base, revision_id, basis_dir) branch = dir.open_branch() revs = branch.revno() except errors.NoSuchRevision: to_transport.delete_tree('.') raise finally: br_from.unlock() info_dialog(_i18n('Branching successful'), _i18n('%d revision(s) branched.') % revs) self.response(Gtk.ResponseType.OK)
def _on_add_clicked(self, widget): """ Add button clicked handler. """ if len(self._entry_name.get_text()) == 0: error_dialog(_i18n("No tag name specified"), _i18n("You have to specify the tag's desired name.")) return if self._revid is None: if self._hbox_revid.get_revision_id() is None: self._revid = self._branch.last_revision() else: self._revid = self._hbox_revid.get_revision_id() self.tagname = self._entry_name.get_text() self.response(Gtk.ResponseType.OK)
def _on_diff3_clicked(self, widget): """ Launch external utility to resolve conflicts. """ self._set_diff3(self._entry_diff3.get_text()) selected = self._get_selected_file() if selected is None: error_dialog(_i18n('No file was selected'), _i18n('Please select a file from the list.')) return elif self._get_selected_type() == 'text conflict': base = self.wt.abspath(selected) + '.BASE' this = self.wt.abspath(selected) + '.THIS' other = self.wt.abspath(selected) + '.OTHER' try: p = subprocess.Popen([ self._entry_diff3.get_text(), base, this, other ]) p.wait() except OSError, e: warning_dialog(_i18n('Call to external utility failed'), str(e))
def _on_merge_clicked(self, widget): merge_source = self._combo_source.get_active() if merge_source == 0: branch = self._filechooser.get_filename() elif merge_source == 1: branch = self._custom_entry.get_text() if branch == "": error_dialog(_i18n('Branch not given'), _i18n('Please specify a branch to merge from.')) return other_branch = Branch.open_containing(branch)[0] try: conflicts = self.wt.merge_from_branch(other_branch) except errors.BzrCommandError, errmsg: error_dialog(_i18n('Bazaar command error'), str(errmsg)) return
def _on_init_clicked(self, widget): if self._radio_custom.get_active() and len(self._entry_custom.get_text()) == 0: error_dialog(_i18n("Directory name not specified"), _i18n("You should specify a new directory name.")) return if self._radio_current.get_active(): location = self.path else: location = self.path + os.sep + self._entry_custom.get_text() format = bzrdir.format_registry.make_bzrdir('default') to_transport = transport.get_transport(location) try: to_transport.mkdir('.') except errors.FileExists: pass try: existing_bzrdir = bzrdir.BzrDir.open(location) except errors.NotBranchError: branch = bzrdir.BzrDir.create_branch_convenience(to_transport.base, format=format) else: from bzrlib.transport.local import LocalTransport if existing_bzrdir.has_branch(): if (isinstance(to_transport, LocalTransport) and not existing_bzrdir.has_workingtree()): raise errors.BranchExistsWithoutWorkingTree(location) raise errors.AlreadyBranchError(location) else: branch = existing_bzrdir.create_branch() existing_bzrdir.create_workingtree() self.response(Gtk.ResponseType.OK)
def _handle_error(self, e): error_dialog('Error', str(e))
_i18n('Merge location is already fully merged in working tree.')) except errors.ConflictsInTree: error_dialog(_i18n('Conflicts in tree'), _i18n('You need to resolve the conflicts before committing.')) except errors.StrictCommitFailed: error_dialog(_i18n('Strict commit failed'), _i18n('There are unknown files in the working tree.\nPlease add or delete them.')) except errors.BoundBranchOutOfDate, errmsg: error_dialog(_i18n('Bound branch is out of date'), # FIXME: Really ? Internationalizing %s ?? --vila080505 _i18n('%s') % errmsg) except errors.NotVersionedError: error_dialog(_i18n('File not versioned'), _i18n('The selected file is not versioned.')) except errors.DivergedBranches: error_dialog(_i18n('Branches have been diverged'), _i18n('You cannot push if branches have diverged. Use the\noverwrite option if you want to push anyway.')) except errors.NoSuchFile: error_dialog(_i18n("No diff output"), _i18n("The selected file hasn't changed.")) except errors.NoSuchRevision: error_dialog(_i18n('No such revision'), _i18n("The revision you specified doesn't exist.")) except errors.FileExists: error_dialog(_i18n('Target already exists'), _i18n("Target directory already exists. Please select another target.")) except errors.AlreadyBranchError, errmsg: error_dialog(_i18n('Directory is already a branch'), _i18n('The current directory (%s) is already a branch.\nYou can start using it, or initialize another directory.') % errmsg) except errors.BranchExistsWithoutWorkingTree, errmsg: error_dialog(_i18n('Branch without a working tree'), _i18n('The current directory (%s)\nis a branch without a working tree.') % errmsg)