/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-02-14 03:16:54 UTC
  • mfrom: (7479.2.3 no-more-python2)
  • Revision ID: breezy.the.bot@gmail.com-20200214031654-bp1xtv2jr9nmhto3
Drop python2 support.

Merged from https://code.launchpad.net/~jelmer/brz/no-more-python2/+merge/378694

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
    RevisionSpec,
87
87
    RevisionInfo,
88
88
    )
89
 
from .sixish import (
90
 
    PY3,
91
 
    text_type,
92
 
    viewitems,
93
 
    viewvalues,
94
 
)
95
89
from .trace import mutter, note, warning, is_quiet, get_verbosity_level
96
90
 
97
91
 
221
215
    if ref_branch is None or ref_branch.name:
222
216
        if ref_branch is not None:
223
217
            control_dir = ref_branch.controldir
224
 
        for name, branch in viewitems(control_dir.get_branches()):
 
218
        for name, branch in control_dir.get_branches().items():
225
219
            yield name, branch
226
220
    else:
227
221
        repo = ref_branch.controldir.find_repository()
741
735
                    "anything."),
742
736
        'verbose',
743
737
        Option('file-ids-from',
744
 
               type=text_type,
 
738
               type=str,
745
739
               help='Lookup file ids from this tree.'),
746
740
        ]
747
741
    encoding_type = 'replace'
871
865
        Option('kind',
872
866
               help='List entries of a particular kind: file, directory, '
873
867
                    'symlink.',
874
 
               type=text_type),
 
868
               type=str),
875
869
        ]
876
870
    takes_args = ['file*']
877
871
 
1336
1330
                            help='Create a stacked branch that refers to another branch '
1337
1331
                            'for the commit history. Only the work not present in the '
1338
1332
                            'referenced branch is included in the branch created.',
1339
 
                            type=text_type),
 
1333
                            type=str),
1340
1334
                     Option('strict',
1341
1335
                            help='Refuse to push if there are uncommitted changes in'
1342
1336
                            ' the working tree, --no-strict disables the check.'),
1447
1441
    takes_options = ['revision',
1448
1442
                     Option(
1449
1443
                         'hardlink', help='Hard-link working tree files where possible.'),
1450
 
                     Option('files-from', type=text_type,
 
1444
                     Option('files-from', type=str,
1451
1445
                            help="Get file contents from this tree."),
1452
1446
                     Option('no-tree',
1453
1447
                            help="Create a branch without a working-tree."),
1619
1613
                names[name] = active
1620
1614
            # Only mention the current branch explicitly if it's not
1621
1615
            # one of the colocated branches
1622
 
            if not any(viewvalues(names)) and active_branch is not None:
 
1616
            if not any(names.values()) and active_branch is not None:
1623
1617
                self.outf.write("* %s\n" % gettext("(default)"))
1624
1618
            for name in sorted(names):
1625
1619
                active = names[name]
1627
1621
                    prefix = "*"
1628
1622
                else:
1629
1623
                    prefix = " "
1630
 
                self.outf.write("%s %s\n" % (
1631
 
                    prefix, (name if PY3 else name.encode(self.outf.encoding))))
 
1624
                self.outf.write("%s %s\n" % (prefix, name))
1632
1625
 
1633
1626
 
1634
1627
class cmd_checkout(Command):
1662
1655
                                 "common operations like diff and status without "
1663
1656
                                 "such access, and also support local commits."
1664
1657
                            ),
1665
 
                     Option('files-from', type=text_type,
 
1658
                     Option('files-from', type=str,
1666
1659
                            help="Get file contents from this tree."),
1667
1660
                     Option('hardlink',
1668
1661
                            help='Hard-link working tree files where possible.'
2306
2299
    _see_also = ['status']
2307
2300
    takes_args = ['file*']
2308
2301
    takes_options = [
2309
 
        Option('diff-options', type=text_type,
 
2302
        Option('diff-options', type=str,
2310
2303
               help='Pass these options to the external diff program.'),
2311
 
        Option('prefix', type=text_type,
 
2304
        Option('prefix', type=str,
2312
2305
               short_name='p',
2313
2306
               help='Set prefixes added to old and new filenames, as '
2314
2307
                    'two values separated by a colon. (eg "old/:new/").'),
2315
2308
        Option('old',
2316
2309
               help='Branch/tree to compare from.',
2317
 
               type=text_type,
 
2310
               type=str,
2318
2311
               ),
2319
2312
        Option('new',
2320
2313
               help='Branch/tree to compare to.',
2321
 
               type=text_type,
 
2314
               type=str,
2322
2315
               ),
2323
2316
        'revision',
2324
2317
        'change',
2325
2318
        Option('using',
2326
2319
               help='Use this command to compare files.',
2327
 
               type=text_type,
 
2320
               type=str,
2328
2321
               ),
2329
2322
        RegistryOption('format',
2330
2323
                       short_name='F',
2699
2692
        Option('message',
2700
2693
               help='Show revisions whose message matches this '
2701
2694
               'regular expression.',
2702
 
               type=text_type,
 
2695
               type=str,
2703
2696
               hidden=True),
2704
2697
        Option('limit',
2705
2698
               short_name='l',
2725
2718
                   short_name='m',
2726
2719
                   help='Show revisions whose properties match this '
2727
2720
                   'expression.',
2728
 
                   type=text_type),
 
2721
                   type=str),
2729
2722
        ListOption('match-message',
2730
2723
                   help='Show revisions whose message matches this '
2731
2724
                   'expression.',
2732
 
                   type=text_type),
 
2725
                   type=str),
2733
2726
        ListOption('match-committer',
2734
2727
                   help='Show revisions whose committer matches this '
2735
2728
                   'expression.',
2736
 
                   type=text_type),
 
2729
                   type=str),
2737
2730
        ListOption('match-author',
2738
2731
                   help='Show revisions whose authors match this '
2739
2732
                   'expression.',
2740
 
                   type=text_type),
 
2733
                   type=str),
2741
2734
        ListOption('match-bugs',
2742
2735
                   help='Show revisions whose bugs match this '
2743
2736
                   'expression.',
2744
 
                   type=text_type)
 
2737
                   type=str)
2745
2738
        ]
2746
2739
    encoding_type = 'replace'
2747
2740
 
3007
3000
        Option('kind', short_name='k',
3008
3001
               help=('List entries of a particular kind: file, '
3009
3002
                     'directory, symlink, tree-reference.'),
3010
 
               type=text_type),
 
3003
               type=str),
3011
3004
        'null',
3012
3005
        'show-ids',
3013
3006
        'directory',
3331
3324
    takes_options = ['directory',
3332
3325
                     Option('format',
3333
3326
                            help="Type of file to export to.",
3334
 
                            type=text_type),
 
3327
                            type=str),
3335
3328
                     'revision',
3336
3329
                     Option('filters', help='Apply content filters to export the '
3337
3330
                            'convenient form.'),
3338
3331
                     Option('root',
3339
 
                            type=text_type,
 
3332
                            type=str,
3340
3333
                            help="Name of the root directory inside the exported file."),
3341
3334
                     Option('per-file-timestamps',
3342
3335
                            help='Set modification time of files to that of the last '
3538
3531
    takes_args = ['selected*']
3539
3532
    takes_options = [
3540
3533
        ListOption(
3541
 
            'exclude', type=text_type, short_name='x',
 
3534
            'exclude', type=str, short_name='x',
3542
3535
            help="Do not consider changes made to a given path."),
3543
 
        Option('message', type=text_type,
 
3536
        Option('message', type=str,
3544
3537
               short_name='m',
3545
3538
               help="Description of the new revision."),
3546
3539
        'verbose',
3547
3540
        Option('unchanged',
3548
3541
               help='Commit even if nothing has changed.'),
3549
 
        Option('file', type=text_type,
 
3542
        Option('file', type=str,
3550
3543
               short_name='F',
3551
3544
               argname='msgfile',
3552
3545
               help='Take commit message from this file.'),
3553
3546
        Option('strict',
3554
3547
               help="Refuse to commit if there are unknown "
3555
3548
               "files in the working tree."),
3556
 
        Option('commit-time', type=text_type,
 
3549
        Option('commit-time', type=str,
3557
3550
               help="Manually set a commit time using commit date "
3558
3551
               "format, e.g. '2009-10-10 08:00:00 +0100'."),
3559
3552
        ListOption(
3560
 
            'bugs', type=text_type,
 
3553
            'bugs', type=str,
3561
3554
            help="Link to a related bug. (see \"brz help bugs\")."),
3562
3555
        ListOption(
3563
 
            'fixes', type=text_type,
 
3556
            'fixes', type=str,
3564
3557
            help="Mark a bug as being fixed by this revision "
3565
3558
                 "(see \"brz help bugs\")."),
3566
3559
        ListOption(
3567
 
            'author', type=text_type,
 
3560
            'author', type=str,
3568
3561
            help="Set the author's name, if it's different "
3569
3562
                 "from the committer."),
3570
3563
        Option('local',
4030
4023
    def print_aliases(self):
4031
4024
        """Print out the defined aliases in a similar format to bash."""
4032
4025
        aliases = _mod_config.GlobalConfig().get_aliases()
4033
 
        for key, value in sorted(viewitems(aliases)):
 
4026
        for key, value in sorted(aliases.items()):
4034
4027
            self.outf.write('brz alias %s="%s"\n' % (key, value))
4035
4028
 
4036
4029
    @display_command
4147
4140
                                        'breezy.tests', 'parallel_registry'),
4148
4141
                                    value_switches=False,
4149
4142
                                    ),
4150
 
                     Option('randomize', type=text_type, argname="SEED",
 
4143
                     Option('randomize', type=str, argname="SEED",
4151
4144
                            help='Randomize the order of tests using the given'
4152
4145
                                 ' seed or "now" for the current time.'),
4153
 
                     ListOption('exclude', type=text_type, argname="PATTERN",
 
4146
                     ListOption('exclude', type=str, argname="PATTERN",
4154
4147
                                short_name='x',
4155
4148
                                help='Exclude tests that match this regular'
4156
4149
                                ' expression.'),
4160
4153
                            help='Output test progress via subunit v2.'),
4161
4154
                     Option('strict', help='Fail on missing dependencies or '
4162
4155
                            'known failures.'),
4163
 
                     Option('load-list', type=text_type, argname='TESTLISTFILE',
 
4156
                     Option('load-list', type=str, argname='TESTLISTFILE',
4164
4157
                            help='Load a test id list from a text file.'),
4165
 
                     ListOption('debugflag', type=text_type, short_name='E',
 
4158
                     ListOption('debugflag', type=str, short_name='E',
4166
4159
                                help='Turn on a selftest debug flag.'),
4167
 
                     ListOption('starting-with', type=text_type, argname='TESTID',
 
4160
                     ListOption('starting-with', type=str, argname='TESTID',
4168
4161
                                param_name='starting_with', short_name='s',
4169
4162
                                help='Load only the tests starting with TESTID.'),
4170
4163
                     Option('sync',
5590
5583
                       value_switches=True),
5591
5584
        Option('listen',
5592
5585
               help='Listen for connections on nominated address.',
5593
 
               type=text_type),
 
5586
               type=str),
5594
5587
        Option('port',
5595
5588
               help='Listen for connections on nominated port.  Passing 0 as '
5596
5589
                    'the port number will result in a dynamically allocated '
5732
5725
            diff='Normal unified diff.',
5733
5726
            plain='No patch, just directive.'),
5734
5727
        Option('sign', help='GPG-sign the directive.'), 'revision',
5735
 
        Option('mail-to', type=text_type,
 
5728
        Option('mail-to', type=str,
5736
5729
               help='Instead of printing the directive, email to this '
5737
5730
               'address.'),
5738
 
        Option('message', type=text_type, short_name='m',
 
5731
        Option('message', type=str, short_name='m',
5739
5732
               help='Message to use when committing this merge.')
5740
5733
        ]
5741
5734
 
5889
5882
               help='Branch to generate the submission from, '
5890
5883
               'rather than the one containing the working directory.',
5891
5884
               short_name='f',
5892
 
               type=text_type),
 
5885
               type=str),
5893
5886
        Option('output', short_name='o',
5894
5887
               help='Write merge directive to this file or directory; '
5895
5888
                    'use - for stdout.',
5896
 
               type=text_type),
 
5889
               type=str),
5897
5890
        Option('strict',
5898
5891
               help='Refuse to send if there are uncommitted changes in'
5899
5892
               ' the working tree, --no-strict disables the check.'),
5900
5893
        Option('mail-to', help='Mail the request to this address.',
5901
 
               type=text_type),
 
5894
               type=str),
5902
5895
        'revision',
5903
5896
        'message',
5904
 
        Option('body', help='Body for the email.', type=text_type),
 
5897
        Option('body', help='Body for the email.', type=str),
5905
5898
        RegistryOption('format',
5906
5899
                       help='Use the specified output format.',
5907
5900
                       lazy_registry=('breezy.send', 'format_registry')),
5957
5950
               help='Branch to generate the submission from, '
5958
5951
               'rather than the one containing the working directory.',
5959
5952
               short_name='f',
5960
 
               type=text_type),
 
5953
               type=str),
5961
5954
        Option('output', short_name='o', help='Write directive to this file.',
5962
 
               type=text_type),
 
5955
               type=str),
5963
5956
        Option('strict',
5964
5957
               help='Refuse to bundle revisions if there are uncommitted'
5965
5958
               ' changes in the working tree, --no-strict disables the check.'),
6089
6082
        from .tag import tag_sort_methods
6090
6083
        branch, relpath = Branch.open_containing(directory)
6091
6084
 
6092
 
        tags = list(viewitems(branch.tags.get_tag_dict()))
 
6085
        tags = list(branch.tags.get_tag_dict().items())
6093
6086
        if not tags:
6094
6087
            return
6095
6088
 
6193
6186
            with_no_trees='Reconfigure repository to not create '
6194
6187
            'working trees on branches by default.'
6195
6188
            ),
6196
 
        Option('bind-to', help='Branch to bind checkout to.', type=text_type),
 
6189
        Option('bind-to', help='Branch to bind checkout to.', type=str),
6197
6190
        Option('force',
6198
6191
               help='Perform reconfiguration even if local changes'
6199
6192
               ' will be lost.'),
6200
6193
        Option('stacked-on',
6201
6194
               help='Reconfigure a branch to be stacked on another branch.',
6202
 
               type=text_type,
 
6195
               type=str,
6203
6196
               ),
6204
6197
        Option('unstacked',
6205
6198
               help='Reconfigure a branch to be unstacked.  This '
6439
6432
               ),
6440
6433
        Option('name',
6441
6434
               help='Name of the view to define, list or delete.',
6442
 
               type=text_type,
 
6435
               type=str,
6443
6436
               ),
6444
6437
        Option('switch',
6445
6438
               help='Name of the view to switch to.',
6446
 
               type=text_type,
 
6439
               type=str,
6447
6440
               ),
6448
6441
        ]
6449
6442
 
6792
6785
    takes_options = [Option('plugin',
6793
6786
                            help='Export help text from named command '
6794
6787
                                 '(defaults to all built in commands).',
6795
 
                            type=text_type),
 
6788
                            type=str),
6796
6789
                     Option('include-duplicates',
6797
6790
                            help='Output multiple copies of the same msgid '
6798
6791
                                 'string if it appears more than once.'),
6898
6891
    takes_options = [
6899
6892
        'verbose',
6900
6893
        'revision',
6901
 
        Option('color', type=text_type, argname='when',
 
6894
        Option('color', type=str, argname='when',
6902
6895
               help='Show match in color. WHEN is never, always or auto.'),
6903
6896
        Option('diff', short_name='p',
6904
6897
               help='Grep for pattern in changeset for each revision.'),
6905
 
        ListOption('exclude', type=text_type, argname='glob', short_name='X',
 
6898
        ListOption('exclude', type=str, argname='glob', short_name='X',
6906
6899
                   help="Skip files whose base name matches GLOB."),
6907
 
        ListOption('include', type=text_type, argname='glob', short_name='I',
 
6900
        ListOption('include', type=str, argname='glob', short_name='I',
6908
6901
                   help="Search only files whose base name matches GLOB."),
6909
6902
        Option('files-with-matches', short_name='l',
6910
6903
               help='Print only the name of each input file in '