/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: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-06-12 01:45:56 UTC
  • mfrom: (7513.1.2 pypy3)
  • Revision ID: breezy.the.bot@gmail.com-20200612014556-tsc8assk3d0luziu
Avoid deprecated behaviour in ElementTree.

Merged from https://code.launchpad.net/~jelmer/brz/pypy3/+merge/385611

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""builtin brz commands"""
18
18
 
19
 
from __future__ import absolute_import
20
 
 
21
19
import errno
22
20
import os
23
21
import sys
86
84
    RevisionSpec,
87
85
    RevisionInfo,
88
86
    )
89
 
from .sixish import (
90
 
    PY3,
91
 
    text_type,
92
 
    viewitems,
93
 
    viewvalues,
94
 
)
95
87
from .trace import mutter, note, warning, is_quiet, get_verbosity_level
96
88
 
97
89
 
221
213
    if ref_branch is None or ref_branch.name:
222
214
        if ref_branch is not None:
223
215
            control_dir = ref_branch.controldir
224
 
        for name, branch in viewitems(control_dir.get_branches()):
 
216
        for name, branch in control_dir.get_branches().items():
225
217
            yield name, branch
226
218
    else:
227
219
        repo = ref_branch.controldir.find_repository()
741
733
                    "anything."),
742
734
        'verbose',
743
735
        Option('file-ids-from',
744
 
               type=text_type,
 
736
               type=str,
745
737
               help='Lookup file ids from this tree.'),
746
738
        ]
747
739
    encoding_type = 'replace'
871
863
        Option('kind',
872
864
               help='List entries of a particular kind: file, directory, '
873
865
                    'symlink.',
874
 
               type=text_type),
 
866
               type=str),
875
867
        ]
876
868
    takes_args = ['file*']
877
869
 
1336
1328
                            help='Create a stacked branch that refers to another branch '
1337
1329
                            'for the commit history. Only the work not present in the '
1338
1330
                            'referenced branch is included in the branch created.',
1339
 
                            type=text_type),
 
1331
                            type=str),
1340
1332
                     Option('strict',
1341
1333
                            help='Refuse to push if there are uncommitted changes in'
1342
1334
                            ' the working tree, --no-strict disables the check.'),
1448
1440
    takes_options = ['revision',
1449
1441
                     Option(
1450
1442
                         'hardlink', help='Hard-link working tree files where possible.'),
1451
 
                     Option('files-from', type=text_type,
 
1443
                     Option('files-from', type=str,
1452
1444
                            help="Get file contents from this tree."),
1453
1445
                     Option('no-tree',
1454
1446
                            help="Create a branch without a working-tree."),
1622
1614
                names[name] = active
1623
1615
            # Only mention the current branch explicitly if it's not
1624
1616
            # one of the colocated branches
1625
 
            if not any(viewvalues(names)) and active_branch is not None:
 
1617
            if not any(names.values()) and active_branch is not None:
1626
1618
                self.outf.write("* %s\n" % gettext("(default)"))
1627
1619
            for name in sorted(names):
1628
1620
                active = names[name]
1630
1622
                    prefix = "*"
1631
1623
                else:
1632
1624
                    prefix = " "
1633
 
                self.outf.write("%s %s\n" % (
1634
 
                    prefix, (name if PY3 else name.encode(self.outf.encoding))))
 
1625
                self.outf.write("%s %s\n" % (prefix, name))
1635
1626
 
1636
1627
 
1637
1628
class cmd_checkout(Command):
1665
1656
                                 "common operations like diff and status without "
1666
1657
                                 "such access, and also support local commits."
1667
1658
                            ),
1668
 
                     Option('files-from', type=text_type,
 
1659
                     Option('files-from', type=str,
1669
1660
                            help="Get file contents from this tree."),
1670
1661
                     Option('hardlink',
1671
1662
                            help='Hard-link working tree files where possible.'
2341
2332
    _see_also = ['status']
2342
2333
    takes_args = ['file*']
2343
2334
    takes_options = [
2344
 
        Option('diff-options', type=text_type,
 
2335
        Option('diff-options', type=str,
2345
2336
               help='Pass these options to the external diff program.'),
2346
 
        Option('prefix', type=text_type,
 
2337
        Option('prefix', type=str,
2347
2338
               short_name='p',
2348
2339
               help='Set prefixes added to old and new filenames, as '
2349
2340
                    'two values separated by a colon. (eg "old/:new/").'),
2350
2341
        Option('old',
2351
2342
               help='Branch/tree to compare from.',
2352
 
               type=text_type,
 
2343
               type=str,
2353
2344
               ),
2354
2345
        Option('new',
2355
2346
               help='Branch/tree to compare to.',
2356
 
               type=text_type,
 
2347
               type=str,
2357
2348
               ),
2358
2349
        'revision',
2359
2350
        'change',
2360
2351
        Option('using',
2361
2352
               help='Use this command to compare files.',
2362
 
               type=text_type,
 
2353
               type=str,
2363
2354
               ),
2364
2355
        RegistryOption('format',
2365
2356
                       short_name='F',
2734
2725
        Option('message',
2735
2726
               help='Show revisions whose message matches this '
2736
2727
               'regular expression.',
2737
 
               type=text_type,
 
2728
               type=str,
2738
2729
               hidden=True),
2739
2730
        Option('limit',
2740
2731
               short_name='l',
2760
2751
                   short_name='m',
2761
2752
                   help='Show revisions whose properties match this '
2762
2753
                   'expression.',
2763
 
                   type=text_type),
 
2754
                   type=str),
2764
2755
        ListOption('match-message',
2765
2756
                   help='Show revisions whose message matches this '
2766
2757
                   'expression.',
2767
 
                   type=text_type),
 
2758
                   type=str),
2768
2759
        ListOption('match-committer',
2769
2760
                   help='Show revisions whose committer matches this '
2770
2761
                   'expression.',
2771
 
                   type=text_type),
 
2762
                   type=str),
2772
2763
        ListOption('match-author',
2773
2764
                   help='Show revisions whose authors match this '
2774
2765
                   'expression.',
2775
 
                   type=text_type),
 
2766
                   type=str),
2776
2767
        ListOption('match-bugs',
2777
2768
                   help='Show revisions whose bugs match this '
2778
2769
                   'expression.',
2779
 
                   type=text_type)
 
2770
                   type=str)
2780
2771
        ]
2781
2772
    encoding_type = 'replace'
2782
2773
 
3042
3033
        Option('kind', short_name='k',
3043
3034
               help=('List entries of a particular kind: file, '
3044
3035
                     'directory, symlink, tree-reference.'),
3045
 
               type=text_type),
 
3036
               type=str),
3046
3037
        'null',
3047
3038
        'show-ids',
3048
3039
        'directory',
3366
3357
    takes_options = ['directory',
3367
3358
                     Option('format',
3368
3359
                            help="Type of file to export to.",
3369
 
                            type=text_type),
 
3360
                            type=str),
3370
3361
                     'revision',
3371
3362
                     Option('filters', help='Apply content filters to export the '
3372
3363
                            'convenient form.'),
3373
3364
                     Option('root',
3374
 
                            type=text_type,
 
3365
                            type=str,
3375
3366
                            help="Name of the root directory inside the exported file."),
3376
3367
                     Option('per-file-timestamps',
3377
3368
                            help='Set modification time of files to that of the last '
3573
3564
    takes_args = ['selected*']
3574
3565
    takes_options = [
3575
3566
        ListOption(
3576
 
            'exclude', type=text_type, short_name='x',
 
3567
            'exclude', type=str, short_name='x',
3577
3568
            help="Do not consider changes made to a given path."),
3578
 
        Option('message', type=text_type,
 
3569
        Option('message', type=str,
3579
3570
               short_name='m',
3580
3571
               help="Description of the new revision."),
3581
3572
        'verbose',
3582
3573
        Option('unchanged',
3583
3574
               help='Commit even if nothing has changed.'),
3584
 
        Option('file', type=text_type,
 
3575
        Option('file', type=str,
3585
3576
               short_name='F',
3586
3577
               argname='msgfile',
3587
3578
               help='Take commit message from this file.'),
3588
3579
        Option('strict',
3589
3580
               help="Refuse to commit if there are unknown "
3590
3581
               "files in the working tree."),
3591
 
        Option('commit-time', type=text_type,
 
3582
        Option('commit-time', type=str,
3592
3583
               help="Manually set a commit time using commit date "
3593
3584
               "format, e.g. '2009-10-10 08:00:00 +0100'."),
3594
3585
        ListOption(
3595
 
            'bugs', type=text_type,
 
3586
            'bugs', type=str,
3596
3587
            help="Link to a related bug. (see \"brz help bugs\")."),
3597
3588
        ListOption(
3598
 
            'fixes', type=text_type,
 
3589
            'fixes', type=str,
3599
3590
            help="Mark a bug as being fixed by this revision "
3600
3591
                 "(see \"brz help bugs\")."),
3601
3592
        ListOption(
3602
 
            'author', type=text_type,
 
3593
            'author', type=str,
3603
3594
            help="Set the author's name, if it's different "
3604
3595
                 "from the committer."),
3605
3596
        Option('local',
4065
4056
    def print_aliases(self):
4066
4057
        """Print out the defined aliases in a similar format to bash."""
4067
4058
        aliases = _mod_config.GlobalConfig().get_aliases()
4068
 
        for key, value in sorted(viewitems(aliases)):
 
4059
        for key, value in sorted(aliases.items()):
4069
4060
            self.outf.write('brz alias %s="%s"\n' % (key, value))
4070
4061
 
4071
4062
    @display_command
4182
4173
                                        'breezy.tests', 'parallel_registry'),
4183
4174
                                    value_switches=False,
4184
4175
                                    ),
4185
 
                     Option('randomize', type=text_type, argname="SEED",
 
4176
                     Option('randomize', type=str, argname="SEED",
4186
4177
                            help='Randomize the order of tests using the given'
4187
4178
                                 ' seed or "now" for the current time.'),
4188
 
                     ListOption('exclude', type=text_type, argname="PATTERN",
 
4179
                     ListOption('exclude', type=str, argname="PATTERN",
4189
4180
                                short_name='x',
4190
4181
                                help='Exclude tests that match this regular'
4191
4182
                                ' expression.'),
4195
4186
                            help='Output test progress via subunit v2.'),
4196
4187
                     Option('strict', help='Fail on missing dependencies or '
4197
4188
                            'known failures.'),
4198
 
                     Option('load-list', type=text_type, argname='TESTLISTFILE',
 
4189
                     Option('load-list', type=str, argname='TESTLISTFILE',
4199
4190
                            help='Load a test id list from a text file.'),
4200
 
                     ListOption('debugflag', type=text_type, short_name='E',
 
4191
                     ListOption('debugflag', type=str, short_name='E',
4201
4192
                                help='Turn on a selftest debug flag.'),
4202
 
                     ListOption('starting-with', type=text_type, argname='TESTID',
 
4193
                     ListOption('starting-with', type=str, argname='TESTID',
4203
4194
                                param_name='starting_with', short_name='s',
4204
4195
                                help='Load only the tests starting with TESTID.'),
4205
4196
                     Option('sync',
5625
5616
                       value_switches=True),
5626
5617
        Option('listen',
5627
5618
               help='Listen for connections on nominated address.',
5628
 
               type=text_type),
 
5619
               type=str),
5629
5620
        Option('port',
5630
5621
               help='Listen for connections on nominated port.  Passing 0 as '
5631
5622
                    'the port number will result in a dynamically allocated '
5767
5758
            diff='Normal unified diff.',
5768
5759
            plain='No patch, just directive.'),
5769
5760
        Option('sign', help='GPG-sign the directive.'), 'revision',
5770
 
        Option('mail-to', type=text_type,
 
5761
        Option('mail-to', type=str,
5771
5762
               help='Instead of printing the directive, email to this '
5772
5763
               'address.'),
5773
 
        Option('message', type=text_type, short_name='m',
 
5764
        Option('message', type=str, short_name='m',
5774
5765
               help='Message to use when committing this merge.')
5775
5766
        ]
5776
5767
 
5924
5915
               help='Branch to generate the submission from, '
5925
5916
               'rather than the one containing the working directory.',
5926
5917
               short_name='f',
5927
 
               type=text_type),
 
5918
               type=str),
5928
5919
        Option('output', short_name='o',
5929
5920
               help='Write merge directive to this file or directory; '
5930
5921
                    'use - for stdout.',
5931
 
               type=text_type),
 
5922
               type=str),
5932
5923
        Option('strict',
5933
5924
               help='Refuse to send if there are uncommitted changes in'
5934
5925
               ' the working tree, --no-strict disables the check.'),
5935
5926
        Option('mail-to', help='Mail the request to this address.',
5936
 
               type=text_type),
 
5927
               type=str),
5937
5928
        'revision',
5938
5929
        'message',
5939
 
        Option('body', help='Body for the email.', type=text_type),
 
5930
        Option('body', help='Body for the email.', type=str),
5940
5931
        RegistryOption('format',
5941
5932
                       help='Use the specified output format.',
5942
5933
                       lazy_registry=('breezy.send', 'format_registry')),
5992
5983
               help='Branch to generate the submission from, '
5993
5984
               'rather than the one containing the working directory.',
5994
5985
               short_name='f',
5995
 
               type=text_type),
 
5986
               type=str),
5996
5987
        Option('output', short_name='o', help='Write directive to this file.',
5997
 
               type=text_type),
 
5988
               type=str),
5998
5989
        Option('strict',
5999
5990
               help='Refuse to bundle revisions if there are uncommitted'
6000
5991
               ' changes in the working tree, --no-strict disables the check.'),
6124
6115
        from .tag import tag_sort_methods
6125
6116
        branch, relpath = Branch.open_containing(directory)
6126
6117
 
6127
 
        tags = list(viewitems(branch.tags.get_tag_dict()))
 
6118
        tags = list(branch.tags.get_tag_dict().items())
6128
6119
        if not tags:
6129
6120
            return
6130
6121
 
6228
6219
            with_no_trees='Reconfigure repository to not create '
6229
6220
            'working trees on branches by default.'
6230
6221
            ),
6231
 
        Option('bind-to', help='Branch to bind checkout to.', type=text_type),
 
6222
        Option('bind-to', help='Branch to bind checkout to.', type=str),
6232
6223
        Option('force',
6233
6224
               help='Perform reconfiguration even if local changes'
6234
6225
               ' will be lost.'),
6235
6226
        Option('stacked-on',
6236
6227
               help='Reconfigure a branch to be stacked on another branch.',
6237
 
               type=text_type,
 
6228
               type=str,
6238
6229
               ),
6239
6230
        Option('unstacked',
6240
6231
               help='Reconfigure a branch to be unstacked.  This '
6474
6465
               ),
6475
6466
        Option('name',
6476
6467
               help='Name of the view to define, list or delete.',
6477
 
               type=text_type,
 
6468
               type=str,
6478
6469
               ),
6479
6470
        Option('switch',
6480
6471
               help='Name of the view to switch to.',
6481
 
               type=text_type,
 
6472
               type=str,
6482
6473
               ),
6483
6474
        ]
6484
6475
 
6827
6818
    takes_options = [Option('plugin',
6828
6819
                            help='Export help text from named command '
6829
6820
                                 '(defaults to all built in commands).',
6830
 
                            type=text_type),
 
6821
                            type=str),
6831
6822
                     Option('include-duplicates',
6832
6823
                            help='Output multiple copies of the same msgid '
6833
6824
                                 'string if it appears more than once.'),
6933
6924
    takes_options = [
6934
6925
        'verbose',
6935
6926
        'revision',
6936
 
        Option('color', type=text_type, argname='when',
 
6927
        Option('color', type=str, argname='when',
6937
6928
               help='Show match in color. WHEN is never, always or auto.'),
6938
6929
        Option('diff', short_name='p',
6939
6930
               help='Grep for pattern in changeset for each revision.'),
6940
 
        ListOption('exclude', type=text_type, argname='glob', short_name='X',
 
6931
        ListOption('exclude', type=str, argname='glob', short_name='X',
6941
6932
                   help="Skip files whose base name matches GLOB."),
6942
 
        ListOption('include', type=text_type, argname='glob', short_name='I',
 
6933
        ListOption('include', type=str, argname='glob', short_name='I',
6943
6934
                   help="Search only files whose base name matches GLOB."),
6944
6935
        Option('files-with-matches', short_name='l',
6945
6936
               help='Print only the name of each input file in '