/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/builtins.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-12 01:41:38 UTC
  • mto: (7143.16.20 even-more-cleanups)
  • mto: This revision was merged to the branch mainline in revision 7175.
  • Revision ID: jelmer@jelmer.uk-20181112014138-3b0zyx91cu3wdq3k
More PEP8 fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
448
448
            raise errors.BzrCommandError(gettext('You can only supply one of'
449
449
                                                 ' revision_id or --revision'))
450
450
        if revision_id is None and revision is None:
451
 
            raise errors.BzrCommandError(gettext('You must supply either'
452
 
                                                 ' --revision or a revision_id'))
 
451
            raise errors.BzrCommandError(
 
452
                gettext('You must supply either --revision or a revision_id'))
453
453
 
454
454
        b = controldir.ControlDir.open_containing_tree_or_branch(directory)[1]
455
455
 
942
942
            try:
943
943
                (src, dst) = rel_names
944
944
            except IndexError:
945
 
                raise errors.BzrCommandError(gettext('to copy multiple files the'
946
 
                                                     ' destination must be a versioned'
947
 
                                                     ' directory'))
 
945
                raise errors.BzrCommandError(
 
946
                    gettext('to copy multiple files the'
 
947
                            ' destination must be a versioned'
 
948
                            ' directory'))
948
949
            pairs = [(src, dst)]
949
950
        else:
950
 
            pairs = [(n, osutils.joinpath([rel_names[-1], osutils.basename(n)]))
951
 
                     for n in rel_names[:-1]]
 
951
            pairs = [
 
952
                (n, osutils.joinpath([rel_names[-1], osutils.basename(n)]))
 
953
                for n in rel_names[:-1]]
952
954
 
953
955
        for src, dst in pairs:
954
956
            try:
1032
1034
 
1033
1035
    def run_auto(self, names_list, after, dry_run):
1034
1036
        if names_list is not None and len(names_list) > 1:
1035
 
            raise errors.BzrCommandError(gettext('Only one path may be specified to'
1036
 
                                                 ' --auto.'))
 
1037
            raise errors.BzrCommandError(
 
1038
                gettext('Only one path may be specified to --auto.'))
1037
1039
        if after:
1038
 
            raise errors.BzrCommandError(gettext('--after cannot be specified with'
1039
 
                                                 ' --auto.'))
 
1040
            raise errors.BzrCommandError(
 
1041
                gettext('--after cannot be specified with --auto.'))
1040
1042
        work_tree, file_list = WorkingTree.open_containing_paths(
1041
1043
            names_list, default_directory='.')
1042
1044
        self.add_cleanup(work_tree.lock_tree_write().unlock)
1535
1537
            note(gettext('Created new stacked branch referring to %s.') %
1536
1538
                 branch.get_stacked_on_url())
1537
1539
        except (errors.NotStacked, _mod_branch.UnstackableBranchFormat,
1538
 
                errors.UnstackableRepositoryFormat) as e:
 
1540
                errors.UnstackableRepositoryFormat):
1539
1541
            note(ngettext('Branched %d revision.',
1540
 
                          'Branched %d revisions.', branch.revno()) % branch.revno())
 
1542
                          'Branched %d revisions.',
 
1543
                          branch.revno()) % branch.revno())
1541
1544
        if bind:
1542
1545
            # Bind to the parent
1543
1546
            parent_branch = Branch.open(from_location)
3918
3921
        # display a warning if an email address isn't included in the given name.
3919
3922
        try:
3920
3923
            _mod_config.extract_email_address(name)
3921
 
        except _mod_config.NoEmailInUsername as e:
 
3924
        except _mod_config.NoEmailInUsername:
3922
3925
            warning('"%s" does not seem to contain an email address.  '
3923
3926
                    'This is allowed, but not recommended.', name)
3924
3927
 
4572
4575
 
4573
4576
    def sanity_check_merger(self, merger):
4574
4577
        if (merger.show_base and
4575
 
                not merger.merge_type is _mod_merge.Merge3Merger):
 
4578
                merger.merge_type is not _mod_merge.Merge3Merger):
4576
4579
            raise errors.BzrCommandError(gettext("Show-base is not supported for this"
4577
4580
                                                 " merge type. %s") % merger.merge_type)
4578
4581
        if merger.reprocess is None:
4752
4755
        self.add_cleanup(tree.lock_write().unlock)
4753
4756
        parents = tree.get_parent_ids()
4754
4757
        if len(parents) != 2:
4755
 
            raise errors.BzrCommandError(gettext("Sorry, remerge only works after normal"
4756
 
                                                 " merges.  Not cherrypicking or"
4757
 
                                                 " multi-merges."))
4758
 
        repository = tree.branch.repository
 
4758
            raise errors.BzrCommandError(
 
4759
                gettext("Sorry, remerge only works after normal"
 
4760
                        " merges.  Not cherrypicking or multi-merges."))
4759
4761
        interesting_files = None
4760
4762
        new_conflicts = []
4761
4763
        conflicts = tree.conflicts()
4768
4770
                if tree.kind(filename) != "directory":
4769
4771
                    continue
4770
4772
 
4771
 
                for path, ie in tree.iter_entries_by_dir(specific_files=[filename]):
 
4773
                for path, ie in tree.iter_entries_by_dir(
 
4774
                        specific_files=[filename]):
4772
4775
                    interesting_files.add(path)
4773
4776
            new_conflicts = conflicts.select_conflicts(tree, file_list)[0]
4774
4777
        else:
5294
5297
                for revision_id in revision_id_list:
5295
5298
                    revision_id = cache_utf8.encode(revision_id)
5296
5299
                    b.repository.sign_revision(revision_id, gpg_strategy)
5297
 
            except:
 
5300
            except BaseException:
5298
5301
                b.repository.abort_write_group()
5299
5302
                raise
5300
5303
            else:
5305
5308
                b.repository.start_write_group()
5306
5309
                try:
5307
5310
                    b.repository.sign_revision(rev_id, gpg_strategy)
5308
 
                except:
 
5311
                except BaseException:
5309
5312
                    b.repository.abort_write_group()
5310
5313
                    raise
5311
5314
                else:
5326
5329
                    for revno in range(from_revno, to_revno + 1):
5327
5330
                        b.repository.sign_revision(b.get_rev_id(revno),
5328
5331
                                                   gpg_strategy)
5329
 
                except:
 
5332
                except BaseException:
5330
5333
                    b.repository.abort_write_group()
5331
5334
                    raise
5332
5335
                else:
5358
5361
            try:
5359
5362
                location = b.get_old_bound_location()
5360
5363
            except errors.UpgradeRequired:
5361
 
                raise errors.BzrCommandError(gettext('No location supplied.  '
5362
 
                                                     'This format does not remember old locations.'))
 
5364
                raise errors.BzrCommandError(
 
5365
                    gettext('No location supplied.  '
 
5366
                            'This format does not remember old locations.'))
5363
5367
            else:
5364
5368
                if location is None:
5365
5369
                    if b.get_bound_location() is not None:
5373
5377
        try:
5374
5378
            b.bind(b_other)
5375
5379
        except errors.DivergedBranches:
5376
 
            raise errors.BzrCommandError(gettext('These branches have diverged.'
5377
 
                                                 ' Try merging, and then bind again.'))
 
5380
            raise errors.BzrCommandError(
 
5381
                gettext('These branches have diverged.'
 
5382
                        ' Try merging, and then bind again.'))
5378
5383
        if b.get_config().has_explicit_nickname():
5379
5384
            b.nick = b_other.nick
5380
5385
 
5423
5428
                     Option('keep-tags',
5424
5429
                            help='Keep tags that point to removed revisions.'),
5425
5430
                     Option('local',
5426
 
                            help="Only remove the commits from the local branch"
5427
 
                            " when in a checkout."
 
5431
                            help="Only remove the commits from the local "
 
5432
                            "branch when in a checkout."
5428
5433
                            ),
5429
5434
                     ]
5430
5435
    takes_args = ['location?']
5505
5510
               last_rev_id, rev_id)
5506
5511
        uncommit(b, tree=tree, dry_run=dry_run, verbose=verbose,
5507
5512
                 revno=revno, local=local, keep_tags=keep_tags)
5508
 
        self.outf.write(gettext('You can restore the old tip by running:\n'
5509
 
                                '  brz pull . -r revid:%s\n') % last_rev_id.decode('utf-8'))
 
5513
        self.outf.write(
 
5514
            gettext('You can restore the old tip by running:\n'
 
5515
                    '  brz pull . -r revid:%s\n')
 
5516
            % last_rev_id.decode('utf-8'))
5510
5517
 
5511
5518
 
5512
5519
class cmd_break_lock(Command):
5581
5588
                                      'transport_server_registry'),
5582
5589
                       value_switches=True),
5583
5590
        Option('listen',
5584
 
               help='Listen for connections on nominated address.', type=text_type),
 
5591
               help='Listen for connections on nominated address.',
 
5592
               type=text_type),
5585
5593
        Option('port',
5586
5594
               help='Listen for connections on nominated port.  Passing 0 as '
5587
5595
                    'the port number will result in a dynamically allocated '
5714
5722
 
5715
5723
    takes_options = [
5716
5724
        'directory',
5717
 
        RegistryOption.from_kwargs('patch-type',
5718
 
                                   'The type of patch to include in the directive.',
5719
 
                                   title='Patch type',
5720
 
                                   value_switches=True,
5721
 
                                   enum_switch=False,
5722
 
                                   bundle='Bazaar revision bundle (default).',
5723
 
                                   diff='Normal unified diff.',
5724
 
                                   plain='No patch, just directive.'),
 
5725
        RegistryOption.from_kwargs(
 
5726
            'patch-type',
 
5727
            'The type of patch to include in the directive.',
 
5728
            title='Patch type',
 
5729
            value_switches=True,
 
5730
            enum_switch=False,
 
5731
            bundle='Bazaar revision bundle (default).',
 
5732
            diff='Normal unified diff.',
 
5733
            plain='No patch, just directive.'),
5725
5734
        Option('sign', help='GPG-sign the directive.'), 'revision',
5726
5735
        Option('mail-to', type=text_type,
5727
 
               help='Instead of printing the directive, email to this address.'),
 
5736
               help='Instead of printing the directive, email to this '
 
5737
               'address.'),
5728
5738
        Option('message', type=text_type, short_name='m',
5729
5739
               help='Message to use when committing this merge.')
5730
5740
        ]
5760
5770
            # FIXME: Should be done only if we succeed ? -- vila 2012-01-03
5761
5771
            branch.set_public_branch(public_branch)
5762
5772
        if not include_bundle and public_branch is None:
5763
 
            raise errors.BzrCommandError(gettext('No public branch specified or'
5764
 
                                                 ' known'))
 
5773
            raise errors.BzrCommandError(
 
5774
                gettext('No public branch specified or known'))
5765
5775
        base_revision_id = None
5766
5776
        if revision is not None:
5767
5777
            if len(revision) > 2:
5768
 
                raise errors.BzrCommandError(gettext('brz merge-directive takes '
5769
 
                                                     'at most two one revision identifiers'))
 
5778
                raise errors.BzrCommandError(
 
5779
                    gettext('brz merge-directive takes '
 
5780
                            'at most two one revision identifiers'))
5770
5781
            revision_id = revision[-1].as_revision_id(branch)
5771
5782
            if len(revision) == 2:
5772
5783
                base_revision_id = revision[0].as_revision_id(branch)