25
from olive import delimiter
26
25
from errors import show_bzr_error
28
27
from bzrlib.config import LocationConfig
29
28
import bzrlib.errors as errors
31
from olive.dialog import error_dialog, info_dialog, question_dialog
30
from dialog import error_dialog, info_dialog, question_dialog
32
from history import UrlHistory
34
34
class PushDialog(gtk.Dialog):
35
35
""" New implementation of the Push dialog. """
88
88
self.vbox.show_all()
90
90
# Build location history
91
self._history = UrlHistory(self.branch.get_config(), 'push_history')
91
92
self._build_history()
93
94
def _build_history(self):
94
95
""" Build up the location history. """
95
config = LocationConfig(self.branch.base)
96
history = config.get_user_option('gpush_history')
97
if history is not None:
98
self._combo_model = gtk.ListStore(str)
99
for item in history.split(delimiter):
100
self._combo_model.append([ item ])
101
self._combo.set_model(self._combo_model)
102
self._combo.set_text_column(0)
96
self._combo_model = gtk.ListStore(str)
97
for item in self._history.get_entries():
98
self._combo_model.append([ item ])
99
self._combo.set_model(self._combo_model)
100
self._combo.set_text_column(0)
104
102
location = self.branch.get_push_location()
106
104
self._combo.get_child().set_text(location)
108
def _add_to_history(self, location):
109
""" Add specified location to the history (if not yet added). """
110
config = LocationConfig(self.branch.base)
111
history = config.get_user_option('gpush_history')
113
config.set_user_option('gpush_history', location)
115
h = history.split(delimiter)
116
if location not in h:
118
config.set_user_option('gpush_history', delimiter.join(h))
120
106
def _on_test_clicked(self, widget):
121
107
""" Test button clicked handler. """
127
113
m = _urlRE.match(url)
129
115
proto = m.groupdict()['proto']
130
if (proto == 'sftp') or (proto == 'file') or (proto == 'ftp'):
131
# have write acces (most probably)
116
# FIXME: This should ask the transport or branch rather than
117
# guessing using regular expressions. JRV 20070714
118
if proto in ('sftp', 'file', 'ftp'):
119
# have write access (most probably)
132
120
self._image_test.set_from_stock(gtk.STOCK_YES, 4)
133
121
self._label_test.set_markup(_('<b>Write access is probably available</b>'))
158
146
revs = do_push(self.branch, overwrite=True)
161
self._add_to_history(location)
149
self._history.add_entry(location)
162
150
info_dialog(_('Push successful'),
163
151
_("%d revision(s) pushed.") % revs)