/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:
26
26
 
27
27
import bzrlib.errors as errors
28
28
 
29
 
from olive import gladefile
30
29
from dialog import error_dialog, info_dialog
 
30
from guifiles import GLADEFILENAME
 
31
 
31
32
 
32
33
class OlivePush:
33
34
    """ Display Push dialog and perform the needed actions. """
34
35
    def __init__(self, branch):
35
36
        """ Initialize the Push dialog. """
36
 
        self.glade = gtk.glade.XML(gladefile, 'window_push')
 
37
        self.glade = gtk.glade.XML(GLADEFILENAME, 'window_push')
37
38
        
38
39
        self.window = self.glade.get_widget('window_push')
39
40
 
65
66
        self.check_remember.set_sensitive(0)
66
67
        self.check_create.set_sensitive(0)
67
68
        
68
 
        self.entry_stored.set_text(branch.get_push_location())
 
69
        self.entry_stored.set_text(branch.get_push_location() or '')
69
70
    
70
71
    def display(self):
71
72
        """ Display the Push dialog. """
102
103
            try:
103
104
                revs = do_push(self.branch,
104
105
                               overwrite=self.check_overwrite.get_active())
105
 
            except errors.NotBranchError:
106
 
                error_dialog(_('Directory is not a branch'),
107
 
                             _('You can perform this action only in a branch.'))
108
 
                return
109
106
            except errors.DivergedBranches:
110
 
                error_dialog(_('Branches have been diverged'),
111
 
                             _('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)
112
111
                return
113
112
        elif self.radio_specific.get_active():
114
113
            location = self.entry_location.get_text()
120
119
            try:
121
120
                revs = do_push(self.branch, location,
122
121
                               self.check_remember.get_active(),
123
 
                               self.check_overwrite.get_active(),
 
122
                               False,
124
123
                               self.check_create.get_active())
125
 
            except errors.NotBranchError:
126
 
                error_dialog(_('Directory is not a branch'),
127
 
                             _('You can perform this action only in a branch.'))
128
 
                return
129
124
            except errors.DivergedBranches:
130
 
                error_dialog(_('Branches have been diverged'),
131
 
                             _('You cannot push if branches have diverged. Use the\noverwrite option if you want to push anyway.'))
132
 
                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
133
134
        
134
135
        self.close()
135
136
        info_dialog(_('Push successful'),
184
185
    from bzrlib.bzrdir import BzrDir
185
186
    from bzrlib.transport import get_transport
186
187
        
187
 
    br_from = Branch.open_containing(branch)[0]
 
188
    br_from = branch
188
189
    
189
190
    stored_loc = br_from.get_push_location()
190
191
    if location is None:
191
192
        if stored_loc is None:
192
193
            error_dialog(_('Push location is unknown'),
193
 
                                     _('Please specify a location manually.'))
 
194
                         _('Please specify a location manually.'))
194
195
            return
195
196
        else:
196
197
            location = stored_loc