Beispiel #1
0
def do_push(br_from, location, overwrite):
    """Update a mirror of a branch.

    :param br_from: the source branch
    :param location: the location of the branch that you'd like to update
    :param overwrite: overwrite target location if it diverged
    :return: number of revisions pushed
    """
    revision_id = None
    to_transport = get_transport(location)
    try:
        dir_to = ControlDir.open_from_transport(to_transport)
    except errors.NotBranchError:
        dir_to = None

    if dir_to is None:
        try:
            br_to = br_from.create_clone_on_transport(
                to_transport, revision_id=revision_id)
        except errors.NoSuchFile:
            response = question_dialog(
                _i18n('Non existing parent directory'),
                _i18n("The parent directory (%s)\ndoesn't exist. Create?") %
                    location)
            if response == Gtk.ResponseType.OK:
                br_to = br_from.create_clone_on_transport(
                    to_transport, revision_id=revision_id, create_prefix=True)
            else:
                return _i18n("Push aborted.")
        push_result = create_push_result(br_from, br_to)
    else:
        push_result = dir_to.push_branch(br_from, revision_id, overwrite)
    message = create_push_message(br_from, push_result)
    return message
Beispiel #2
0
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.'))
Beispiel #3
0
    def _on_push_clicked(self, widget):
        """Push button clicked handler. """
        self._push_message.hide()
        self._progress_widget.tick()
        location = self._combo.get_child().get_text()

        try:
            message = do_push(self.branch, location, overwrite=False)
        except errors.DivergedBranches:
            response = question_dialog(
                _i18n('Branches have been diverged'),
                _i18n('You cannot push if branches have diverged.\n'
                      'Overwrite?'))
            if response == Gtk.ResponseType.YES:
                message = do_push(self.branch, location, overwrite=True)
            else:
                return
        self._history.add_entry(location)
        if (self.branch is not None
            and self.branch.get_push_location() is None):
            self.branch.set_push_location(location)
        if message:
            self._progress_widget.finished()
            self._push_message.props.label = message
            self._push_message.show()
Beispiel #4
0
    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)
Beispiel #5
0
def create_push_message(br_from, push_result):
    """Return a mesage explaining what happened during the push."""
    messages = []
    rev_count = br_from.revno() - push_result.old_revno
    messages.append(_i18n("%d revision(s) pushed.") % rev_count)
    if push_result.stacked_on is not None:
        messages.append(_i18n("Stacked on %s.") % push_result.stacked_on)
    if push_result.workingtree_updated is False:
        messages.append(_i18n(
            "\nThe working tree was not updated:"
            "\nSee 'bzr help working-trees' for more information."))
    return '\n'.join(messages)
Beispiel #6
0
    def __init__(self):
        super(SearchBox, self).__init__(homogeneous=False, spacing=6)

        # Close button
        button = Gtk.Button()
        image = Gtk.Image()
        image.set_from_stock('gtk-stop', Gtk.IconSize.BUTTON)
        button.set_image(image)
        button.set_relief(Gtk.ReliefStyle.NONE)
        button.connect("clicked", lambda w: self.hide())
        self.pack_start(button, False, False, 0)

        # Search entry
        label = Gtk.Label()
        self._label = label
        self.pack_start(label, False, False, 0)

        entry = Gtk.Entry()
        self._entry = entry
        entry.connect("activate", lambda w, d: self._do_search(d),
                      'forward')
        self.pack_start(entry, False, False, 0)

        # Next/previous buttons
        button = Gtk.Button(_i18n('_Next'), use_underline=True)
        image = Gtk.Image()
        image.set_from_stock('gtk-go-forward', Gtk.IconSize.BUTTON)
        button.set_image(image)
        button.connect("clicked", lambda w, d: self._do_search(d),
                       'forward')
        self.pack_start(button, False, False, 0)

        button = Gtk.Button(_i18n('_Previous'), use_underline=True)
        image = Gtk.Image()
        image.set_from_stock('gtk-go-back', Gtk.IconSize.BUTTON)
        button.set_image(image)
        button.connect("clicked", lambda w, d: self._do_search(d),
                       'backward')
        self.pack_start(button, False, False, 0)

        # Search options
        check = Gtk.CheckButton('Match case')
        self._match_case = check
        self.pack_start(check, False, False, 0)

        check = Gtk.CheckButton('Regexp')
        check.connect("toggled", lambda w: self._set_label())
        self._regexp = check
        self.pack_start(check, False, False, 0)

        self._view = None
        self._column = None
Beispiel #7
0
    def run(self, filename=None):
        open_display()
        from commit import CommitDialog

        wt = None
        br = None
        try:
            (wt, path) = workingtree.WorkingTree.open_containing(filename)
            br = wt.branch
        except NoWorkingTree, e:
            from dialog import error_dialog
            error_dialog(_i18n('Directory does not have a working tree'),
                         _i18n('Operation aborted.'))
            return 1 # should this be retval=3?
Beispiel #8
0
 def _get_menu_bar(self):
     menubar = Gtk.MenuBar()
     # View menu
     mb_view = Gtk.MenuItem.new_with_mnemonic(_i18n("_View"))
     mb_view_menu = Gtk.Menu()
     mb_view_wrapsource = Gtk.CheckMenuItem.new_with_mnemonic(
         _i18n("Wrap _Long Lines"))
     mb_view_wrapsource.connect('activate', self.diff._on_wraplines_toggled)
     mb_view_menu.append(mb_view_wrapsource)
     mb_view.set_submenu(mb_view_menu)
     menubar.append(mb_view)
     if self.SHOW_WIDGETS:
         menubar.show_all()
     return menubar
Beispiel #9
0
    def __init__(self, tagname, parent):
        super(RemoveTagDialog, self).__init__(
            title="Remove tag", parent=parent, flags=0,
            buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))

        # Get the arguments
        self.tag = tagname

        # Create the widgets
        self._hbox = Gtk.HBox()
        self._vbox_question = Gtk.VBox()
        self._image_question = Gtk.Image.new_from_stock(Gtk.STOCK_DIALOG_QUESTION,
                                                        Gtk.IconSize.DIALOG)
        self._label_title = Gtk.Label()
        self._label_question = Gtk.Label()
        self._button_remove = Gtk.Button(_i18n("_Remove tag"), use_underline=True)

        # Set callbacks
        self._button_remove.connect('clicked', self._on_remove_clicked)

        # Set properties
        self._hbox.set_border_width(5)
        self._hbox.set_spacing(5)
        self._vbox_question.set_spacing(3)

        self._label_title.set_markup(_i18n("<b><big>Remove tag?</big></b>"))
        self._label_title.set_alignment(0.0, 0.5)
        self._label_question.set_markup(_i18n("Are you sure you want to remove the tag: <b>%s</b>?") % self.tag)
        self._label_question.set_alignment(0.0, 0.5)

        self._button_remove.set_image(Gtk.Image.new_from_stock(Gtk.STOCK_REMOVE,
                                                               Gtk.IconSize.BUTTON))
        self._button_remove.set_can_default(True)

        # Construct the dialog
        self._vbox_question.pack_start(self._label_title, True, True, 0)
        self._vbox_question.pack_start(self._label_question, True, True, 0)

        self._hbox.pack_start(self._image_question, True, True, 0)
        self._hbox.pack_start(self._vbox_question, True, True, 0)

        self.get_content_area().add(self._hbox)

        self.action_area.pack_end(self._button_remove, False, False, 0)

        # Display dialog
        self.get_content_area().show_all()

        # Default to Commit button
        self._button_remove.grab_default()
Beispiel #10
0
 def run(self, merge_from_path=None):
     from bzrlib.plugins.gtk.dialog import error_dialog
     from bzrlib.plugins.gtk.merge import MergeDialog
     
     (wt, path) = workingtree.WorkingTree.open_containing('.')
     old_tree = wt.branch.repository.revision_tree(wt.branch.last_revision())
     delta = wt.changes_from(old_tree)
     if len(delta.added) or len(delta.removed) or len(delta.renamed) or len(delta.modified):
         error_dialog(_i18n('There are local changes in the branch'),
                      _i18n('Please commit or revert the changes before merging.'))
     else:
         parent_branch_path = wt.branch.get_parent()
         merge = MergeDialog(wt, path, parent_branch_path)
         response = merge.run()
         merge.destroy()
Beispiel #11
0
 def run(self):
     try:
         loom_branch.require_loom_branch(self.branch)
     except loom_branch.NotALoom:
         response = question_dialog(
             _i18n("Upgrade to Loom branch?"),
             _i18n("Branch is not a loom branch. Upgrade to Loom format?"),
             parent=self)
             # Doesn't set a parent for the dialog..
         if response == Gtk.ResponseType.NO:
             return
         assert self.branch.nick is not None
         loom_branch.loomify(self.branch)
     self._load_threads()
     return super(LoomDialog, self).run()
Beispiel #12
0
    def __init__(self, repository=None, revid=None, branch=None, parent=None):
        """Initialize the Push dialog. """
        super(PushDialog, self).__init__(
            title="Push", parent=parent, flags=0, border_width=6,
            buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE))
        if repository is None:
            repository = branch.repository
        self.branch = branch

        # Unused arguments
        self.repository = repository
        if revid is None:
            revid = branch.last_revision()
        self.revid = revid

        # Create the widgets
        self._label_location = Gtk.Label(label=_i18n("Location:"))
        self._combo = Gtk.ComboBox.new_with_entry()
        self._button_push = Gtk.Button(_i18n("_Push"), use_underline=True)
        self._hbox_location = Gtk.Box(Gtk.Orientation.HORIZONTAL, 6)
        self._push_message = Gtk.Label(xalign=0)
        self._progress_widget = ProgressPanel()

        # Set callbacks
        ui.ui_factory.set_progress_bar_widget(self._progress_widget)
        self.connect('close', self._on_close_clicked)
        self._button_push.connect('clicked', self._on_push_clicked)

        # Set properties
        content_area = self.get_content_area()
        content_area.set_spacing(6)

        # Pack widgets
        self._hbox_location.pack_start(self._label_location, False, False, 0)
        self._hbox_location.pack_start(self._combo, False, False, 0)
        content_area.pack_start(self._hbox_location, True, True, 0)
        content_area.pack_start(self._progress_widget, True, True, 0)
        content_area.pack_start(self._push_message, True, True, 0)
        self.get_action_area().pack_end(self._button_push, True, True, 0)

        # Show the dialog
        content_area.show_all()
        self._progress_widget.hide()
        self._push_message.hide()

        # Build location history
        self._history = UrlHistory(self.branch.get_config(), 'push_history')
        self._build_history()
Beispiel #13
0
    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)
Beispiel #14
0
    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)
Beispiel #15
0
    def __init__(self, branch, parent=None):
        super(RevisionBrowser, self).__init__(
            title="Revision Browser - Olive", parent=parent,
            flags=Gtk.DialogFlags.MODAL,
            buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))

        # Get arguments
        self.branch = branch

        # Create the widgets
        self._button_select = Gtk.Button(_i18n("_Select"), use_underline=True)
        start_revs = [branch.last_revision(),]
        self.treeview = TreeView(branch, start_revs, None)

        # Set callbacks
        self._button_select.connect('clicked', self._on_select_clicked)
        self.treeview.connect('revision-activated',
                               self._on_treeview_revision_activated)

        # Set properties
        self.set_default_size(600, 400)
        self.get_content_area().set_spacing(3)
        self.treeview.set_property('graph-column-visible', False)
        self.treeview.set_property('date-column-visible', True)
        self.treeview.set_property('mainline-only', True)

        # Construct the dialog
        self.action_area.pack_end(self._button_select, False, False, 0)

        self.get_content_area().pack_start(self.treeview, True, True, 0)

        # Show the dialog
        self.show_all()
Beispiel #16
0
    def __init__(self, index, parent=None):
        super(SearchDialog, self).__init__(
            title="Search Revisions", parent=parent,
            flags=Gtk.DialogFlags.MODAL,
            buttons=(Gtk.STOCK_OK, Gtk.ResponseType.OK,
                Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
        pixbuf = self.render_icon_pixbuf(Gtk.STOCK_FIND, Gtk.IconSize.MENU)
        self.set_icon(pixbuf)
        
        # Get arguments
        self.index = index

        self.searchbar = Gtk.HBox()
        searchbar_label = Gtk.Label(label=_i18n("Search for:"))
        self.searchbar.pack_start(searchbar_label, False, False, 0)
        self.searchentry = Gtk.Entry()
        self.searchentry.connect('activate', self._searchentry_activate)
        # TODO: Completion using the bzr-search suggests functionality
        self.searchbar.add(self.searchentry)
        self.get_content_area().pack_start(self.searchbar, False, False, 0)

        self.results_model = Gtk.ListStore(
            GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_PYOBJECT)
        self.results_treeview = Gtk.TreeView(self.results_model)
        self.results_treeview.connect(
            "row-activated", self._searchresult_row_activated)

        documentname_column = Gtk.TreeViewColumn(
            _i18n("Document"), Gtk.CellRendererText(), text=0)
        self.results_treeview.append_column(documentname_column)

        summary_column = Gtk.TreeViewColumn(
            _i18n("Summary"), Gtk.CellRendererText(), text=1)
        self.results_treeview.append_column(summary_column)

        results_scrolledwindow = Gtk.ScrolledWindow()
        results_scrolledwindow.set_policy(
            Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        results_scrolledwindow.add(self.results_treeview)

        self.get_content_area().pack_start(
            results_scrolledwindow, True, True, 0)

        self.set_default_size(600, 400)
        # Show the dialog
        self.show_all()
Beispiel #17
0
 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))
Beispiel #18
0
    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
Beispiel #19
0
    def _load_tags(self):
        """ Load the tags into the TreeView. """
        tvcol_name = Gtk.TreeViewColumn(_i18n("Tag Name"),
                                        Gtk.CellRendererText(),
                                        text=0)
        tvcol_name.set_resizable(True)

        tvcol_revid = Gtk.TreeViewColumn(_i18n("Revision ID"),
                                         Gtk.CellRendererText(),
                                         text=1)
        tvcol_revid.set_resizable(True)

        self._treeview_tags.append_column(tvcol_name)
        self._treeview_tags.append_column(tvcol_revid)

        self._treeview_tags.set_search_column(0)

        self._refresh_tags()
Beispiel #20
0
 def __init__(self, wt, wtpath, default_branch_path=None, parent=None):
     """ Initialize the Merge dialog. """
     super(MergeDialog, self).__init__(
         title="Merge changes", parent=parent, flags=0,
         buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
     self.set_icon_from_file(icon_path("bzr-icon-64.png"))
     # Get arguments
     self.wt = wt
     self.wtpath = wtpath
     self.default_branch_path = default_branch_path
     self.parent_window = parent
     
     # Create widgets
     self._hbox = Gtk.HBox()
     self._source = Gtk.HBox()
     self._label_merge_from = Gtk.Label(label=_i18n("Merge from"))
     self._combo_source = Gtk.ComboBoxText()
     for entry in [_i18n("Folder"),_i18n("Custom Location")]:
         self._combo_source.append_text(entry)
     self._combo_source.connect("changed", self._on_combo_changed)
     self._button_merge = Gtk.Button(_i18n("_Merge"), use_underline=True)
     self._button_merge_icon = Gtk.Image()
     self._button_merge_icon.set_from_stock(Gtk.STOCK_APPLY, Gtk.IconSize.BUTTON)
     self._button_merge.set_image(self._button_merge_icon)
     self._button_merge.connect('clicked', self._on_merge_clicked)
     
     # Add widgets to dialog
     self.get_content_area().pack_start(self._hbox, False, False, 0)
     self._hbox.add(self._label_merge_from)
     self._hbox.add(self._combo_source)
     self._hbox.set_spacing(5)
     self.action_area.pack_end(self._button_merge, False, False, 0)
     
     if self.default_branch_path and os.path.isdir(
                         self.default_branch_path.partition('file://')[2]):
         self.directory = self.default_branch_path.partition('file://')[2]
         self._combo_source.set_active(0)
     elif self.default_branch_path:
         self._combo_source.set_active(1)
     else:
         # If no default_branch_path give, default to folder source with current folder
         self._combo_source.set_active(0)
     self.get_content_area().show_all()
Beispiel #21
0
 def show_spinner(self):
     """
     Replace the current content of the Avatar with a Gtk.Spinner
     if an email address has been parsed. If not, show an Gtk.Label with
     the translatable 'No email' text.
     """
     if self.email:
         tooltip = _i18n("Retrieving avatar for %s...") % self.email
         spinner = Gtk.Spinner()
         spinner.start()
         self.pack_start(spinner, False, True, 0)
         spinner.set_tooltip_text(tooltip)
         spinner.set_size_request(20, 20)
         spinner.show()
     else:
         no_email = Gtk.Label(label=_i18n("No email"))
         self.pack_start(no_email, True, True, 0)
         self.set_tooltip_text(self.apparent_username)
         no_email.show()
Beispiel #22
0
    def __init__(self, repository, revid=None, branch=None, parent=None):
        """ Initialize Add tag dialog. """
        super(AddTagDialog, self).__init__(
            title="Add tag", parent=parent, flags=0,
            buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))

        # Get arguments
        self._repository = repository
        self._revid = revid
        self._branch = branch

        # Create the widgets
        self._button_add = Gtk.Button(_i18n("_Add tag"), use_underline=True)
        self._table = Gtk.Table(2, 2)
        self._label_name = Gtk.Label(label=_i18n("Tag Name:"))
        self._label_revid = Gtk.Label(label=_i18n("Revision ID:"))
        self._entry_name = Gtk.Entry()
        if self._revid is not None:
            self._hbox_revid = Gtk.Label(label=self._revid)
        else:
            self._hbox_revid = RevisionSelectionBox(self._branch)

        # Set callbacks
        self._button_add.connect('clicked', self._on_add_clicked)

        # Set properties
        self._label_name.set_alignment(0, 0.5)
        self._label_revid.set_alignment(0, 0.5)
        self._button_add.set_image(Gtk.Image.new_from_stock(Gtk.STOCK_ADD,
                                                            Gtk.IconSize.BUTTON))
        self._button_add.set_can_default(True)

        # Construct the dialog
        self._table.attach(self._label_name, 0, 1, 0, 1)
        self._table.attach(self._label_revid, 0, 1, 1, 2)
        self._table.attach(self._entry_name, 1, 2, 0, 1)
        self._table.attach(self._hbox_revid, 1, 2, 1, 2)
        self.get_content_area().add(self._table)
        self.action_area.pack_end(self._button_add, False, False, 0)

        # Show the dialog
        self.get_content_area().show_all()
Beispiel #23
0
 def _on_combo_changed(self, widget, event):
     """ We try to get the last revision if focus lost. """
     rev = self._get_last_revno()
     if rev is None:
         self._entry_revision.set_text(_i18n("N/A"))
         self._button_revision.set_sensitive(False)
     else:
         self._entry_revision.set_text(str(rev))
         self._button_revision.set_sensitive(True)
         if self._entry_nick.get_text() == "":
             self._entry_nick.set_text(os.path.basename(self._combo.get_child().get_text().rstrip("/\\")))
Beispiel #24
0
 def _on_branch_changed(self, widget, event):
     """ We try to get the last revision if focus lost. """
     rev = self._get_last_revno()
     if rev is None:
         self._entry_revision.set_text(_i18n('N/A'))
         self._button_revision.set_sensitive(False)
     else:
         self._entry_revision.set_text(str(rev))
         self._button_revision.set_sensitive(True)
         if self._entry_nick.get_text() == '':
             self._entry_nick.set_text(os.path.basename(self._remote_branch.get_url().rstrip("/\\")))
Beispiel #25
0
 def __init__(self, path, parent=None):
     """ Initialize the Initialize dialog. """
     super(InitDialog, self).__init__(
         title="Initialize - Olive", parent=parent, flags=0,
         buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
     
     # Get arguments
     self.path = path
     
     # Create the widgets
     self._button_init = Gtk.Button(_i18n("_Initialize"), use_underline=True)
     self._label_question = Gtk.Label(label=_i18n("Which directory do you want to initialize?"))
     self._radio_current = Gtk.RadioButton.new_with_label(
         None, _i18n("Current directory"))
     self._radio_custom = Gtk.RadioButton.new_with_label_from_widget(
         self._radio_current, _i18n("Create a new directory with the name:"))
     self._entry_custom = Gtk.Entry()
     self._hbox_custom = Gtk.HBox()
     
     # Set callbacks
     self._button_init.connect('clicked', self._on_init_clicked)
     self._radio_custom.connect('toggled', self._on_custom_toggled)
     
     # Set properties
     self._entry_custom.set_sensitive(False)
     
     # Construct the dialog
     self.action_area.pack_end(self._button_init, False, False, 0)
     
     self._hbox_custom.pack_start(self._radio_custom, False, False, 0)
     self._hbox_custom.pack_start(self._entry_custom, True, True, 0)
     
     content_area = self.get_content_area()
     content_area.pack_start(self._label_question, True, True, 0)
     content_area.pack_start(self._radio_current, True, True, 0)
     content_area.pack_start(self._hbox_custom, True, True, 0)
     
     # Display the dialog
     content_area.show_all()
Beispiel #26
0
    def _create_table(self):
        table = Gtk.Table(homogeneous=False, columns=2, rows=3)

        table.attach(Gtk.Label(_i18n('File id:')), 0, 1, 0, 1)
        table.attach(Gtk.Label(self.file_id), 1, 2, 0, 1)

        table.attach(Gtk.Label(_i18n('SHA1Sum:')), 0, 1, 1, 2)
        table.attach(Gtk.Label(self.tree.get_file_sha1(self.file_id, self.path)), 1, 1, 1, 2)

        basis_tree = self.tree.revision_tree(self.tree.last_revision())
        last_revision = basis_tree.get_file_revision(self.file_id)

        table.attach(Gtk.Label(_i18n('Last Change Revision:')), 0, 1, 2, 3)
        revno = ".".join([str(x) for x in
            self.tree.branch.revision_id_to_dotted_revno(last_revision)])
        table.attach(Gtk.Label(revno), 1, 1, 2, 3)

        table.attach(Gtk.Label(_i18n('Last Change Author:')), 0, 1, 3, 4)
        rev = self.tree.branch.repository.get_revision(last_revision)
        table.attach(Gtk.Label("\n".join(rev.get_apparent_authors())), 1, 1, 3, 4)

        table.show_all()
        return table
Beispiel #27
0
 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)
Beispiel #28
0
    def _generate_status(self):
        """ Generate 'bzr status' output. """
        self.model = Gtk.TreeStore(str, str)
        self.treeview.set_headers_visible(False)
        self.treeview.set_model(self.model)
        self.treeview.connect("row-activated", self.row_diff)

        cell = Gtk.CellRendererText()
        cell.set_property("width-chars", 20)
        column = Gtk.TreeViewColumn()
        column.pack_start(cell, True)
        column.add_attribute(cell, "text", 0)
        self.treeview.append_column(column)

        delta = self.wt.changes_from(self.old_tree)

        changes = False

        if len(delta.added):
            changes = True
            titer = self.model.append(None, [ _i18n('Added'), None ])
            for path, id, kind in delta.added:
                self.model.append(titer, [ path, path ])

        if len(delta.removed):
            changes = True
            titer = self.model.append(None, [ _i18n('Removed'), None ])
            for path, id, kind in delta.removed:
                self.model.append(titer, [ path, path ])

        if len(delta.renamed):
            changes = True
            titer = self.model.append(None, [ _i18n('Renamed'), None ])
            for oldpath, newpath, id, kind, text_modified, meta_modified \
                    in delta.renamed:
                self.model.append(titer, [ oldpath, newpath ])

        if len(delta.modified):
            changes = True
            titer = self.model.append(None, [ _i18n('Modified'), None ])
            for path, id, kind, text_modified, meta_modified in delta.modified:
                self.model.append(titer, [ path, path ])

        done_unknown = False
        for path in self.wt.unknowns():
            changes = True
            if not done_unknown:
                titer = self.model.append(None, [ _i18n('Unknown'), None ])
                done_unknown = True
            self.model.append(titer, [ path, path ])

        if not changes:
            self.model.append(None, [ _i18n('No changes.'), None ])

        self.treeview.expand_all()
Beispiel #29
0
    def __init__(self, wt, parent=None):
        """ Initialize the Conflicts dialog. """
        super(ConflictsDialog, self).__init__(
            title="Conflicts - Olive", parent=parent, flags=0,
            buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.CANCEL))

        # Get arguments
        self.wt = wt

        # Create the widgets
        self._scrolledwindow = Gtk.ScrolledWindow()
        self._treeview = Gtk.TreeView()
        self._label_diff3 = Gtk.Label(label=_i18n("External utility:"))
        self._entry_diff3 = Gtk.Entry()
        self._image_diff3 = Gtk.Image()
        self._button_diff3 = Gtk.Button()
        self._hbox_diff3 = Gtk.HBox()

        # Set callbacks
        self._button_diff3.connect('clicked', self._on_diff3_clicked)

        # Set properties
        self._scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC,
                                        Gtk.PolicyType.AUTOMATIC)
        self._image_diff3.set_from_stock(Gtk.STOCK_APPLY, Gtk.IconSize.BUTTON)
        self._button_diff3.set_image(self._image_diff3)
        self._entry_diff3.set_text(self._get_diff3())
        self._hbox_diff3.set_spacing(3)
        content_area = self.get_content_area()
        content_area.set_spacing(3)
        self.set_default_size(400, 300)

        # Construct dialog
        self._hbox_diff3.pack_start(self._label_diff3, False, False, 0)
        self._hbox_diff3.pack_start(self._entry_diff3, True, True, 0)
        self._hbox_diff3.pack_start(self._button_diff3, False, False, 0)
        self._scrolledwindow.add(self._treeview)
        content_area.pack_start(self._scrolledwindow, True, True, 0)
        content_area.pack_start(self._hbox_diff3, False, False, 0)

        # Create the conflict list
        self._create_conflicts()

        # Show the dialog
        content_area.show_all()
Beispiel #30
0
    def _create_table(self):
        table = Gtk.Table(homogeneous=False, columns=2, rows=6)

        self._push_location_entry = self._create_location_entry(
            self.branch.get_push_location, self.branch.set_push_location)
        self._parent_location_entry = self._create_location_entry(
            self.branch.get_parent, self.branch.set_parent)
        self._bound_location_entry = self._create_location_entry(
            self.branch.get_bound_location, self.branch.set_bound_location)
        self._public_location_entry = self._create_location_entry(
            self.branch.get_public_branch, self.branch.set_public_branch)
        self._submit_location_entry = self._create_location_entry(
            self.branch.get_submit_branch, self.branch.set_submit_branch)

        table.attach(Gtk.Label(_i18n('Push location:')), 0, 1, 0, 1)
        table.attach(self._push_location_entry, 1, 2, 0, 1)

        table.attach(Gtk.Label(_i18n('Parent location:')), 0, 1, 1, 2)
        table.attach(self._parent_location_entry, 1, 1, 1, 2)

        table.attach(Gtk.Label(_i18n('Bound location:')), 0, 1, 2, 3)
        table.attach(self._bound_location_entry, 1, 1, 2, 3)

        table.attach(Gtk.Label(_i18n('Public location:')), 0, 1, 3, 4)
        table.attach(self._public_location_entry, 1, 1, 3, 4)

        table.attach(Gtk.Label(_i18n('Submit location:')), 0, 1, 4, 5)
        table.attach(self._submit_location_entry, 1, 1, 4, 5)

        self._append_revisions_only = Gtk.CheckButton(_i18n('Append revisions only'))
        value = self.branch.get_append_revisions_only()
        if value is None:
            value = False
        self._append_revisions_only.set_active(value)
        table.attach(self._append_revisions_only, 0, 2, 5, 6)

        table.show_all()
        return table