/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-27 20:30:59 UTC
  • mto: (0.12.2 olive)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060927203059-85792ae0a81db524
Bunch of small fixes, cleanups and simplifications.

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
 
    
 
24
        
25
25
import gtk
26
26
import gtk.gdk
27
27
import gtk.glade
32
32
 
33
33
class OlivePush:
34
34
    """ Display Push dialog and perform the needed actions. """
35
 
    def __init__(self, branch):
 
35
    def __init__(self, comm):
36
36
        """ Initialize the Push dialog. """
37
37
        self.glade = gtk.glade.XML(gladefile, 'window_push')
38
38
        
 
39
        # Communication object
 
40
        self.comm = comm
 
41
        
39
42
        self.window = self.glade.get_widget('window_push')
40
 
 
41
 
        self.branch = branch
42
43
        
43
44
        # Dictionary for signal_autoconnect
44
45
        dic = { "on_button_push_push_clicked": self.push,
66
67
        self.check_remember.set_sensitive(0)
67
68
        self.check_create.set_sensitive(0)
68
69
        
69
 
        self.entry_stored.set_text(branch.get_push_location())
 
70
        # Get stored location
 
71
        self.notbranch = False
 
72
        try:
 
73
            from bzrlib.branch import Branch
 
74
    
 
75
            branch = Branch.open_containing(self.comm.get_path())[0]
 
76
    
 
77
            self.entry_stored.set_text(branch.get_push_location())
 
78
        except errors.NotBranchError:
 
79
            self.notbranch = True
 
80
            return
70
81
    
71
82
    def display(self):
72
83
        """ Display the Push dialog. """
73
 
        self.window.show()
74
 
        self.width, self.height = self.window.get_size()
 
84
        if self.notbranch:
 
85
            error_dialog(_('Directory is not a branch'),
 
86
                                     _('You can perform this action only in a branch.'))
 
87
            self.close()
 
88
        else:
 
89
            self.window.show()
 
90
            self.width, self.height = self.window.get_size()
75
91
    
76
92
    def stored_toggled(self, widget):
77
93
        if widget.get_active():
99
115
    
100
116
    def push(self, widget):
101
117
        revs = 0
 
118
        self.comm.set_busy(self.window)
102
119
        if self.radio_stored.get_active():
103
120
            try:
104
 
                revs = do_push(self.branch,
 
121
                revs = do_push(self.comm.get_path(),
105
122
                               overwrite=self.check_overwrite.get_active())
106
123
            except errors.NotBranchError:
107
124
                error_dialog(_('Directory is not a branch'),
119
136
                return
120
137
            
121
138
            try:
122
 
                revs = do_push(self.branch, location,
 
139
                revs = do_push(self.comm.get_path(), location,
123
140
                               self.check_remember.get_active(),
124
141
                               self.check_overwrite.get_active(),
125
142
                               self.check_create.get_active())
126
143
            except errors.NotBranchError:
127
144
                error_dialog(_('Directory is not a branch'),
128
145
                                         _('You can perform this action only in a branch.'))
 
146
                self.comm.set_busy(self.window, False)
129
147
                return
130
148
            except errors.DivergedBranches:
131
149
                error_dialog(_('Branches have been diverged'),
132
150
                                         _('You cannot push if branches have diverged. Use the\noverwrite option if you want to push anyway.'))
 
151
                self.comm.set_busy(self.window, False)
133
152
                return
134
153
        
135
154
        self.close()
241
260
    else:
242
261
        old_rh = br_to.revision_history()
243
262
        try:
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
 
 
 
263
            try:
 
264
                tree_to = dir_to.open_workingtree()
 
265
            except errors.NotLocalUrl:
 
266
                # FIXME - what to do here? how should we warn the user?
 
267
                #warning('This transport does not update the working '
 
268
                #        'tree of: %s' % (br_to.base,))
 
269
                count = br_to.pull(br_from, overwrite)
 
270
            except errors.NoWorkingTree:
 
271
                count = br_to.pull(br_from, overwrite)
 
272
            else:
 
273
                count = tree_to.pull(br_from, overwrite)
 
274
        except errors.DivergedBranches:
 
275
            raise
 
276
    
255
277
    return count