953
955
src_kind = tree.stored_kind(src)
954
956
except errors.NoSuchFile:
955
957
raise errors.BzrCommandError(
956
gettext('Could not copy %s => %s: %s is not versioned.')
958
gettext('Could not copy %s => %s: %s is not versioned.')
958
960
if src_kind is None:
959
961
raise errors.BzrCommandError(
960
962
gettext('Could not copy %s => %s . %s is not versioned\\.'
962
964
if src_kind == 'directory':
963
965
raise errors.BzrCommandError(
964
966
gettext('Could not copy %s => %s . %s is a directory.'
966
968
dst_parent = osutils.split(dst)[0]
967
969
if dst_parent != '':
969
971
dst_parent_kind = tree.stored_kind(dst_parent)
970
972
except errors.NoSuchFile:
971
973
raise errors.BzrCommandError(
972
gettext('Could not copy %s => %s: %s is not versioned.')
973
% (src, dst, dst_parent))
974
gettext('Could not copy %s => %s: %s is not versioned.')
975
% (src, dst, dst_parent))
974
976
if dst_parent_kind != 'directory':
975
977
raise errors.BzrCommandError(
976
gettext('Could not copy to %s: %s is not a directory.')
977
% (dst_parent, dst_parent))
978
gettext('Could not copy to %s: %s is not a directory.')
979
% (dst_parent, dst_parent))
979
981
tree.copy_one(src, dst)
1003
1005
takes_args = ['names*']
1004
1006
takes_options = [Option("after", help="Move only the brz identifier"
1005
" of the file, because the file has already been moved."),
1006
Option('auto', help='Automatically guess renames.'),
1007
Option('dry-run', help='Avoid making changes when guessing renames.'),
1007
" of the file, because the file has already been moved."),
1008
Option('auto', help='Automatically guess renames.'),
1010
'dry-run', help='Avoid making changes when guessing renames.'),
1009
1012
aliases = ['move', 'rename']
1010
1013
encoding_type = 'replace'
1018
1021
names_list = []
1019
1022
if len(names_list) < 2:
1020
1023
raise errors.BzrCommandError(gettext("missing file argument"))
1021
tree, rel_names = WorkingTree.open_containing_paths(names_list, canonicalize=False)
1024
tree, rel_names = WorkingTree.open_containing_paths(
1025
names_list, canonicalize=False)
1022
1026
for file_name in rel_names[0:-1]:
1023
1027
if file_name == '':
1024
raise errors.BzrCommandError(gettext("can not move root of branch"))
1028
raise errors.BzrCommandError(
1029
gettext("can not move root of branch"))
1025
1030
self.add_cleanup(tree.lock_tree_write().unlock)
1026
1031
self._run(tree, names_list, rel_names, after)
1028
1033
def run_auto(self, names_list, after, dry_run):
1029
1034
if names_list is not None and len(names_list) > 1:
1030
1035
raise errors.BzrCommandError(gettext('Only one path may be specified to'
1033
1038
raise errors.BzrCommandError(gettext('--after cannot be specified with'
1035
1040
work_tree, file_list = WorkingTree.open_containing_paths(
1036
1041
names_list, default_directory='.')
1037
1042
self.add_cleanup(work_tree.lock_tree_write().unlock)
1038
1043
rename_map.RenameMap.guess_renames(
1039
work_tree.basis_tree(), work_tree, dry_run)
1044
work_tree.basis_tree(), work_tree, dry_run)
1041
1046
def _run(self, tree, names_list, rel_names, after):
1042
1047
into_existing = osutils.isdir(names_list[-1])
1097
1102
# If 'after' is specified, the tail must refer to a file on disk.
1098
1103
if dest_parent:
1099
dest_parent_fq = osutils.pathjoin(tree.basedir, dest_parent)
1104
dest_parent_fq = osutils.pathjoin(
1105
tree.basedir, dest_parent)
1101
1107
# pathjoin with an empty tail adds a slash, which breaks
1103
1109
dest_parent_fq = tree.basedir
1105
1111
dest_tail = osutils.canonical_relpath(
1107
osutils.pathjoin(dest_parent_fq, spec_tail))
1113
osutils.pathjoin(dest_parent_fq, spec_tail))
1109
1115
# not 'after', so case as specified is used
1110
1116
dest_tail = spec_tail
1151
1157
_see_also = ['push', 'update', 'status-flags', 'send']
1152
1158
takes_options = ['remember', 'overwrite', 'revision',
1153
custom_help('verbose',
1154
help='Show logs of pulled revisions.'),
1155
custom_help('directory',
1156
help='Branch to pull into, '
1157
'rather than the one containing the working directory.'),
1159
help="Perform a local pull in a bound "
1160
"branch. Local pulls are not applied to "
1161
"the master branch."
1164
help="Show base revision text in conflicts."),
1165
Option('overwrite-tags',
1166
help="Overwrite tags only."),
1159
custom_help('verbose',
1160
help='Show logs of pulled revisions.'),
1161
custom_help('directory',
1162
help='Branch to pull into, '
1163
'rather than the one containing the working directory.'),
1165
help="Perform a local pull in a bound "
1166
"branch. Local pulls are not applied to "
1167
"the master branch."
1170
help="Show base revision text in conflicts."),
1171
Option('overwrite-tags',
1172
help="Overwrite tags only."),
1168
1174
takes_args = ['location?']
1169
1175
encoding_type = 'replace'
1297
1304
_see_also = ['pull', 'update', 'working-trees']
1298
1305
takes_options = ['remember', 'overwrite', 'verbose', 'revision',
1299
Option('create-prefix',
1300
help='Create the path leading up to the branch '
1301
'if it does not already exist.'),
1302
custom_help('directory',
1303
help='Branch to push from, '
1304
'rather than the one containing the working directory.'),
1305
Option('use-existing-dir',
1306
help='By default push will fail if the target'
1307
' directory exists, but does not already'
1308
' have a control directory. This flag will'
1309
' allow push to proceed.'),
1311
help='Create a stacked branch that references the public location '
1312
'of the parent branch.'),
1313
Option('stacked-on',
1314
help='Create a stacked branch that refers to another branch '
1315
'for the commit history. Only the work not present in the '
1316
'referenced branch is included in the branch created.',
1319
help='Refuse to push if there are uncommitted changes in'
1320
' the working tree, --no-strict disables the check.'),
1322
help="Don't populate the working tree, even for protocols"
1323
" that support it."),
1324
Option('overwrite-tags',
1325
help="Overwrite tags only."),
1326
Option('lossy', help="Allow lossy push, i.e. dropping metadata "
1327
"that can't be represented in the target.")
1306
Option('create-prefix',
1307
help='Create the path leading up to the branch '
1308
'if it does not already exist.'),
1309
custom_help('directory',
1310
help='Branch to push from, '
1311
'rather than the one containing the working directory.'),
1312
Option('use-existing-dir',
1313
help='By default push will fail if the target'
1314
' directory exists, but does not already'
1315
' have a control directory. This flag will'
1316
' allow push to proceed.'),
1318
help='Create a stacked branch that references the public location '
1319
'of the parent branch.'),
1320
Option('stacked-on',
1321
help='Create a stacked branch that refers to another branch '
1322
'for the commit history. Only the work not present in the '
1323
'referenced branch is included in the branch created.',
1326
help='Refuse to push if there are uncommitted changes in'
1327
' the working tree, --no-strict disables the check.'),
1329
help="Don't populate the working tree, even for protocols"
1330
" that support it."),
1331
Option('overwrite-tags',
1332
help="Overwrite tags only."),
1333
Option('lossy', help="Allow lossy push, i.e. dropping metadata "
1334
"that can't be represented in the target.")
1329
1336
takes_args = ['location?']
1330
1337
encoding_type = 'replace'
1332
1339
def run(self, location=None, remember=None, overwrite=False,
1333
create_prefix=False, verbose=False, revision=None,
1334
use_existing_dir=False, directory=None, stacked_on=None,
1335
stacked=False, strict=None, no_tree=False,
1336
overwrite_tags=False, lossy=False):
1340
create_prefix=False, verbose=False, revision=None,
1341
use_existing_dir=False, directory=None, stacked_on=None,
1342
stacked=False, strict=None, no_tree=False,
1343
overwrite_tags=False, lossy=False):
1337
1344
from .push import _show_push_branch
1387
1394
"No push location known or specified. To push to the "
1388
1395
"parent branch (at %s), use 'brz push :parent'." %
1389
1396
urlutils.unescape_for_display(parent_loc,
1390
self.outf.encoding)))
1397
self.outf.encoding)))
1392
1399
raise errors.BzrCommandError(gettext(
1393
1400
"No push location known or specified."))
1395
1402
display_url = urlutils.unescape_for_display(stored_loc,
1397
1404
note(gettext("Using saved push location: %s") % display_url)
1398
1405
location = stored_loc
1400
1407
_show_push_branch(br_from, revision_id, location, self.outf,
1401
verbose=verbose, overwrite=overwrite, remember=remember,
1402
stacked_on=stacked_on, create_prefix=create_prefix,
1403
use_existing_dir=use_existing_dir, no_tree=no_tree,
1408
verbose=verbose, overwrite=overwrite, remember=remember,
1409
stacked_on=stacked_on, create_prefix=create_prefix,
1410
use_existing_dir=use_existing_dir, no_tree=no_tree,
1407
1414
class cmd_branch(Command):
1421
1428
_see_also = ['checkout']
1422
1429
takes_args = ['from_location', 'to_location?']
1423
1430
takes_options = ['revision',
1424
Option('hardlink', help='Hard-link working tree files where possible.'),
1425
Option('files-from', type=text_type,
1426
help="Get file contents from this tree."),
1428
help="Create a branch without a working-tree."),
1430
help="Switch the checkout in the current directory "
1431
"to the new branch."),
1433
help='Create a stacked branch referring to the source branch. '
1434
'The new branch will depend on the availability of the source '
1435
'branch for all operations.'),
1436
Option('standalone',
1437
help='Do not use a shared repository, even if available.'),
1438
Option('use-existing-dir',
1439
help='By default branch will fail if the target'
1440
' directory exists, but does not already'
1441
' have a control directory. This flag will'
1442
' allow branch to proceed.'),
1444
help="Bind new branch to from location."),
1432
'hardlink', help='Hard-link working tree files where possible.'),
1433
Option('files-from', type=text_type,
1434
help="Get file contents from this tree."),
1436
help="Create a branch without a working-tree."),
1438
help="Switch the checkout in the current directory "
1439
"to the new branch."),
1441
help='Create a stacked branch referring to the source branch. '
1442
'The new branch will depend on the availability of the source '
1443
'branch for all operations.'),
1444
Option('standalone',
1445
help='Do not use a shared repository, even if available.'),
1446
Option('use-existing-dir',
1447
help='By default branch will fail if the target'
1448
' directory exists, but does not already'
1449
' have a control directory. This flag will'
1450
' allow branch to proceed.'),
1452
help="Bind new branch to from location."),
1447
1455
def run(self, from_location, to_location=None, revision=None,
1448
1456
hardlink=False, stacked=False, standalone=False, no_tree=False,
1525
1533
# We therefore need a try/except here and not just 'if stacked:'
1527
1535
note(gettext('Created new stacked branch referring to %s.') %
1528
branch.get_stacked_on_url())
1536
branch.get_stacked_on_url())
1529
1537
except (errors.NotStacked, _mod_branch.UnstackableBranchFormat,
1530
errors.UnstackableRepositoryFormat) as e:
1531
note(ngettext('Branched %d revision.', 'Branched %d revisions.', branch.revno()) % branch.revno())
1538
errors.UnstackableRepositoryFormat) as e:
1539
note(ngettext('Branched %d revision.',
1540
'Branched %d revisions.', branch.revno()) % branch.revno())
1533
1542
# Bind to the parent
1534
1543
parent_branch = Branch.open(from_location)
1863
1872
takes_args = ['file*']
1864
1873
takes_options = ['verbose',
1865
Option('new', help='Only remove files that have never been committed.'),
1866
RegistryOption.from_kwargs('file-deletion-strategy',
1867
'The file deletion mode to be used.',
1868
title='Deletion Strategy', value_switches=True, enum_switch=False,
1869
safe='Backup changed files (default).',
1870
keep='Delete from brz but leave the working copy.',
1871
no_backup='Don\'t backup changed files.'),
1875
'new', help='Only remove files that have never been committed.'),
1876
RegistryOption.from_kwargs('file-deletion-strategy',
1877
'The file deletion mode to be used.',
1878
title='Deletion Strategy', value_switches=True, enum_switch=False,
1879
safe='Backup changed files (default).',
1880
keep='Delete from brz but leave the working copy.',
1881
no_backup='Don\'t backup changed files.'),
1873
1883
aliases = ['rm', 'del']
1874
1884
encoding_type = 'replace'
1876
1886
def run(self, file_list, verbose=False, new=False,
1877
file_deletion_strategy='safe'):
1887
file_deletion_strategy='safe'):
1879
1889
tree, file_list = WorkingTree.open_containing_paths(file_list)
2061
2071
Option('create-prefix',
2062
2072
help='Create the path leading up to the branch '
2063
2073
'if it does not already exist.'),
2064
RegistryOption('format',
2065
help='Specify a format for this branch. '
2066
'See "help formats" for a full list.',
2067
lazy_registry=('breezy.controldir', 'format_registry'),
2068
converter=lambda name: controldir.format_registry.make_controldir(name),
2069
value_switches=True,
2070
title="Branch format",
2072
Option('append-revisions-only',
2073
help='Never change revnos or the existing log.'
2074
' Append revisions to it only.'),
2076
'Create a branch without a working tree.')
2074
RegistryOption('format',
2075
help='Specify a format for this branch. '
2076
'See "help formats" for a full list.',
2077
lazy_registry=('breezy.controldir', 'format_registry'),
2078
converter=lambda name: controldir.format_registry.make_controldir(
2080
value_switches=True,
2081
title="Branch format",
2083
Option('append-revisions-only',
2084
help='Never change revnos or the existing log.'
2085
' Append revisions to it only.'),
2087
'Create a branch without a working tree.')
2078
2090
def run(self, location=None, format=None, append_revisions_only=False,
2079
2091
create_prefix=False, no_tree=False):
2080
2092
if format is None:
2181
2194
_see_also = ['init', 'branch', 'checkout', 'repositories']
2182
2195
takes_args = ["location"]
2183
2196
takes_options = [RegistryOption('format',
2184
help='Specify a format for this repository. See'
2185
' "brz help formats" for details.',
2186
lazy_registry=('breezy.controldir', 'format_registry'),
2187
converter=lambda name: controldir.format_registry.make_controldir(name),
2188
value_switches=True, title='Repository format'),
2197
help='Specify a format for this repository. See'
2198
' "brz help formats" for details.',
2200
'breezy.controldir', 'format_registry'),
2201
converter=lambda name: controldir.format_registry.make_controldir(
2203
value_switches=True, title='Repository format'),
2189
2204
Option('no-trees',
2190
help='Branches in the repository will default to'
2191
' not having a working tree.'),
2205
help='Branches in the repository will default to'
2206
' not having a working tree.'),
2193
2208
aliases = ["init-repo"]
2195
2210
def run(self, location, format=None, no_trees=False):
2209
2224
(repo, newdir, require_stacking, repository_policy) = (
2210
2225
format.initialize_on_transport_ex(to_transport,
2211
create_prefix=True, make_working_trees=not no_trees,
2212
shared_repo=True, force_new_repo=True,
2213
use_existing_dir=True,
2214
repo_format_name=repo_format_name))
2226
create_prefix=True, make_working_trees=not no_trees,
2227
shared_repo=True, force_new_repo=True,
2228
use_existing_dir=True,
2229
repo_format_name=repo_format_name))
2215
2230
if not is_quiet():
2216
2231
from .info import show_bzrdir_info
2217
2232
show_bzrdir_info(newdir, verbose=0, outfile=self.outf)
2313
2328
help='Set prefixes added to old and new filenames, as '
2314
2329
'two values separated by a colon. (eg "old/:new/").'),
2316
help='Branch/tree to compare from.',
2331
help='Branch/tree to compare from.',
2320
help='Branch/tree to compare to.',
2335
help='Branch/tree to compare to.',
2325
2340
Option('using',
2326
help='Use this command to compare files.',
2341
help='Use this command to compare files.',
2329
2344
RegistryOption('format',
2331
help='Diff format to use.',
2332
lazy_registry=('breezy.diff', 'format_registry'),
2333
title='Diff format'),
2346
help='Diff format to use.',
2347
lazy_registry=('breezy.diff', 'format_registry'),
2348
title='Diff format'),
2334
2349
Option('context',
2335
help='How many lines of context to show.',
2350
help='How many lines of context to show.',
2339
2354
aliases = ['di', 'dif']
2340
2355
encoding_type = 'exact'
2649
2664
takes_args = ['file*']
2650
2665
_see_also = ['log-formats', 'revisionspec']
2651
2666
takes_options = [
2653
help='Show from oldest to newest.'),
2655
custom_help('verbose',
2656
help='Show files changed in each revision.'),
2660
type=breezy.option._parse_revision_str,
2662
help='Show just the specified revision.'
2663
' See also "help revisionspec".'),
2665
RegistryOption('authors',
2666
'What names to list as authors - first, all or committer.',
2668
lazy_registry=('breezy.log', 'author_list_registry'),
2672
help='Number of levels to display - 0 for all, 1 for flat.',
2674
type=_parse_levels),
2676
help='Show revisions whose message matches this '
2677
'regular expression.',
2682
help='Limit the output to the first N revisions.',
2687
help='Show changes made in each revision as a patch.'),
2688
Option('include-merged',
2689
help='Show merged revisions like --levels 0 does.'),
2690
Option('include-merges', hidden=True,
2691
help='Historical alias for --include-merged.'),
2692
Option('omit-merges',
2693
help='Do not report commits with more than one parent.'),
2694
Option('exclude-common-ancestry',
2695
help='Display only the revisions that are not part'
2696
' of both ancestries (require -rX..Y).'
2698
Option('signatures',
2699
help='Show digital signature validity.'),
2702
help='Show revisions whose properties match this '
2705
ListOption('match-message',
2706
help='Show revisions whose message matches this '
2709
ListOption('match-committer',
2668
help='Show from oldest to newest.'),
2670
custom_help('verbose',
2671
help='Show files changed in each revision.'),
2675
type=breezy.option._parse_revision_str,
2677
help='Show just the specified revision.'
2678
' See also "help revisionspec".'),
2680
RegistryOption('authors',
2681
'What names to list as authors - first, all or committer.',
2684
'breezy.log', 'author_list_registry'),
2688
help='Number of levels to display - 0 for all, 1 for flat.',
2690
type=_parse_levels),
2692
help='Show revisions whose message matches this '
2693
'regular expression.',
2698
help='Limit the output to the first N revisions.',
2703
help='Show changes made in each revision as a patch.'),
2704
Option('include-merged',
2705
help='Show merged revisions like --levels 0 does.'),
2706
Option('include-merges', hidden=True,
2707
help='Historical alias for --include-merged.'),
2708
Option('omit-merges',
2709
help='Do not report commits with more than one parent.'),
2710
Option('exclude-common-ancestry',
2711
help='Display only the revisions that are not part'
2712
' of both ancestries (require -rX..Y).'
2714
Option('signatures',
2715
help='Show digital signature validity.'),
2718
help='Show revisions whose properties match this '
2721
ListOption('match-message',
2722
help='Show revisions whose message matches this '
2725
ListOption('match-committer',
2710
2726
help='Show revisions whose committer matches this '
2713
ListOption('match-author',
2729
ListOption('match-author',
2714
2730
help='Show revisions whose authors match this '
2717
ListOption('match-bugs',
2733
ListOption('match-bugs',
2718
2734
help='Show revisions whose bugs match this '
2722
2738
encoding_type = 'replace'
2724
2740
@display_command
2967
2984
_see_also = ['status', 'cat']
2968
2985
takes_args = ['path?']
2969
2986
takes_options = [
2972
Option('recursive', short_name='R',
2973
help='Recurse into subdirectories.'),
2975
help='Print paths relative to the root of the branch.'),
2976
Option('unknown', short_name='u',
2977
help='Print unknown files.'),
2978
Option('versioned', help='Print versioned files.',
2980
Option('ignored', short_name='i',
2981
help='Print ignored files.'),
2982
Option('kind', short_name='k',
2983
help=('List entries of a particular kind: file, '
2984
'directory, symlink, tree-reference.'),
2989
Option('recursive', short_name='R',
2990
help='Recurse into subdirectories.'),
2992
help='Print paths relative to the root of the branch.'),
2993
Option('unknown', short_name='u',
2994
help='Print unknown files.'),
2995
Option('versioned', help='Print versioned files.',
2997
Option('ignored', short_name='i',
2998
help='Print ignored files.'),
2999
Option('kind', short_name='k',
3000
help=('List entries of a particular kind: file, '
3001
'directory, symlink, tree-reference.'),
2990
3008
@display_command
2991
3009
def run(self, revision=None, verbose=False,
2992
3010
recursive=False, from_root=False,
2997
3015
raise errors.BzrCommandError(gettext('invalid kind specified'))
2999
3017
if verbose and null:
3000
raise errors.BzrCommandError(gettext('Cannot set both --verbose and --null'))
3018
raise errors.BzrCommandError(
3019
gettext('Cannot set both --verbose and --null'))
3001
3020
all = not (unknown or versioned or ignored)
3003
selection = {'I':ignored, '?':unknown, 'V':versioned}
3022
selection = {'I': ignored, '?': unknown, 'V': versioned}
3005
3024
if path is None:
3009
3028
raise errors.BzrCommandError(gettext('cannot specify both --from-root'
3012
3031
tree, branch, relpath = \
3013
3032
_open_directory_or_containing_tree_or_branch(fs_path, directory)
3301
3321
encoding_type = 'exact'
3302
3322
takes_args = ['dest', 'branch_or_subdir?']
3303
3323
takes_options = ['directory',
3305
help="Type of file to export to.",
3308
Option('filters', help='Apply content filters to export the '
3309
'convenient form.'),
3312
help="Name of the root directory inside the exported file."),
3313
Option('per-file-timestamps',
3314
help='Set modification time of files to that of the last '
3315
'revision in which it was changed.'),
3316
Option('uncommitted',
3317
help='Export the working tree contents rather than that of the '
3325
help="Type of file to export to.",
3328
Option('filters', help='Apply content filters to export the '
3329
'convenient form.'),
3332
help="Name of the root directory inside the exported file."),
3333
Option('per-file-timestamps',
3334
help='Set modification time of files to that of the last '
3335
'revision in which it was changed.'),
3336
Option('uncommitted',
3337
help='Export the working tree contents rather than that of the '
3321
3341
def run(self, dest, branch_or_subdir=None, revision=None, format=None,
3322
root=None, filters=False, per_file_timestamps=False, uncommitted=False,
3342
root=None, filters=False, per_file_timestamps=False, uncommitted=False,
3324
3344
from .export import export, guess_format, get_root_name
3326
3346
if branch_or_subdir is None:
3510
3530
_see_also = ['add', 'bugs', 'hooks', 'uncommit']
3511
3531
takes_args = ['selected*']
3512
3532
takes_options = [
3513
ListOption('exclude', type=text_type, short_name='x',
3514
help="Do not consider changes made to a given path."),
3515
Option('message', type=text_type,
3517
help="Description of the new revision."),
3520
help='Commit even if nothing has changed.'),
3521
Option('file', type=text_type,
3524
help='Take commit message from this file.'),
3526
help="Refuse to commit if there are unknown "
3527
"files in the working tree."),
3528
Option('commit-time', type=text_type,
3529
help="Manually set a commit time using commit date "
3530
"format, e.g. '2009-10-10 08:00:00 +0100'."),
3531
ListOption('fixes', type=text_type,
3532
help="Mark a bug as being fixed by this revision "
3533
"(see \"brz help bugs\")."),
3534
ListOption('author', type=text_type,
3535
help="Set the author's name, if it's different "
3536
"from the committer."),
3538
help="Perform a local commit in a bound "
3539
"branch. Local commits are not pushed to "
3540
"the master branch until a normal commit "
3543
Option('show-diff', short_name='p',
3544
help='When no message is supplied, show the diff along'
3545
' with the status summary in the message editor.'),
3547
help='When committing to a foreign version control '
3548
'system do not push data that can not be natively '
3533
ListOption('exclude', type=text_type, short_name='x',
3534
help="Do not consider changes made to a given path."),
3535
Option('message', type=text_type,
3537
help="Description of the new revision."),
3540
help='Commit even if nothing has changed.'),
3541
Option('file', type=text_type,
3544
help='Take commit message from this file.'),
3546
help="Refuse to commit if there are unknown "
3547
"files in the working tree."),
3548
Option('commit-time', type=text_type,
3549
help="Manually set a commit time using commit date "
3550
"format, e.g. '2009-10-10 08:00:00 +0100'."),
3551
ListOption('fixes', type=text_type,
3552
help="Mark a bug as being fixed by this revision "
3553
"(see \"brz help bugs\")."),
3554
ListOption('author', type=text_type,
3555
help="Set the author's name, if it's different "
3556
"from the committer."),
3558
help="Perform a local commit in a bound "
3559
"branch. Local commits are not pushed to "
3560
"the master branch until a normal commit "
3563
Option('show-diff', short_name='p',
3564
help='When no message is supplied, show the diff along'
3565
' with the status summary in the message editor.'),
3567
help='When committing to a foreign version control '
3568
'system do not push data that can not be natively '
3549
3569
'represented.'),
3551
3571
aliases = ['ci', 'checkin']
3553
3573
def _iter_bug_fix_urls(self, fixes, branch):
3662
3682
# No message supplied: make one up.
3663
3683
# text is the status of the tree
3664
3684
text = make_commit_message_template_encoded(tree,
3665
selected_list, diff=show_diff,
3666
output_encoding=osutils.get_user_encoding())
3685
selected_list, diff=show_diff,
3686
output_encoding=osutils.get_user_encoding())
3667
3687
# start_message is the template generated from hooks
3668
3688
# XXX: Warning - looks like hooks return unicode,
3669
3689
# make_commit_message_template_encoded returns user encoding.
3672
3692
my_message = set_commit_message(commit_obj)
3673
3693
if my_message is None:
3674
start_message = generate_commit_message_template(commit_obj)
3694
start_message = generate_commit_message_template(
3675
3696
if start_message is not None:
3676
3697
start_message = start_message.encode(
3677
osutils.get_user_encoding())
3698
osutils.get_user_encoding())
3678
3699
my_message = edit_commit_message_encoded(text,
3679
start_message=start_message)
3700
start_message=start_message)
3680
3701
if my_message is None:
3681
3702
raise errors.BzrCommandError(gettext("please specify a commit"
3682
" message with either --message or --file"))
3703
" message with either --message or --file"))
3683
3704
if my_message == "":
3684
3705
raise errors.BzrCommandError(gettext("Empty commit message specified."
3685
" Please specify a commit message with either"
3686
" --message or --file or leave a blank message"
3687
" with --message \"\"."))
3706
" Please specify a commit message with either"
3707
" --message or --file or leave a blank message"
3708
" with --message \"\"."))
3688
3709
return my_message
3690
3711
# The API permits a commit with a filter of [] to mean 'select nothing'
3703
3724
except PointlessCommit:
3704
3725
raise errors.BzrCommandError(gettext("No changes to commit."
3705
" Please 'brz add' the files you want to commit, or use"
3706
" --unchanged to force an empty commit."))
3726
" Please 'brz add' the files you want to commit, or use"
3727
" --unchanged to force an empty commit."))
3707
3728
except ConflictsInTree:
3708
3729
raise errors.BzrCommandError(gettext('Conflicts detected in working '
3709
'tree. Use "brz conflicts" to list, "brz resolve FILE" to'
3730
'tree. Use "brz conflicts" to list, "brz resolve FILE" to'
3711
3732
except StrictCommitFailed:
3712
3733
raise errors.BzrCommandError(gettext("Commit refused because there are"
3713
" unknown files in the working tree."))
3734
" unknown files in the working tree."))
3714
3735
except errors.BoundBranchOutOfDate as e:
3715
3736
e.extra_help = (gettext("\n"
3716
'To commit to master branch, run update and then commit.\n'
3717
'You can also pass --local to commit to continue working '
3737
'To commit to master branch, run update and then commit.\n'
3738
'You can also pass --local to commit to continue working '
3826
3847
takes_args = ['url?']
3827
3848
takes_options = [
3828
3849
RegistryOption('format',
3829
help='Upgrade to a specific format. See "brz help'
3830
' formats" for details.',
3831
lazy_registry=('breezy.controldir', 'format_registry'),
3832
converter=lambda name: controldir.format_registry.make_controldir(name),
3833
value_switches=True, title='Branch format'),
3850
help='Upgrade to a specific format. See "brz help'
3851
' formats" for details.',
3852
lazy_registry=('breezy.controldir', 'format_registry'),
3853
converter=lambda name: controldir.format_registry.make_controldir(
3855
value_switches=True, title='Branch format'),
3834
3856
Option('clean',
3835
help='Remove the backup.bzr directory if successful.'),
3857
help='Remove the backup.bzr directory if successful.'),
3836
3858
Option('dry-run',
3837
help="Show what would be done, but don't actually do anything."),
3859
help="Show what would be done, but don't actually do anything."),
3840
3862
def run(self, url='.', format=None, clean=False, dry_run=False):
4102
4125
Option('list-only',
4103
4126
help='List the tests instead of running them.'),
4104
4127
RegistryOption('parallel',
4105
help="Run the test suite in parallel.",
4106
lazy_registry=('breezy.tests', 'parallel_registry'),
4107
value_switches=False,
4128
help="Run the test suite in parallel.",
4130
'breezy.tests', 'parallel_registry'),
4131
value_switches=False,
4109
4133
Option('randomize', type=text_type, argname="SEED",
4110
4134
help='Randomize the order of tests using the given'
4111
4135
' seed or "now" for the current time.'),
4208
4231
self._disable_fsync()
4209
4232
selftest_kwargs = {"verbose": verbose,
4211
"stop_on_failure": one,
4212
"transport": transport,
4213
"test_suite_factory": test_suite_factory,
4214
"lsprof_timed": lsprof_timed,
4215
"lsprof_tests": lsprof_tests,
4216
"matching_tests_first": first,
4217
"list_only": list_only,
4218
"random_seed": randomize,
4219
"exclude_pattern": exclude_pattern,
4221
"load_list": load_list,
4222
"debug_flags": debugflag,
4223
"starting_with": starting_with
4234
"stop_on_failure": one,
4235
"transport": transport,
4236
"test_suite_factory": test_suite_factory,
4237
"lsprof_timed": lsprof_timed,
4238
"lsprof_tests": lsprof_tests,
4239
"matching_tests_first": first,
4240
"list_only": list_only,
4241
"random_seed": randomize,
4242
"exclude_pattern": exclude_pattern,
4244
"load_list": load_list,
4245
"debug_flags": debugflag,
4246
"starting_with": starting_with
4225
4248
selftest_kwargs.update(self.additional_selftest_args)
4227
4250
# Make deprecation warnings visible, unless -Werror is set
4393
4416
Option('uncommitted', help='Apply uncommitted changes'
4394
4417
' from a working copy, instead of branch changes.'),
4395
4418
Option('pull', help='If the destination is already'
4396
' completely merged into the source, pull from the'
4397
' source rather than merging. When this happens,'
4398
' you do not need to commit the result.'),
4419
' completely merged into the source, pull from the'
4420
' source rather than merging. When this happens,'
4421
' you do not need to commit the result.'),
4399
4422
custom_help('directory',
4400
help='Branch to merge into, '
4423
help='Branch to merge into, '
4401
4424
'rather than the one containing the working directory.'),
4402
4425
Option('preview', help='Instead of merging, show a diff of the'
4404
4427
Option('interactive', help='Select changes interactively.',
4408
4431
def run(self, location=None, revision=None, force=False,
4441
4464
if location is not None:
4443
4466
mergeable = bundle.read_mergeable_from_url(location,
4444
possible_transports=possible_transports)
4467
possible_transports=possible_transports)
4445
4468
except errors.NotABundle:
4446
4469
mergeable = None
4448
4471
if uncommitted:
4449
4472
raise errors.BzrCommandError(gettext('Cannot use --uncommitted'
4450
' with bundles or merge directives.'))
4473
' with bundles or merge directives.'))
4452
4475
if revision is not None:
4453
4476
raise errors.BzrCommandError(gettext(
4454
4477
'Cannot use -r with merge directives or bundles'))
4455
4478
merger, verified = _mod_merge.Merger.from_mergeable(tree,
4458
4481
if merger is None and uncommitted:
4459
4482
if revision is not None and len(revision) > 0:
4460
4483
raise errors.BzrCommandError(gettext('Cannot use --uncommitted and'
4461
' --revision at the same time.'))
4484
' --revision at the same time.'))
4462
4485
merger = self.get_merger_from_uncommitted(tree, location, None)
4463
4486
allow_pending = False
4465
4488
if merger is None:
4466
4489
merger, allow_pending = self._get_merger_from_branch(tree,
4467
location, revision, remember, possible_transports, None)
4490
location, revision, remember, possible_transports, None)
4469
4492
merger.merge_type = merge_type
4470
4493
merger.reprocess = reprocess
4471
4494
merger.show_base = show_base
4472
4495
self.sanity_check_merger(merger)
4473
4496
if (merger.base_rev_id == merger.other_rev_id and
4474
merger.other_rev_id is not None):
4497
merger.other_rev_id is not None):
4475
4498
# check if location is a nonexistent file (and not a branch) to
4476
4499
# disambiguate the 'Nothing to do'
4477
4500
if merger.interesting_files:
4478
4501
if not merger.other_tree.has_filename(
4479
merger.interesting_files[0]):
4502
merger.interesting_files[0]):
4480
4503
note(gettext("merger: ") + str(merger))
4481
4504
raise errors.PathsDoNotExist([location])
4482
4505
note(gettext('Nothing to do.'))
4484
4507
if pull and not preview:
4485
4508
if merger.interesting_files is not None:
4486
raise errors.BzrCommandError(gettext('Cannot pull individual files'))
4509
raise errors.BzrCommandError(
4510
gettext('Cannot pull individual files'))
4487
4511
if (merger.base_rev_id == tree.last_revision()):
4488
4512
result = tree.pull(merger.other_branch, False,
4489
4513
merger.other_rev_id)
4571
4595
(merger.base_tree is not None and
4572
4596
not getattr(merger.base_tree, 'plan_file_merge', None)))):
4573
4597
raise errors.BzrCommandError(
4574
gettext('Plan file merge unsupported: '
4575
'Merge type incompatible with tree formats.'))
4598
gettext('Plan file merge unsupported: '
4599
'Merge type incompatible with tree formats.'))
4577
4601
def _get_merger_from_branch(self, tree, location, revision, remember,
4578
4602
possible_transports, pb):
4579
4603
"""Produce a merger from a location, assuming it refers to a branch."""
4580
4604
# find the branch locations
4581
4605
other_loc, user_location = self._select_branch_location(tree, location,
4583
4607
if revision is not None and len(revision) == 2:
4584
4608
base_loc, _unused = self._select_branch_location(tree,
4585
location, revision, 0)
4609
location, revision, 0)
4587
4611
base_loc = other_loc
4588
4612
# Open the branches
4589
4613
other_branch, other_path = Branch.open_containing(other_loc,
4590
possible_transports)
4614
possible_transports)
4591
4615
if base_loc == other_loc:
4592
4616
base_branch = other_branch
4594
4618
base_branch, base_path = Branch.open_containing(base_loc,
4595
possible_transports)
4619
possible_transports)
4596
4620
# Find the revision ids
4597
4621
other_revision_id = None
4598
4622
base_revision_id = None
4610
4634
# - user ask to remember or there is no previous location set to merge
4611
4635
# from and user didn't ask to *not* remember
4612
4636
if (user_location is not None
4614
or (remember is None
4615
and tree.branch.get_submit_branch() is None)))):
4638
(remember is None and
4639
tree.branch.get_submit_branch() is None)))):
4616
4640
tree.branch.set_submit_branch(other_branch.base)
4617
4641
# Merge tags (but don't set them in the master branch yet, the user
4618
4642
# might revert this merge). Commit will propagate them.
4619
4643
other_branch.tags.merge_to(tree.branch.tags, ignore_master=True)
4620
4644
merger = _mod_merge.Merger.from_revision_ids(tree,
4621
other_revision_id, base_revision_id, other_branch, base_branch)
4645
other_revision_id, base_revision_id, other_branch, base_branch)
4622
4646
if other_path != '':
4623
4647
allow_pending = False
4624
4648
merger.interesting_files = [other_path]
4956
4981
custom_help('revision',
4957
help='Filter on other branch revisions (inclusive). '
4958
'See "help revisionspec" for details.'),
4982
help='Filter on other branch revisions (inclusive). '
4983
'See "help revisionspec" for details.'),
4959
4984
Option('my-revision',
4960
type=_parse_revision_str,
4961
help='Filter on local branch revisions (inclusive). '
4962
'See "help revisionspec" for details.'),
4985
type=_parse_revision_str,
4986
help='Filter on local branch revisions (inclusive). '
4987
'See "help revisionspec" for details.'),
4963
4988
Option('include-merged',
4964
4989
'Show all revisions in addition to the mainline ones.'),
4965
4990
Option('include-merges', hidden=True,
5234
5261
# If there is a tree and we're not annotating historical
5235
5262
# versions, annotate the working tree's content.
5236
5263
annotate_file_tree(wt, relpath, self.outf, long, all,
5237
show_ids=show_ids, file_id=file_id)
5264
show_ids=show_ids, file_id=file_id)
5239
5266
annotate_file_tree(tree, relpath, self.outf, long, all,
5240
show_ids=show_ids, branch=branch, file_id=file_id)
5267
show_ids=show_ids, branch=branch, file_id=file_id)
5243
5270
class cmd_re_sign(Command):
5244
5271
__doc__ = """Create a digital signature for an existing revision."""
5245
5272
# TODO be able to replace existing ones.
5247
hidden = True # is this right ?
5274
hidden = True # is this right ?
5248
5275
takes_args = ['revision_id*']
5249
5276
takes_options = ['directory', 'revision']
5251
5278
def run(self, revision_id_list=None, revision=None, directory=u'.'):
5252
5279
if revision_id_list is not None and revision is not None:
5253
raise errors.BzrCommandError(gettext('You can only supply one of revision_id or --revision'))
5280
raise errors.BzrCommandError(
5281
gettext('You can only supply one of revision_id or --revision'))
5254
5282
if revision_id_list is None and revision is None:
5255
raise errors.BzrCommandError(gettext('You must supply either --revision or a revision_id'))
5283
raise errors.BzrCommandError(
5284
gettext('You must supply either --revision or a revision_id'))
5256
5285
b = WorkingTree.open_containing(directory)[0].branch
5257
5286
self.add_cleanup(b.lock_write().unlock)
5258
5287
return self._run(b, revision_id_list, revision)
5387
5418
# information in shared branches as well.
5388
5419
_see_also = ['commit']
5389
5420
takes_options = ['verbose', 'revision',
5390
Option('dry-run', help='Don\'t actually make changes.'),
5391
Option('force', help='Say yes to all questions.'),
5393
help='Keep tags that point to removed revisions.'),
5395
help="Only remove the commits from the local branch"
5396
" when in a checkout."
5421
Option('dry-run', help='Don\'t actually make changes.'),
5422
Option('force', help='Say yes to all questions.'),
5424
help='Keep tags that point to removed revisions.'),
5426
help="Only remove the commits from the local branch"
5427
" when in a checkout."
5399
5430
takes_args = ['location?']
5401
5432
encoding_type = 'replace'
5621
5654
# XXX: Would be better to just raise a nicely printable
5622
5655
# exception from the real origin. Also below. mbp 20070306
5623
5656
raise errors.BzrCommandError(
5624
gettext("Cannot join {0}. {1}").format(tree, e.reason))
5657
gettext("Cannot join {0}. {1}").format(tree, e.reason))
5627
5660
containing_tree.subsume(sub_tree)
5628
5661
except errors.BadSubsumeSource as e:
5629
5662
raise errors.BzrCommandError(
5630
gettext("Cannot join {0}. {1}").format(tree, e.reason))
5663
gettext("Cannot join {0}. {1}").format(tree, e.reason))
5633
5666
class cmd_split(Command):
5682
5715
takes_options = [
5684
5717
RegistryOption.from_kwargs('patch-type',
5685
'The type of patch to include in the directive.',
5687
value_switches=True,
5689
bundle='Bazaar revision bundle (default).',
5690
diff='Normal unified diff.',
5691
plain='No patch, just directive.'),
5718
'The type of patch to include in the directive.',
5720
value_switches=True,
5722
bundle='Bazaar revision bundle (default).',
5723
diff='Normal unified diff.',
5724
plain='No patch, just directive.'),
5692
5725
Option('sign', help='GPG-sign the directive.'), 'revision',
5693
5726
Option('mail-to', type=text_type,
5694
help='Instead of printing the directive, email to this address.'),
5727
help='Instead of printing the directive, email to this address.'),
5695
5728
Option('message', type=text_type, short_name='m',
5696
help='Message to use when committing this merge.')
5729
help='Message to use when committing this merge.')
5699
5732
encoding_type = 'exact'
5950
5984
from .send import send
5951
5985
return send(submit_branch, revision, public_branch, remember,
5952
format, no_bundle, no_patch, output,
5953
kwargs.get('from', '.'), None, None, None,
5954
self.outf, strict=strict)
5986
format, no_bundle, no_patch, output,
5987
kwargs.get('from', '.'), None, None, None,
5988
self.outf, strict=strict)
5957
5991
class cmd_tag(Command):
6156
6191
help='Whether new branches in the repository have trees.',
6157
6192
value_switches=True, enum_switch=False,
6158
6193
with_trees='Reconfigure repository to create '
6159
'working trees on branches by default.',
6194
'working trees on branches by default.',
6160
6195
with_no_trees='Reconfigure repository to not create '
6161
'working trees on branches by default.'
6196
'working trees on branches by default.'
6163
6198
Option('bind-to', help='Branch to bind checkout to.', type=text_type),
6164
6199
Option('force',
6165
help='Perform reconfiguration even if local changes'
6200
help='Perform reconfiguration even if local changes'
6167
6202
Option('stacked-on',
6168
help='Reconfigure a branch to be stacked on another branch.',
6203
help='Reconfigure a branch to be stacked on another branch.',
6171
6206
Option('unstacked',
6172
help='Reconfigure a branch to be unstacked. This '
6173
'may require copying substantial data into it.',
6207
help='Reconfigure a branch to be unstacked. This '
6208
'may require copying substantial data into it.',
6177
6212
def run(self, location=None, bind_to=None, force=False,
6253
6289
takes_args = ['to_location?']
6254
6290
takes_options = ['directory',
6255
6291
Option('force',
6256
help='Switch even if local commits will be lost.'),
6292
help='Switch even if local commits will be lost.'),
6258
6294
Option('create-branch', short_name='b',
6259
help='Create the target branch from this one before'
6260
' switching to it.'),
6295
help='Create the target branch from this one before'
6296
' switching to it.'),
6261
6297
Option('store',
6262
help='Store and restore uncommitted changes in the'
6298
help='Store and restore uncommitted changes in the'
6266
6302
def run(self, to_location=None, force=False, create_branch=False,
6267
6303
revision=None, directory=u'.', store=False):
6288
6324
raise errors.BzrCommandError(
6289
6325
gettext('cannot create branch without source branch'))
6290
6326
to_location = lookup_new_sibling_branch(control_dir, to_location,
6291
possible_transports=possible_transports)
6327
possible_transports=possible_transports)
6292
6328
to_branch = branch.controldir.sprout(to_location,
6293
possible_transports=possible_transports,
6294
source_branch=branch).open_branch()
6329
possible_transports=possible_transports,
6330
source_branch=branch).open_branch()
6297
6333
to_branch = Branch.open(to_location,
6298
possible_transports=possible_transports)
6334
possible_transports=possible_transports)
6299
6335
except errors.NotBranchError:
6300
6336
to_branch = open_sibling_branch(control_dir, to_location,
6301
possible_transports=possible_transports)
6337
possible_transports=possible_transports)
6302
6338
if revision is not None:
6303
6339
revision = revision.as_revision_id(to_branch)
6306
6342
store_uncommitted=store)
6307
6343
except controldir.BranchReferenceLoop:
6308
6344
raise errors.BzrCommandError(
6309
gettext('switching would create a branch reference loop. '
6310
'Use the "bzr up" command to switch to a '
6311
'different revision.'))
6345
gettext('switching would create a branch reference loop. '
6346
'Use the "bzr up" command to switch to a '
6347
'different revision.'))
6312
6348
if had_explicit_nick:
6313
branch = control_dir.open_branch() #get the new branch!
6349
branch = control_dir.open_branch() # get the new branch!
6314
6350
branch.nick = to_branch.nick
6315
6351
note(gettext('Switched to branch: %s'),
6316
urlutils.unescape_for_display(to_branch.base, 'utf-8'))
6352
urlutils.unescape_for_display(to_branch.base, 'utf-8'))
6320
6355
class cmd_view(Command):
6433
6469
"Both --switch and --all specified"))
6434
6470
elif switch == 'off':
6435
6471
if current_view is None:
6436
raise errors.BzrCommandError(gettext("No current view to disable"))
6472
raise errors.BzrCommandError(
6473
gettext("No current view to disable"))
6437
6474
tree.views.set_view_info(None, view_dict)
6438
self.outf.write(gettext("Disabled '%s' view.\n") % (current_view))
6475
self.outf.write(gettext("Disabled '%s' view.\n") %
6440
6478
tree.views.set_view_info(switch, view_dict)
6441
6479
view_str = views.view_display_str(tree.views.lookup_view())
6442
self.outf.write(gettext("Using '{0}' view: {1}\n").format(switch, view_str))
6481
gettext("Using '{0}' view: {1}\n").format(switch, view_str))
6445
6484
self.outf.write(gettext('Views defined:\n'))
6817
6858
# register lazy builtins from other modules; called at startup and should
6818
6859
# be only called once.
6819
6860
for (name, aliases, module_name) in [
6820
('cmd_bisect', [], 'breezy.bisect'),
6821
('cmd_bundle_info', [], 'breezy.bundle.commands'),
6822
('cmd_config', [], 'breezy.config'),
6823
('cmd_dump_btree', [], 'breezy.bzr.debug_commands'),
6824
('cmd_version_info', [], 'breezy.cmd_version_info'),
6825
('cmd_resolve', ['resolved'], 'breezy.conflicts'),
6826
('cmd_conflicts', [], 'breezy.conflicts'),
6827
('cmd_ping', [], 'breezy.bzr.smart.ping'),
6828
('cmd_sign_my_commits', [], 'breezy.commit_signature_commands'),
6829
('cmd_verify_signatures', [], 'breezy.commit_signature_commands'),
6830
('cmd_test_script', [], 'breezy.cmd_test_script'),
6861
('cmd_bisect', [], 'breezy.bisect'),
6862
('cmd_bundle_info', [], 'breezy.bundle.commands'),
6863
('cmd_config', [], 'breezy.config'),
6864
('cmd_dump_btree', [], 'breezy.bzr.debug_commands'),
6865
('cmd_version_info', [], 'breezy.cmd_version_info'),
6866
('cmd_resolve', ['resolved'], 'breezy.conflicts'),
6867
('cmd_conflicts', [], 'breezy.conflicts'),
6868
('cmd_ping', [], 'breezy.bzr.smart.ping'),
6869
('cmd_sign_my_commits', [], 'breezy.commit_signature_commands'),
6870
('cmd_verify_signatures', [], 'breezy.commit_signature_commands'),
6871
('cmd_test_script', [], 'breezy.cmd_test_script'),
6832
6873
builtin_command_registry.register_lazy(name, aliases, module_name)