/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-03 23:21:15 UTC
  • mfrom: (7290.42.6 paramiko-compat)
  • Revision ID: breezy.the.bot@gmail.com-20200203232115-g7k11bhsfeiqcprv
Fix compatibility with newer versions of paramiko, which break on noise before keys in pem files.

Merged from https://code.launchpad.net/~jelmer/brz/paramiko-compat/+merge/378480

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