/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: Gustav Hartvigsson
  • Date: 2021-01-09 21:36:27 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210109213627-h1xwcutzy9m7a99b
Added 'Case Preserving Working Tree Use Cases' from Canonical Wiki

* Addod a page from the Canonical Bazaar wiki
  with information on the scmeatics of case
  perserving filesystems an a case insensitive
  filesystem works.
  
  * Needs re-work, but this will do as it is the
    same inforamoton as what was on the linked
    page in the currint documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""bzr-upload command implementations."""
18
18
 
19
 
from __future__ import absolute_import
20
 
 
21
19
from ... import (
22
20
    commands,
23
21
    config,
 
22
    errors,
24
23
    lazy_import,
25
24
    option,
26
25
    osutils,
30
29
 
31
30
from breezy import (
32
31
    controldir,
33
 
    errors,
34
32
    globbing,
35
33
    ignores,
36
34
    revision,
39
37
    )
40
38
""")
41
39
 
42
 
from ...sixish import (
43
 
    text_type,
44
 
    )
45
40
 
46
41
auto_option = config.Option(
47
42
    'upload_auto', default=False, from_unicode=config.bool_from_store,
364
359
        # --create-prefix option ?)
365
360
        changes = self.tree.changes_from(from_tree)
366
361
        with self.tree.lock_read():
367
 
            for (path, id, kind) in changes.removed:
368
 
                if self.is_ignored(path):
 
362
            for change in changes.removed:
 
363
                if self.is_ignored(change.path[0]):
369
364
                    if not self.quiet:
370
 
                        self.outf.write('Ignoring %s\n' % path)
 
365
                        self.outf.write('Ignoring %s\n' % change.path[0])
371
366
                    continue
372
 
                if kind is 'file':
373
 
                    self.delete_remote_file(path)
374
 
                elif kind is 'directory':
375
 
                    self.delete_remote_dir_maybe(path)
376
 
                elif kind == 'symlink':
377
 
                    self.delete_remote_file(path)
 
367
                if change.kind[0] == 'file':
 
368
                    self.delete_remote_file(change.path[0])
 
369
                elif change.kind[0] == 'directory':
 
370
                    self.delete_remote_dir_maybe(change.path[0])
 
371
                elif change.kind[0] == 'symlink':
 
372
                    self.delete_remote_file(change.path[0])
378
373
                else:
379
374
                    raise NotImplementedError
380
375
 
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):
 
376
            for change in changes.renamed:
 
377
                if self.is_ignored(change.path[0]) and self.is_ignored(change.path[1]):
384
378
                    if not self.quiet:
385
 
                        self.outf.write('Ignoring %s\n' % old_path)
386
 
                        self.outf.write('Ignoring %s\n' % new_path)
 
379
                        self.outf.write('Ignoring %s\n' % change.path[0])
 
380
                        self.outf.write('Ignoring %s\n' % change.path[1])
387
381
                    continue
388
 
                if content_change:
389
 
                    # We update the old_path content because renames and
 
382
                if change.changed_content:
 
383
                    # We update the change.path[0] content because renames and
390
384
                    # deletions are differed.
391
 
                    self.upload_file(old_path, new_path)
392
 
                self.rename_remote(old_path, new_path)
 
385
                    self.upload_file(change.path[0], change.path[1])
 
386
                self.rename_remote(change.path[0], change.path[1])
393
387
            self.finish_renames()
394
388
            self.finish_deletions()
395
389
 
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 is '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)
 
390
            for change in changes.kind_changed:
 
391
                if self.is_ignored(change.path[1]):
 
392
                    if not self.quiet:
 
393
                        self.outf.write('Ignoring %s\n' % change.path[1])
 
394
                    continue
 
395
                if change.kind[0] in ('file', 'symlink'):
 
396
                    self.delete_remote_file(change.path[0])
 
397
                elif change.kind[0] == 'directory':
 
398
                    self.delete_remote_dir(change.path[0])
 
399
                else:
 
400
                    raise NotImplementedError
 
401
 
 
402
                if change.kind[1] == 'file':
 
403
                    self.upload_file(change.path[1], change.path[1])
 
404
                elif change.kind[1] == 'symlink':
 
405
                    target = self.tree.get_symlink_target(change.path[1])
 
406
                    self.upload_symlink(change.path[1], target)
 
407
                elif change.kind[1] == 'directory':
 
408
                    self.make_remote_dir(change.path[1])
 
409
                else:
 
410
                    raise NotImplementedError
 
411
 
 
412
            for change in changes.added + changes.copied:
 
413
                if self.is_ignored(change.path[1]):
 
414
                    if not self.quiet:
 
415
                        self.outf.write('Ignoring %s\n' % change.path[1])
 
416
                    continue
 
417
                if change.kind[1] == 'file':
 
418
                    self.upload_file(change.path[1], change.path[1])
 
419
                elif change.kind[1] == 'directory':
 
420
                    self.make_remote_dir(change.path[1])
 
421
                elif change.kind[1] == 'symlink':
 
422
                    target = self.tree.get_symlink_target(change.path[1])
429
423
                    try:
430
 
                        self.upload_symlink(path, target)
 
424
                        self.upload_symlink(change.path[1], target)
431
425
                    except errors.TransportNotPossible:
432
426
                        if not self.quiet:
433
427
                            self.outf.write('Not uploading symlink %s -> %s\n'
434
 
                                            % (path, target))
 
428
                                            % (change.path[1], target))
435
429
                else:
436
430
                    raise NotImplementedError
437
431
 
438
432
            # XXX: Add a test for exec_change
439
 
            for (path, id, kind,
440
 
                 content_change, exec_change) in changes.modified:
441
 
                if self.is_ignored(path):
 
433
            for change in changes.modified:
 
434
                if self.is_ignored(change.path[1]):
442
435
                    if not self.quiet:
443
 
                        self.outf.write('Ignoring %s\n' % path)
 
436
                        self.outf.write('Ignoring %s\n' % change.path[1])
444
437
                    continue
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)
 
438
                if change.kind[1] == 'file':
 
439
                    self.upload_file(change.path[1], change.path[1])
 
440
                elif change.kind[1] == 'symlink':
 
441
                    target = self.tree.get_symlink_target(change.path[1])
 
442
                    self.upload_symlink(change.path[1], target)
450
443
                else:
451
444
                    raise NotImplementedError
452
445
 
453
446
            self.set_uploaded_revid(self.rev_id)
454
447
 
455
448
 
456
 
class CannotUploadToWorkingTree(errors.BzrCommandError):
 
449
class CannotUploadToWorkingTree(errors.CommandError):
457
450
 
458
451
    _fmt = 'Cannot upload to a bzr managed working tree: %(url)s".'
459
452
 
460
453
 
461
 
class DivergedUploadedTree(errors.BzrCommandError):
 
454
class DivergedUploadedTree(errors.CommandError):
462
455
 
463
456
    _fmt = ("Your branch (%(revid)s)"
464
457
            " and the uploaded tree (%(uploaded_revid)s) have diverged: ")
485
478
                      help='Branch to upload from, '
486
479
                      'rather than the one containing the working directory.',
487
480
                      short_name='d',
488
 
                      type=text_type,
 
481
                      type=str,
489
482
                      ),
490
483
        option.Option('auto',
491
484
                      'Trigger an upload from this branch whenever the tip '
503
496
             directory)
504
497
 
505
498
        if wt:
506
 
            wt.lock_read()
507
499
            locked = wt
508
500
        else:
509
 
            branch.lock_read()
510
501
            locked = branch
511
 
        try:
 
502
        with locked.lock_read():
512
503
            if wt:
513
504
                changes = wt.changes_from(wt.basis_tree())
514
505
 
519
510
            if location is None:
520
511
                stored_loc = conf.get('upload_location')
521
512
                if stored_loc is None:
522
 
                    raise errors.BzrCommandError(
 
513
                    raise errors.CommandError(
523
514
                        'No upload location known or specified.')
524
515
                else:
525
516
                    # FIXME: Not currently tested
547
538
                rev_id = branch.last_revision()
548
539
            else:
549
540
                if len(revision) != 1:
550
 
                    raise errors.BzrCommandError(
 
541
                    raise errors.CommandError(
551
542
                        'bzr upload --revision takes exactly 1 argument')
552
543
                rev_id = revision[0].in_history(branch).rev_id
553
544
 
566
557
                uploader.upload_full_tree()
567
558
            else:
568
559
                uploader.upload_tree()
569
 
        finally:
570
 
            locked.unlock()
571
560
 
572
561
        # We uploaded successfully, remember it
573
562
        with branch.lock_write():