/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: 2020-03-22 01:35:14 UTC
  • mfrom: (7490.7.6 work)
  • mto: This revision was merged to the branch mainline in revision 7499.
  • Revision ID: jelmer@jelmer.uk-20200322013514-7vw1ntwho04rcuj3
merge lp:brz/3.1.

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