/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to push.py

  • Committer: Jelmer Vernooij
  • Date: 2011-03-23 09:49:44 UTC
  • mfrom: (723.1.1 isearch)
  • Revision ID: jelmer@samba.org-20110323094944-7n5h1vif3xpbze3p
Merge support for interactive substring search in bzr viz and annotate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
 
18
 
from gi.repository import GObject
19
 
from gi.repository import Gtk
 
18
try:
 
19
    import pygtk
 
20
    pygtk.require("2.0")
 
21
except:
 
22
    pass
 
23
 
 
24
import gtk
20
25
 
21
26
from errors import show_bzr_error
22
27
 
23
28
import bzrlib.errors as errors
24
29
 
 
30
from bzrlib.plugins.gtk import _i18n
25
31
from bzrlib.plugins.gtk.dialog import (
26
32
    info_dialog,
27
33
    question_dialog,
28
34
    )
29
35
 
30
36
from bzrlib.plugins.gtk.history import UrlHistory
31
 
from bzrlib.plugins.gtk.i18n import _i18n
32
 
 
33
 
 
34
 
class PushDialog(Gtk.Dialog):
35
 
    """New implementation of the Push dialog."""
 
37
 
 
38
class PushDialog(gtk.Dialog):
 
39
    """ New implementation of the Push dialog. """
36
40
 
37
41
    def __init__(self, repository, revid, branch=None, parent=None):
38
 
        """Initialize the Push dialog. """
39
 
        GObject.GObject.__init__(self, title="Push",
 
42
        """ Initialize the Push dialog. """
 
43
        gtk.Dialog.__init__(self, title="Push - Olive",
40
44
                                  parent=parent,
41
45
                                  flags=0,
42
 
                                  buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
 
46
                                  buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
43
47
 
44
48
        # Get arguments
45
49
        self.repository = repository
47
51
        self.branch = branch
48
52
 
49
53
        # Create the widgets
50
 
        self._label_location = Gtk.Label(label=_i18n("Location:"))
51
 
        self._combo = Gtk.ComboBoxEntry()
52
 
        self._button_push = Gtk.Button(_i18n("_Push"), use_underline=True)
53
 
        self._hbox_location = Gtk.HBox()
 
54
        self._label_location = gtk.Label(_i18n("Location:"))
 
55
        self._combo = gtk.ComboBoxEntry()
 
56
        self._button_push = gtk.Button(_i18n("_Push"), use_underline=True)
 
57
        self._hbox_location = gtk.HBox()
54
58
 
55
59
        # Set callbacks
56
60
        self._button_push.connect('clicked', self._on_push_clicked)
63
67
        # Pack widgets
64
68
        self._hbox_location.pack_start(self._label_location, False, False)
65
69
        self._hbox_location.pack_start(self._combo, True, True)
66
 
        self.vbox.pack_start(self._hbox_location, True, True, 0)
 
70
        self.vbox.pack_start(self._hbox_location)
67
71
        self.action_area.pack_end(self._button_push)
68
72
 
69
73
        # Show the dialog
74
78
        self._build_history()
75
79
 
76
80
    def _build_history(self):
77
 
        """Build up the location history. """
78
 
        self._combo_model = Gtk.ListStore(str)
 
81
        """ Build up the location history. """
 
82
        self._combo_model = gtk.ListStore(str)
79
83
        for item in self._history.get_entries():
80
84
            self._combo_model.append([ item ])
81
85
        self._combo.set_model(self._combo_model)
88
92
 
89
93
    @show_bzr_error
90
94
    def _on_push_clicked(self, widget):
91
 
        """Push button clicked handler. """
 
95
        """ Push button clicked handler. """
92
96
        location = self._combo.get_child().get_text()
93
97
        revs = 0
94
98
 
97
101
        except errors.DivergedBranches:
98
102
            response = question_dialog(_i18n('Branches have been diverged'),
99
103
                                       _i18n('You cannot push if branches have diverged.\nOverwrite?'))
100
 
            if response == Gtk.ResponseType.YES:
 
104
            if response == gtk.RESPONSE_YES:
101
105
                revs = do_push(self.branch, location=location, overwrite=True)
102
106
 
103
107
        if self.branch is not None and self.branch.get_push_location() is None:
107
111
        info_dialog(_i18n('Push successful'),
108
112
                    _i18n("%d revision(s) pushed.") % revs)
109
113
 
110
 
        self.response(Gtk.ResponseType.OK)
 
114
        self.response(gtk.RESPONSE_OK)
111
115
 
112
116
 
113
117
def do_push(br_from, location, overwrite):
114
 
    """Update a mirror of a branch.
 
118
    """ Update a mirror of a branch.
115
119
 
116
120
    :param br_from: the source branch
117
121
    :param location: the location of the branch that you'd like to update
138
142
        except errors.NoSuchFile:
139
143
            response = question_dialog(_i18n('Non existing parent directory'),
140
144
                         _i18n("The parent directory (%s)\ndoesn't exist. Create?") % location)
141
 
            if response == Gtk.ResponseType.OK:
 
145
            if response == gtk.RESPONSE_OK:
142
146
                transport.create_prefix()
143
147
            else:
144
148
                return