/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 olive/push.py

  • Committer: Jelmer Vernooij
  • Date: 2007-02-01 15:50:40 UTC
  • Revision ID: jelmer@samba.org-20070201155040-3hq4mfbxs99kzazy
add framework for tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
import sys
18
 
 
19
17
try:
20
18
    import pygtk
21
19
    pygtk.require("2.0")
28
26
 
29
27
import bzrlib.errors as errors
30
28
 
31
 
from olive import gladefile
 
29
from dialog import error_dialog, info_dialog
 
30
from guifiles import GLADEFILENAME
 
31
 
32
32
 
33
33
class OlivePush:
34
34
    """ Display Push dialog and perform the needed actions. """
35
35
    def __init__(self, branch):
36
36
        """ Initialize the Push dialog. """
37
 
        self.glade = gtk.glade.XML(gladefile, 'window_push')
 
37
        self.glade = gtk.glade.XML(GLADEFILENAME, 'window_push')
38
38
        
39
39
        self.window = self.glade.get_widget('window_push')
40
40
 
66
66
        self.check_remember.set_sensitive(0)
67
67
        self.check_create.set_sensitive(0)
68
68
        
69
 
        self.entry_stored.set_text(branch.get_push_location())
 
69
        self.entry_stored.set_text(branch.get_push_location() or '')
70
70
    
71
71
    def display(self):
72
72
        """ Display the Push dialog. """
103
103
            try:
104
104
                revs = do_push(self.branch,
105
105
                               overwrite=self.check_overwrite.get_active())
106
 
            except errors.NotBranchError:
107
 
                error_dialog(_('Directory is not a branch'),
108
 
                                         _('You can perform this action only in a branch.'))
109
 
                return
110
106
            except errors.DivergedBranches:
111
 
                error_dialog(_('Branches have been diverged'),
112
 
                                         _('You cannot push if branches have diverged. Use the\noverwrite option if you want to push anyway.'))
 
107
                response = question_dialog(_('Branches have been diverged'),
 
108
                             _('You cannot push if branches have diverged. \nOverwrite?'))
 
109
                if response == gtk.RESPONSE_OK:
 
110
                    revs = do_push(self.branch, overwrite=True)
113
111
                return
114
112
        elif self.radio_specific.get_active():
115
113
            location = self.entry_location.get_text()
116
114
            if location == '':
117
115
                error_dialog(_('No location specified'),
118
 
                                         _('Please specify a location or use the default.'))
 
116
                             _('Please specify a location or use the default.'))
119
117
                return
120
118
            
121
119
            try:
122
120
                revs = do_push(self.branch, location,
123
121
                               self.check_remember.get_active(),
124
 
                               self.check_overwrite.get_active(),
 
122
                               False,
125
123
                               self.check_create.get_active())
126
 
            except errors.NotBranchError:
127
 
                error_dialog(_('Directory is not a branch'),
128
 
                                         _('You can perform this action only in a branch.'))
129
 
                return
130
124
            except errors.DivergedBranches:
131
 
                error_dialog(_('Branches have been diverged'),
132
 
                                         _('You cannot push if branches have diverged. Use the\noverwrite option if you want to push anyway.'))
133
 
                return
 
125
                response = question_dialog(_('Branches have been diverged'),
 
126
                             _('You cannot push if branches have diverged. \nOverwrite?'))
 
127
                if response == gtk.RESPONSE_OK:
 
128
                    revs = do_push(self.branch, location,
 
129
                        self.check_remember.get_active(),
 
130
                            True,
 
131
                            self.check_create.get_active())
 
132
                else:
 
133
                    return
134
134
        
135
135
        self.close()
136
136
        info_dialog(_('Push successful'),
137
 
                                _('%d revision(s) pushed.') % revs)
 
137
                    _('%d revision(s) pushed.') % revs)
138
138
    
139
139
    def test(self, widget):
140
140
        """ Test if write access possible. """
185
185
    from bzrlib.bzrdir import BzrDir
186
186
    from bzrlib.transport import get_transport
187
187
        
188
 
    br_from = Branch.open_containing(branch)[0]
 
188
    br_from = branch
189
189
    
190
190
    stored_loc = br_from.get_push_location()
191
191
    if location is None:
192
192
        if stored_loc is None:
193
193
            error_dialog(_('Push location is unknown'),
194
 
                                     _('Please specify a location manually.'))
 
194
                         _('Please specify a location manually.'))
195
195
            return
196
196
        else:
197
197
            location = stored_loc
216
216
                transport.mkdir(relurl)
217
217
            except errors.NoSuchFile:
218
218
                error_dialog(_('Non existing parent directory'),
219
 
                                         _("The parent directory (%s)\ndoesn't exist.") % location)
 
219
                             _("The parent directory (%s)\ndoesn't exist.") % location)
220
220
                return
221
221
        else:
222
222
            current = transport.base
232
232
                                   new_transport.relpath(transport.base)))
233
233
                    if new_transport.base == transport.base:
234
234
                        error_dialog(_('Path prefix not created'),
235
 
                                                 _("The path leading up to the specified location couldn't\nbe created."))
 
235
                                     _("The path leading up to the specified location couldn't\nbe created."))
236
236
                        return
237
237
        dir_to = br_from.bzrdir.clone(location_url,
238
238
            revision_id=br_from.last_revision())