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