/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: Szilveszter Farkas (Phanatic)
  • Date: 2006-09-25 02:15:59 UTC
  • mto: (0.14.1 main)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060925021559-43c540369d728e63
Fix Push functionality.

Show diffs side-by-side

added added

removed removed

Lines of Context:
122
122
        if self.radio_stored.get_active():
123
123
            try:
124
124
                revs = do_push(self.comm.get_path(),
125
 
                                   overwrite=self.check_overwrite.get_active())
 
125
                               overwrite=self.check_overwrite.get_active())
126
126
            except errors.NotBranchError:
127
127
                self.dialog.error_dialog(_('Directory is not a branch'),
128
128
                                         _('You can perform this action only in a branch.'))
129
129
                return
130
 
            except errors.NoLocationKnown:
131
 
                self.dialog.error_dialog(_('Push location is unknown'),
132
 
                                         _('Please specify a location manually.'))
133
 
                return
134
 
            except errors.NonExistingParent, errmsg:
135
 
                self.dialog.error_dialog(_('Non existing parent directory'),
136
 
                                         _("The parent directory (%s)\ndoesn't exist.") % errmsg)
137
 
                return
138
 
            except errors.DivergedBranchesError:
 
130
            except errors.DivergedBranches:
139
131
                self.dialog.error_dialog(_('Branches have been diverged'),
140
132
                                         _('You cannot push if branches have diverged. Use the\noverwrite option if you want to push anyway.'))
141
133
                return
150
142
            
151
143
            try:
152
144
                revs = do_push(self.comm.get_path(), location,
153
 
                                   self.check_remember.get_active(),
154
 
                                   self.check_overwrite.get_active(),
155
 
                                   self.check_create.get_active())
 
145
                               self.check_remember.get_active(),
 
146
                               self.check_overwrite.get_active(),
 
147
                               self.check_create.get_active())
156
148
            except errors.NotBranchError:
157
149
                self.dialog.error_dialog(_('Directory is not a branch'),
158
150
                                         _('You can perform this action only in a branch.'))
159
151
                self.comm.set_busy(self.window, False)
160
152
                return
161
 
            except errors.NonExistingParent, errmsg:
162
 
                self.dialog.error_dialog(_('Non existing parent directory'),
163
 
                                         _("The parent directory (%s)\ndoesn't exist.") % errmsg)
164
 
                self.comm.set_busy(self.window, False)
165
 
                return
166
 
            except errors.DivergedBranchesError:
 
153
            except errors.DivergedBranches:
167
154
                self.dialog.error_dialog(_('Branches have been diverged'),
168
155
                                         _('You cannot push if branches have diverged. Use the\noverwrite option if you want to push anyway.'))
169
156
                self.comm.set_busy(self.window, False)
170
157
                return
171
 
            except errors.PathPrefixNotCreated:
172
 
                self.dialog.error_dialog(_('Path prefix not created'),
173
 
                                         _("The path leading up to the specified location couldn't\nbe created."))
174
 
                self.comm.set_busy(self.window, False)
175
 
                return
176
158
            except:
177
159
                raise
178
160
        else:
229
211
    :return: number of revisions pushed
230
212
    """
231
213
    from bzrlib.branch import Branch
 
214
    from bzrlib.bzrdir import BzrDir
232
215
    from bzrlib.transport import get_transport
233
216
        
234
217
    br_from = Branch.open_containing(branch)[0]
236
219
    stored_loc = br_from.get_push_location()
237
220
    if location is None:
238
221
        if stored_loc is None:
239
 
            raise NoLocationKnown
 
222
            self.dialog.error_dialog(_('Push location is unknown'),
 
223
                                     _('Please specify a location manually.'))
 
224
            return
240
225
        else:
241
226
            location = stored_loc
242
227
 
249
234
    old_rh = []
250
235
 
251
236
    try:
252
 
        dir_to = bzrlib.bzrdir.BzrDir.open(location_url)
 
237
        dir_to = BzrDir.open(location_url)
253
238
        br_to = dir_to.open_branch()
254
 
    except NotBranchError:
 
239
    except errors.NotBranchError:
255
240
        # create a branch.
256
241
        transport = transport.clone('..')
257
242
        if not create_prefix:
258
243
            try:
259
244
                relurl = transport.relpath(location_url)
260
245
                transport.mkdir(relurl)
261
 
            except NoSuchFile:
262
 
                raise NonExistingParent(location)
 
246
            except errors.NoSuchFile:
 
247
                self.dialog.error_dialog(_('Non existing parent directory'),
 
248
                                         _("The parent directory (%s)\ndoesn't exist.") % location)
 
249
                return
263
250
        else:
264
251
            current = transport.base
265
252
            needed = [(transport, transport.relpath(location_url))]
268
255
                    transport, relpath = needed[-1]
269
256
                    transport.mkdir(relpath)
270
257
                    needed.pop()
271
 
                except NoSuchFile:
 
258
                except errors.NoSuchFile:
272
259
                    new_transport = transport.clone('..')
273
260
                    needed.append((new_transport,
274
261
                                   new_transport.relpath(transport.base)))
275
262
                    if new_transport.base == transport.base:
276
 
                        raise PathPrefixNotCreated
 
263
                        self.dialog.error_dialog(_('Path prefix not created'),
 
264
                                                 _("The path leading up to the specified location couldn't\nbe created."))
 
265
                        return
277
266
        dir_to = br_from.bzrdir.clone(location_url,
278
267
            revision_id=br_from.last_revision())
279
268
        br_to = dir_to.open_branch()
283
272
        try:
284
273
            try:
285
274
                tree_to = dir_to.open_workingtree()
286
 
            except NotLocalUrl:
 
275
            except errors.NotLocalUrl:
287
276
                # FIXME - what to do here? how should we warn the user?
288
277
                #warning('This transport does not update the working '
289
278
                #        'tree of: %s' % (br_to.base,))
290
279
                count = br_to.pull(br_from, overwrite)
291
 
            except NoWorkingTree:
 
280
            except errors.NoWorkingTree:
292
281
                count = br_to.pull(br_from, overwrite)
293
282
            else:
294
283
                count = tree_to.pull(br_from, overwrite)
295
 
        except DivergedBranches:
296
 
            raise DivergedBranchesError
 
284
        except errors.DivergedBranches:
 
285
            raise
297
286
    
298
287
    return count