184
185
self.outf.write('Uploading %s\n' % old_relpath)
185
186
self._up_put_bytes(old_relpath, self.tree.get_file_text(new_relpath, id), mode)
188
def _force_clear(self, relpath):
190
st = self._up_stat(relpath)
191
if stat.S_ISDIR(st.st_mode):
192
# A simple rmdir may not be enough
194
self.outf.write('Clearing %s/%s\n' % (
195
self.to_transport.external_url(), relpath))
196
self._up_delete_tree(relpath)
197
elif stat.S_ISLNK(st.st_mode):
199
self.outf.write('Clearing %s/%s\n' % (
200
self.to_transport.external_url(), relpath))
201
self._up_delete(relpath)
202
except errors.PathError:
187
205
def upload_file_robustly(self, relpath, id, mode=None):
188
206
"""Upload a file, clearing the way on the remote side.
190
208
When doing a full upload, it may happen that a directory exists where
191
209
we want to put our file.
194
st = self._up_stat(relpath)
195
if stat.S_ISDIR(st.st_mode):
196
# A simple rmdir may not be enough
198
self.outf.write('Clearing %s/%s\n' % (
199
self.to_transport.external_url(), relpath))
200
self._up_delete_tree(relpath)
201
except errors.PathError:
211
self._force_clear(relpath)
203
212
self.upload_file(relpath, relpath, id, mode)
214
def upload_symlink(self, relpath, target):
215
self.to_transport.symlink(target, relpath)
217
def upload_symlink_robustly(self, relpath, target):
218
"""Handle uploading symlinks.
220
self._force_clear(relpath)
221
# Target might not be there at this time; dummy file should be
222
# overwritten at some point, possibly by another upload.
223
target = osutils.normpath(osutils.pathjoin(
224
osutils.dirname(relpath),
227
self.upload_symlink(relpath, target)
205
229
def make_remote_dir(self, relpath, mode=None):
304
328
if ie.kind == 'file':
305
329
self.upload_file_robustly(relpath, ie.file_id)
330
elif ie.kind == 'symlink':
332
self.upload_symlink_robustly(relpath, ie.symlink_target)
333
except errors.TransportNotPossible:
335
target = self.tree.path_content_summary(relpath)[3]
336
self.outf.write('Not uploading symlink %s -> %s\n'
306
338
elif ie.kind == 'directory':
307
339
self.make_remote_dir_robustly(relpath)
308
elif ie.kind == 'symlink':
310
target = self.tree.path_content_summary(relpath)[3]
311
self.outf.write('Not uploading symlink %s -> %s\n'
314
341
raise NotImplementedError
315
342
self.set_uploaded_revid(self.rev_id)
347
374
elif kind is 'directory':
348
375
self.delete_remote_dir_maybe(path)
349
376
elif kind == 'symlink':
351
target = self.tree.path_content_summary(path)[3]
352
self.outf.write('Not deleting remote symlink %s -> %s\n'
377
self.delete_remote_file(path)
355
379
raise NotImplementedError
365
389
# We update the old_path content because renames and
366
390
# deletions are differed.
367
391
self.upload_file(old_path, new_path, id)
368
if kind == 'symlink':
370
self.outf.write('Not renaming remote symlink %s to %s\n'
371
% (old_path, new_path))
373
self.rename_remote(old_path, new_path)
392
self.rename_remote(old_path, new_path)
374
393
self.finish_renames()
375
394
self.finish_deletions()
379
398
if not self.quiet:
380
399
self.outf.write('Ignoring %s\n' % path)
382
if old_kind == 'file':
401
if old_kind in ('file', 'symlink'):
383
402
self.delete_remote_file(path)
384
elif old_kind == 'directory':
403
elif old_kind == 'directory':
385
404
self.delete_remote_dir(path)
387
406
raise NotImplementedError
389
408
if new_kind == 'file':
390
409
self.upload_file(path, path, id)
410
elif new_kind == 'symlink':
411
target = self.tree.get_symlink_target(path)
412
self.upload_symlink(path, target)
391
413
elif new_kind is 'directory':
392
414
self.make_remote_dir(path)
403
425
elif kind == 'directory':
404
426
self.make_remote_dir(path)
405
427
elif kind == 'symlink':
407
target = self.tree.path_content_summary(path)[3]
408
self.outf.write('Not uploading symlink %s -> %s\n'
428
target = self.tree.get_symlink_target(path)
430
self.upload_symlink(path, target)
431
except errors.TransportNotPossible:
433
self.outf.write('Not uploading symlink %s -> %s\n'
411
436
raise NotImplementedError
544
572
# We uploaded successfully, remember it
573
with branch.lock_write():
547
574
upload_location = conf.get('upload_location')
548
575
if upload_location is None or remember:
549
576
conf.set('upload_location',
550
577
urlutils.unescape(to_transport.base))
551
578
if auto is not None:
552
579
conf.set('upload_auto', auto)