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
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
218
227
repo = ref_branch.controldir.find_repository()
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.',
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',
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]
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))))
1627
1637
class cmd_checkout(Command):
1655
1665
"common operations like diff and status without "
1656
1666
"such access, and also support local commits."
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/").'),
2341
2351
help='Branch/tree to compare from.',
2345
2355
help='Branch/tree to compare to.',
2350
2360
Option('using',
2351
2361
help='Use this command to compare files.',
2354
2364
RegistryOption('format',
2355
2365
short_name='F',
2750
2760
short_name='m',
2751
2761
help='Show revisions whose properties match this '
2754
2764
ListOption('match-message',
2755
2765
help='Show revisions whose message matches this '
2758
2768
ListOption('match-committer',
2759
2769
help='Show revisions whose committer matches this '
2762
2772
ListOption('match-author',
2763
2773
help='Show revisions whose authors match this '
2766
2776
ListOption('match-bugs',
2767
2777
help='Show revisions whose bugs match this '
2771
2781
encoding_type = 'replace'
3032
3042
Option('kind', short_name='k',
3033
3043
help=('List entries of a particular kind: file, '
3034
3044
'directory, symlink, tree-reference.'),
3356
3366
takes_options = ['directory',
3357
3367
Option('format',
3358
3368
help="Type of file to export to.",
3361
3371
Option('filters', help='Apply content filters to export the '
3362
3372
'convenient form.'),
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 = [
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."),
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'."),
3595
'bugs', type=text_type,
3586
3596
help="Link to a related bug. (see \"brz help bugs\")."),
3598
'fixes', type=text_type,
3589
3599
help="Mark a bug as being fixed by this revision "
3590
3600
"(see \"brz help bugs\")."),
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))
4061
4071
@display_command
4172
4182
'breezy.tests', 'parallel_registry'),
4173
4183
value_switches=False,
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.'),
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:
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 '
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.')
5914
5924
help='Branch to generate the submission from, '
5915
5925
'rather than the one containing the working directory.',
5916
5926
short_name='f',
5918
5928
Option('output', short_name='o',
5919
5929
help='Write merge directive to this file or directory; '
5920
5930
'use - for stdout.',
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.',
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',
5986
5996
Option('output', short_name='o', help='Write directive to this file.',
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)
6117
tags = list(branch.tags.get_tag_dict().items())
6127
tags = list(viewitems(branch.tags.get_tag_dict()))
6218
6228
with_no_trees='Reconfigure repository to not create '
6219
6229
'working trees on branches by default.'
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.',
6229
6239
Option('unstacked',
6230
6240
help='Reconfigure a branch to be unstacked. This '
6817
6827
takes_options = [Option('plugin',
6818
6828
help='Export help text from named command '
6819
6829
'(defaults to all built in commands).',
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 = [
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 '