/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: 2006-09-30 10:21:43 UTC
  • Revision ID: jelmer@samba.org-20060930102143-c0ef64d6ca860c21
Merge some files from Olive and bzr-gtk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    pygtk.require("2.0")
22
22
except:
23
23
    pass
24
 
try:
25
 
    import gtk
26
 
    import gtk.gdk
27
 
    import gtk.glade
28
 
except:
29
 
    sys.exit(1)
 
24
    
 
25
import gtk
 
26
import gtk.gdk
 
27
import gtk.glade
30
28
 
31
29
import bzrlib.errors as errors
32
30
 
 
31
from olive import gladefile
 
32
 
33
33
class OlivePush:
34
34
    """ Display Push dialog and perform the needed actions. """
35
 
    def __init__(self, gladefile, comm):
 
35
    def __init__(self, branch):
36
36
        """ Initialize the Push dialog. """
37
 
        self.gladefile = gladefile
38
 
        self.glade = gtk.glade.XML(self.gladefile, 'window_push')
39
 
        
40
 
        # Communication object
41
 
        self.comm = comm
 
37
        self.glade = gtk.glade.XML(gladefile, 'window_push')
42
38
        
43
39
        self.window = self.glade.get_widget('window_push')
 
40
 
 
41
        self.branch = branch
44
42
        
45
43
        # Dictionary for signal_autoconnect
46
44
        dic = { "on_button_push_push_clicked": self.push,
68
66
        self.check_remember.set_sensitive(0)
69
67
        self.check_create.set_sensitive(0)
70
68
        
71
 
        # Get stored location
72
 
        self.notbranch = False
73
 
        try:
74
 
            from bzrlib.branch import Branch
75
 
    
76
 
            branch = Branch.open_containing(self.comm.get_path())[0]
77
 
    
78
 
            self.entry_stored.set_text(branch.get_push_location())
79
 
        except errors.NotBranchError:
80
 
            self.notbranch = True
81
 
            return
 
69
        self.entry_stored.set_text(branch.get_push_location())
82
70
    
83
71
    def display(self):
84
72
        """ Display the Push dialog. """
85
 
        if self.notbranch:
86
 
            error_dialog(_('Directory is not a branch'),
87
 
                                     _('You can perform this action only in a branch.'))
88
 
            self.close()
89
 
        else:
90
 
            self.window.show()
91
 
            self.width, self.height = self.window.get_size()
 
73
        self.window.show()
 
74
        self.width, self.height = self.window.get_size()
92
75
    
93
76
    def stored_toggled(self, widget):
94
77
        if widget.get_active():
116
99
    
117
100
    def push(self, widget):
118
101
        revs = 0
119
 
        self.comm.set_busy(self.window)
120
102
        if self.radio_stored.get_active():
121
103
            try:
122
 
                revs = do_push(self.comm.get_path(),
 
104
                revs = do_push(self.branch,
123
105
                               overwrite=self.check_overwrite.get_active())
124
106
            except errors.NotBranchError:
125
107
                error_dialog(_('Directory is not a branch'),
129
111
                error_dialog(_('Branches have been diverged'),
130
112
                                         _('You cannot push if branches have diverged. Use the\noverwrite option if you want to push anyway.'))
131
113
                return
132
 
            except:
133
 
                raise
134
114
        elif self.radio_specific.get_active():
135
115
            location = self.entry_location.get_text()
136
116
            if location == '':
139
119
                return
140
120
            
141
121
            try:
142
 
                revs = do_push(self.comm.get_path(), location,
 
122
                revs = do_push(self.branch, location,
143
123
                               self.check_remember.get_active(),
144
124
                               self.check_overwrite.get_active(),
145
125
                               self.check_create.get_active())
146
126
            except errors.NotBranchError:
147
127
                error_dialog(_('Directory is not a branch'),
148
128
                                         _('You can perform this action only in a branch.'))
149
 
                self.comm.set_busy(self.window, False)
150
129
                return
151
130
            except errors.DivergedBranches:
152
131
                error_dialog(_('Branches have been diverged'),
153
132
                                         _('You cannot push if branches have diverged. Use the\noverwrite option if you want to push anyway.'))
154
 
                self.comm.set_busy(self.window, False)
155
133
                return
156
 
            except:
157
 
                raise
158
 
        else:
159
 
            # This should really never happen
160
 
            pass
161
134
        
162
135
        self.close()
163
136
        info_dialog(_('Push successful'),
268
241
    else:
269
242
        old_rh = br_to.revision_history()
270
243
        try:
271
 
            try:
272
 
                tree_to = dir_to.open_workingtree()
273
 
            except errors.NotLocalUrl:
274
 
                # FIXME - what to do here? how should we warn the user?
275
 
                #warning('This transport does not update the working '
276
 
                #        'tree of: %s' % (br_to.base,))
277
 
                count = br_to.pull(br_from, overwrite)
278
 
            except errors.NoWorkingTree:
279
 
                count = br_to.pull(br_from, overwrite)
280
 
            else:
281
 
                count = tree_to.pull(br_from, overwrite)
282
 
        except errors.DivergedBranches:
283
 
            raise
284
 
    
 
244
            tree_to = dir_to.open_workingtree()
 
245
        except errors.NotLocalUrl:
 
246
            # FIXME - what to do here? how should we warn the user?
 
247
            #warning('This transport does not update the working '
 
248
            #        'tree of: %s' % (br_to.base,))
 
249
            count = br_to.pull(br_from, overwrite)
 
250
        except errors.NoWorkingTree:
 
251
            count = br_to.pull(br_from, overwrite)
 
252
        else:
 
253
            count = tree_to.pull(br_from, overwrite)
 
254
 
285
255
    return count