/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/plugins/upload/cmds.py

  • Committer: Jelmer Vernooij
  • Date: 2019-06-03 23:48:08 UTC
  • mfrom: (7316 work)
  • mto: This revision was merged to the branch mainline in revision 7328.
  • Revision ID: jelmer@jelmer.uk-20190603234808-15yk5c7054tj8e2b
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from ... import (
22
22
    commands,
23
23
    config,
24
 
    errors,
25
24
    lazy_import,
26
25
    option,
27
26
    osutils,
31
30
 
32
31
from breezy import (
33
32
    controldir,
 
33
    errors,
34
34
    globbing,
35
35
    ignores,
36
36
    revision,
364
364
        # --create-prefix option ?)
365
365
        changes = self.tree.changes_from(from_tree)
366
366
        with self.tree.lock_read():
367
 
            for change in changes.removed:
368
 
                if self.is_ignored(change.path[0]):
 
367
            for (path, id, kind) in changes.removed:
 
368
                if self.is_ignored(path):
369
369
                    if not self.quiet:
370
 
                        self.outf.write('Ignoring %s\n' % change.path[0])
 
370
                        self.outf.write('Ignoring %s\n' % path)
371
371
                    continue
372
 
                if change.kind[0] == 'file':
373
 
                    self.delete_remote_file(change.path[0])
374
 
                elif change.kind[0] == 'directory':
375
 
                    self.delete_remote_dir_maybe(change.path[0])
376
 
                elif change.kind[0] == 'symlink':
377
 
                    self.delete_remote_file(change.path[0])
 
372
                if kind == 'file':
 
373
                    self.delete_remote_file(path)
 
374
                elif kind == 'directory':
 
375
                    self.delete_remote_dir_maybe(path)
 
376
                elif kind == 'symlink':
 
377
                    self.delete_remote_file(path)
378
378
                else:
379
379
                    raise NotImplementedError
380
380
 
381
 
            for change in changes.renamed:
382
 
                if self.is_ignored(change.path[0]) and self.is_ignored(change.path[1]):
 
381
            for (old_path, new_path, id, kind,
 
382
                 content_change, exec_change) in changes.renamed:
 
383
                if self.is_ignored(old_path) and self.is_ignored(new_path):
383
384
                    if not self.quiet:
384
 
                        self.outf.write('Ignoring %s\n' % change.path[0])
385
 
                        self.outf.write('Ignoring %s\n' % change.path[1])
 
385
                        self.outf.write('Ignoring %s\n' % old_path)
 
386
                        self.outf.write('Ignoring %s\n' % new_path)
386
387
                    continue
387
 
                if change.changed_content:
388
 
                    # We update the change.path[0] content because renames and
 
388
                if content_change:
 
389
                    # We update the old_path content because renames and
389
390
                    # deletions are differed.
390
 
                    self.upload_file(change.path[0], change.path[1])
391
 
                self.rename_remote(change.path[0], change.path[1])
 
391
                    self.upload_file(old_path, new_path)
 
392
                self.rename_remote(old_path, new_path)
392
393
            self.finish_renames()
393
394
            self.finish_deletions()
394
395
 
395
 
            for change in changes.kind_changed:
396
 
                if self.is_ignored(change.path[1]):
397
 
                    if not self.quiet:
398
 
                        self.outf.write('Ignoring %s\n' % change.path[1])
399
 
                    continue
400
 
                if change.kind[0] in ('file', 'symlink'):
401
 
                    self.delete_remote_file(change.path[0])
402
 
                elif change.kind[0] == 'directory':
403
 
                    self.delete_remote_dir(change.path[0])
404
 
                else:
405
 
                    raise NotImplementedError
406
 
 
407
 
                if change.kind[1] == 'file':
408
 
                    self.upload_file(change.path[1], change.path[1])
409
 
                elif change.kind[1] == 'symlink':
410
 
                    target = self.tree.get_symlink_target(change.path[1])
411
 
                    self.upload_symlink(change.path[1], target)
412
 
                elif change.kind[1] == 'directory':
413
 
                    self.make_remote_dir(change.path[1])
414
 
                else:
415
 
                    raise NotImplementedError
416
 
 
417
 
            for change in changes.added + changes.copied:
418
 
                if self.is_ignored(change.path[1]):
419
 
                    if not self.quiet:
420
 
                        self.outf.write('Ignoring %s\n' % change.path[1])
421
 
                    continue
422
 
                if change.kind[1] == 'file':
423
 
                    self.upload_file(change.path[1], change.path[1])
424
 
                elif change.kind[1] == 'directory':
425
 
                    self.make_remote_dir(change.path[1])
426
 
                elif change.kind[1] == 'symlink':
427
 
                    target = self.tree.get_symlink_target(change.path[1])
 
396
            for (path, id, old_kind, new_kind) in changes.kind_changed:
 
397
                if self.is_ignored(path):
 
398
                    if not self.quiet:
 
399
                        self.outf.write('Ignoring %s\n' % path)
 
400
                    continue
 
401
                if old_kind in ('file', 'symlink'):
 
402
                    self.delete_remote_file(path)
 
403
                elif old_kind == 'directory':
 
404
                    self.delete_remote_dir(path)
 
405
                else:
 
406
                    raise NotImplementedError
 
407
 
 
408
                if new_kind == 'file':
 
409
                    self.upload_file(path, path)
 
410
                elif new_kind == 'symlink':
 
411
                    target = self.tree.get_symlink_target(path)
 
412
                    self.upload_symlink(path, target)
 
413
                elif new_kind == 'directory':
 
414
                    self.make_remote_dir(path)
 
415
                else:
 
416
                    raise NotImplementedError
 
417
 
 
418
            for (path, id, kind) in changes.added:
 
419
                if self.is_ignored(path):
 
420
                    if not self.quiet:
 
421
                        self.outf.write('Ignoring %s\n' % path)
 
422
                    continue
 
423
                if kind == 'file':
 
424
                    self.upload_file(path, path)
 
425
                elif kind == 'directory':
 
426
                    self.make_remote_dir(path)
 
427
                elif kind == 'symlink':
 
428
                    target = self.tree.get_symlink_target(path)
428
429
                    try:
429
 
                        self.upload_symlink(change.path[1], target)
 
430
                        self.upload_symlink(path, target)
430
431
                    except errors.TransportNotPossible:
431
432
                        if not self.quiet:
432
433
                            self.outf.write('Not uploading symlink %s -> %s\n'
433
 
                                            % (change.path[1], target))
 
434
                                            % (path, target))
434
435
                else:
435
436
                    raise NotImplementedError
436
437
 
437
438
            # XXX: Add a test for exec_change
438
 
            for change in changes.modified:
439
 
                if self.is_ignored(change.path[1]):
 
439
            for (path, id, kind,
 
440
                 content_change, exec_change) in changes.modified:
 
441
                if self.is_ignored(path):
440
442
                    if not self.quiet:
441
 
                        self.outf.write('Ignoring %s\n' % change.path[1])
 
443
                        self.outf.write('Ignoring %s\n' % path)
442
444
                    continue
443
 
                if change.kind[1] == 'file':
444
 
                    self.upload_file(change.path[1], change.path[1])
445
 
                elif change.kind[1] == 'symlink':
446
 
                    target = self.tree.get_symlink_target(change.path[1])
447
 
                    self.upload_symlink(change.path[1], target)
 
445
                if kind == 'file':
 
446
                    self.upload_file(path, path)
 
447
                elif kind == 'symlink':
 
448
                    target = self.tree.get_symlink_target(path)
 
449
                    self.upload_symlink(path, target)
448
450
                else:
449
451
                    raise NotImplementedError
450
452
 
501
503
             directory)
502
504
 
503
505
        if wt:
 
506
            wt.lock_read()
504
507
            locked = wt
505
508
        else:
 
509
            branch.lock_read()
506
510
            locked = branch
507
 
        with locked.lock_read():
 
511
        try:
508
512
            if wt:
509
513
                changes = wt.changes_from(wt.basis_tree())
510
514
 
562
566
                uploader.upload_full_tree()
563
567
            else:
564
568
                uploader.upload_tree()
 
569
        finally:
 
570
            locked.unlock()
565
571
 
566
572
        # We uploaded successfully, remember it
567
573
        with branch.lock_write():