/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

Support user.signingkey configuration variable in .git/config.

Merged from https://code.launchpad.net/~jelmer/brz/local-git-key/+merge/381000

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