234
230
Not versioned and not matching an ignore pattern.
236
Additionally for directories, symlinks and files with a changed
237
executable bit, Bazaar indicates their type using a trailing
238
character: '/', '@' or '*' respectively. These decorations can be
239
disabled using the '--no-classify' option.
232
Additionally for directories, symlinks and files with an executable
233
bit, Bazaar indicates their type using a trailing character: '/', '@'
241
236
To see ignored files use 'bzr ignored'. For details on the
242
237
changes to file texts, use 'bzr diff'.
286
278
def run(self, show_ids=False, file_list=None, revision=None, short=False,
287
versioned=False, no_pending=False, verbose=False,
279
versioned=False, no_pending=False, verbose=False):
289
280
from bzrlib.status import show_tree_status
291
282
if revision and len(revision) > 2:
292
raise errors.BzrCommandError(gettext('bzr status --revision takes exactly'
293
' one or two revision specifiers'))
283
raise errors.BzrCommandError('bzr status --revision takes exactly'
284
' one or two revision specifiers')
295
286
tree, relfile_list = WorkingTree.open_containing_paths(file_list)
296
287
# Avoid asking for specific files when that is not needed.
305
296
show_tree_status(tree, show_ids=show_ids,
306
297
specific_files=relfile_list, revision=revision,
307
298
to_file=self.outf, short=short, versioned=versioned,
308
show_pending=(not no_pending), verbose=verbose,
309
classify=not no_classify)
299
show_pending=(not no_pending), verbose=verbose)
312
302
class cmd_cat_revision(Command):
334
324
def run(self, revision_id=None, revision=None, directory=u'.'):
335
325
if revision_id is not None and revision is not None:
336
raise errors.BzrCommandError(gettext('You can only supply one of'
337
' revision_id or --revision'))
326
raise errors.BzrCommandError('You can only supply one of'
327
' revision_id or --revision')
338
328
if revision_id is None and revision is None:
339
raise errors.BzrCommandError(gettext('You must supply either'
340
' --revision or a revision_id'))
329
raise errors.BzrCommandError('You must supply either'
330
' --revision or a revision_id')
342
332
b = bzrdir.BzrDir.open_containing_tree_or_branch(directory)[1]
344
334
revisions = b.repository.revisions
345
335
if revisions is None:
346
raise errors.BzrCommandError(gettext('Repository %r does not support '
347
'access to raw revision texts'))
336
raise errors.BzrCommandError('Repository %r does not support '
337
'access to raw revision texts')
349
339
b.repository.lock_read()
355
345
self.print_revision(revisions, revision_id)
356
346
except errors.NoSuchRevision:
357
msg = gettext("The repository {0} contains no revision {1}.").format(
347
msg = "The repository %s contains no revision %s." % (
358
348
b.repository.base, revision_id)
359
349
raise errors.BzrCommandError(msg)
360
350
elif revision is not None:
361
351
for rev in revision:
363
353
raise errors.BzrCommandError(
364
gettext('You cannot specify a NULL revision.'))
354
'You cannot specify a NULL revision.')
365
355
rev_id = rev.as_revision_id(b)
366
356
self.print_revision(revisions, rev_id)
479
469
working = d.open_workingtree()
480
470
except errors.NoWorkingTree:
481
raise errors.BzrCommandError(gettext("No working tree to remove"))
471
raise errors.BzrCommandError("No working tree to remove")
482
472
except errors.NotLocalUrl:
483
raise errors.BzrCommandError(gettext("You cannot remove the working tree"
484
" of a remote path"))
473
raise errors.BzrCommandError("You cannot remove the working tree"
486
476
if (working.has_changes()):
487
477
raise errors.UncommittedChanges(working)
540
530
tree.reset_state(revision_ids)
541
531
except errors.BzrError, e:
542
532
if revision_ids is None:
543
extra = (gettext(', the header appears corrupt, try passing -r -1'
544
' to set the state to the last commit'))
533
extra = (', the header appears corrupt, try passing -r -1'
534
' to set the state to the last commit')
547
raise errors.BzrCommandError(gettext('failed to reset the tree state{0}').format(extra))
537
raise errors.BzrCommandError('failed to reset the tree state'
550
541
class cmd_revno(Command):
793
776
def run(self, revision=None, show_ids=False, kind=None, file_list=None):
794
777
if kind and kind not in ['file', 'directory', 'symlink']:
795
raise errors.BzrCommandError(gettext('invalid kind %r specified') % (kind,))
778
raise errors.BzrCommandError('invalid kind %r specified' % (kind,))
797
780
revision = _get_one_revision('inventory', revision)
798
781
work_tree, file_list = WorkingTree.open_containing_paths(file_list)
863
845
return self.run_auto(names_list, after, dry_run)
865
raise errors.BzrCommandError(gettext('--dry-run requires --auto.'))
847
raise errors.BzrCommandError('--dry-run requires --auto.')
866
848
if names_list is None:
868
850
if len(names_list) < 2:
869
raise errors.BzrCommandError(gettext("missing file argument"))
851
raise errors.BzrCommandError("missing file argument")
870
852
tree, rel_names = WorkingTree.open_containing_paths(names_list, canonicalize=False)
871
853
self.add_cleanup(tree.lock_tree_write().unlock)
872
854
self._run(tree, names_list, rel_names, after)
874
856
def run_auto(self, names_list, after, dry_run):
875
857
if names_list is not None and len(names_list) > 1:
876
raise errors.BzrCommandError(gettext('Only one path may be specified to'
858
raise errors.BzrCommandError('Only one path may be specified to'
879
raise errors.BzrCommandError(gettext('--after cannot be specified with'
861
raise errors.BzrCommandError('--after cannot be specified with'
881
863
work_tree, file_list = WorkingTree.open_containing_paths(
882
864
names_list, default_directory='.')
883
865
self.add_cleanup(work_tree.lock_tree_write().unlock)
980
962
match the remote one, use pull --overwrite. This will work even if the two
981
963
branches have diverged.
983
If there is no default location set, the first pull will set it (use
984
--no-remember to avoid setting it). After that, you can omit the
985
location to use the default. To change the default, use --remember. The
986
value will only be saved if the remote location can be accessed.
965
If there is no default location set, the first pull will set it. After
966
that, you can omit the location to use the default. To change the
967
default, use --remember. The value will only be saved if the remote
968
location can be accessed.
988
970
Note: The location can be specified either in the form of a branch,
989
971
or in the form of a path to a file containing a merge directive generated
1008
990
takes_args = ['location?']
1009
991
encoding_type = 'replace'
1011
def run(self, location=None, remember=None, overwrite=False,
993
def run(self, location=None, remember=False, overwrite=False,
1012
994
revision=None, verbose=False,
1013
995
directory=None, local=False,
1014
996
show_base=False):
1043
1025
stored_loc = branch_to.get_parent()
1044
1026
if location is None:
1045
1027
if stored_loc is None:
1046
raise errors.BzrCommandError(gettext("No pull location known or"
1028
raise errors.BzrCommandError("No pull location known or"
1049
1031
display_url = urlutils.unescape_for_display(stored_loc,
1050
1032
self.outf.encoding)
1051
1033
if not is_quiet():
1052
self.outf.write(gettext("Using saved parent location: %s\n") % display_url)
1034
self.outf.write("Using saved parent location: %s\n" % display_url)
1053
1035
location = stored_loc
1055
1037
revision = _get_one_revision('pull', revision)
1056
1038
if mergeable is not None:
1057
1039
if revision is not None:
1058
raise errors.BzrCommandError(gettext(
1059
'Cannot use -r with merge directives or bundles'))
1040
raise errors.BzrCommandError(
1041
'Cannot use -r with merge directives or bundles')
1060
1042
mergeable.install_revisions(branch_to.repository)
1061
1043
base_revision_id, revision_id, verified = \
1062
1044
mergeable.get_merge_request(branch_to.repository)
1080
1061
view_info=view_info)
1081
1062
result = tree_to.pull(
1082
1063
branch_from, overwrite, revision_id, change_reporter,
1083
local=local, show_base=show_base)
1064
possible_transports=possible_transports, local=local,
1065
show_base=show_base)
1085
1067
result = branch_to.pull(
1086
1068
branch_from, overwrite, revision_id, local=local)
1116
1098
do a merge (see bzr help merge) from the other branch, and commit that.
1117
1099
After that you will be able to do a push without '--overwrite'.
1119
If there is no default push location set, the first push will set it (use
1120
--no-remember to avoid setting it). After that, you can omit the
1121
location to use the default. To change the default, use --remember. The
1122
value will only be saved if the remote location can be accessed.
1101
If there is no default push location set, the first push will set it.
1102
After that, you can omit the location to use the default. To change the
1103
default, use --remember. The value will only be saved if the remote
1104
location can be accessed.
1125
1107
_see_also = ['pull', 'update', 'working-trees']
1153
1135
takes_args = ['location?']
1154
1136
encoding_type = 'replace'
1156
def run(self, location=None, remember=None, overwrite=False,
1138
def run(self, location=None, remember=False, overwrite=False,
1157
1139
create_prefix=False, verbose=False, revision=None,
1158
1140
use_existing_dir=False, directory=None, stacked_on=None,
1159
1141
stacked=False, strict=None, no_tree=False):
1190
1172
# error by the feedback given to them. RBC 20080227.
1191
1173
stacked_on = parent_url
1192
1174
if not stacked_on:
1193
raise errors.BzrCommandError(gettext(
1194
"Could not determine branch to refer to."))
1175
raise errors.BzrCommandError(
1176
"Could not determine branch to refer to.")
1196
1178
# Get the destination location
1197
1179
if location is None:
1198
1180
stored_loc = br_from.get_push_location()
1199
1181
if stored_loc is None:
1200
raise errors.BzrCommandError(gettext(
1201
"No push location known or specified."))
1182
raise errors.BzrCommandError(
1183
"No push location known or specified.")
1203
1185
display_url = urlutils.unescape_for_display(stored_loc,
1204
1186
self.outf.encoding)
1205
note(gettext("Using saved push location: %s") % display_url)
1187
self.outf.write("Using saved push location: %s\n" % display_url)
1206
1188
location = stored_loc
1208
1190
_show_push_branch(br_from, revision_id, location, self.outf,
1260
1240
files_from=None):
1261
1241
from bzrlib import switch as _mod_switch
1262
1242
from bzrlib.tag import _merge_tags_if_possible
1263
if self.invoked_as in ['get', 'clone']:
1264
ui.ui_factory.show_user_warning(
1265
'deprecated_command',
1266
deprecated_name=self.invoked_as,
1267
recommended_name='branch',
1268
deprecated_in_version='2.4')
1269
1243
accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch(
1271
1245
if not (hardlink or files_from):
1315
1289
branch = dir.open_branch()
1316
1290
except errors.NoSuchRevision:
1317
1291
to_transport.delete_tree('.')
1318
msg = gettext("The branch {0} has no revision {1}.").format(
1319
from_location, revision)
1292
msg = "The branch %s has no revision %s." % (from_location,
1320
1294
raise errors.BzrCommandError(msg)
1321
1295
_merge_tags_if_possible(br_from, branch)
1322
1296
# If the source branch is stacked, the new branch may
1323
1297
# be stacked whether we asked for that explicitly or not.
1324
1298
# We therefore need a try/except here and not just 'if stacked:'
1326
note(gettext('Created new stacked branch referring to %s.') %
1300
note('Created new stacked branch referring to %s.' %
1327
1301
branch.get_stacked_on_url())
1328
1302
except (errors.NotStacked, errors.UnstackableBranchFormat,
1329
1303
errors.UnstackableRepositoryFormat), e:
1330
note(ngettext('Branched %d revision.', 'Branched %d revisions.', branch.revno()) % branch.revno())
1304
note('Branched %d revision(s).' % branch.revno())
1332
1306
# Bind to the parent
1333
1307
parent_branch = Branch.open(from_location)
1334
1308
branch.bind(parent_branch)
1335
note(gettext('New branch bound to %s') % from_location)
1309
note('New branch bound to %s' % from_location)
1337
1311
# Switch to the new branch
1338
1312
wt, _ = WorkingTree.open_containing('.')
1339
1313
_mod_switch.switch(wt.bzrdir, branch)
1340
note(gettext('Switched to branch: %s'),
1314
note('Switched to branch: %s',
1341
1315
urlutils.unescape_for_display(branch.base, 'utf-8'))
1344
class cmd_branches(Command):
1345
__doc__ = """List the branches available at the current location.
1347
This command will print the names of all the branches at the current
1351
takes_args = ['location?']
1353
Option('recursive', short_name='R',
1354
help='Recursively scan for branches rather than '
1355
'just looking in the specified location.')]
1357
def run(self, location=".", recursive=False):
1359
t = transport.get_transport(location)
1360
if not t.listable():
1361
raise errors.BzrCommandError(
1362
"Can't scan this type of location.")
1363
for b in bzrdir.BzrDir.find_branches(t):
1364
self.outf.write("%s\n" % urlutils.unescape_for_display(
1365
urlutils.relative_url(t.base, b.base),
1366
self.outf.encoding).rstrip("/"))
1368
dir = bzrdir.BzrDir.open_containing(location)[0]
1369
for branch in dir.list_branches():
1370
if branch.name is None:
1371
self.outf.write(gettext(" (default)\n"))
1373
self.outf.write(" %s\n" % branch.name.encode(
1374
self.outf.encoding))
1377
1318
class cmd_checkout(Command):
1378
1319
__doc__ = """Create a new checkout of an existing branch.
1506
1447
def run(self, dir='.', revision=None, show_base=None):
1507
1448
if revision is not None and len(revision) != 1:
1508
raise errors.BzrCommandError(gettext(
1509
"bzr update --revision takes exactly one revision"))
1449
raise errors.BzrCommandError(
1450
"bzr update --revision takes exactly one revision")
1510
1451
tree = WorkingTree.open_containing(dir)[0]
1511
1452
branch = tree.branch
1512
1453
possible_transports = []
1537
1478
revision_id = branch.last_revision()
1538
1479
if revision_id == _mod_revision.ensure_null(tree.last_revision()):
1539
1480
revno = branch.revision_id_to_dotted_revno(revision_id)
1540
note(gettext("Tree is up to date at revision {0} of branch {1}"
1541
).format('.'.join(map(str, revno)), branch_location))
1481
note("Tree is up to date at revision %s of branch %s" %
1482
('.'.join(map(str, revno)), branch_location))
1543
1484
view_info = _get_view_info_for_change_reporter(tree)
1544
1485
change_reporter = delta._ChangeReporter(
1552
1493
old_tip=old_tip,
1553
1494
show_base=show_base)
1554
1495
except errors.NoSuchRevision, e:
1555
raise errors.BzrCommandError(gettext(
1496
raise errors.BzrCommandError(
1556
1497
"branch has no revision %s\n"
1557
1498
"bzr update --revision only works"
1558
" for a revision in the branch history")
1499
" for a revision in the branch history"
1559
1500
% (e.revision))
1560
1501
revno = tree.branch.revision_id_to_dotted_revno(
1561
1502
_mod_revision.ensure_null(tree.last_revision()))
1562
note(gettext('Updated to revision {0} of branch {1}').format(
1563
'.'.join(map(str, revno)), branch_location))
1503
note('Updated to revision %s of branch %s' %
1504
('.'.join(map(str, revno)), branch_location))
1564
1505
parent_ids = tree.get_parent_ids()
1565
1506
if parent_ids[1:] and parent_ids[1:] != existing_pending_merges:
1566
note(gettext('Your local commits will now show as pending merges with '
1567
"'bzr status', and can be committed with 'bzr commit'."))
1507
note('Your local commits will now show as pending merges with '
1508
"'bzr status', and can be committed with 'bzr commit'.")
1568
1509
if conflicts != 0:
1642
1583
def run(self, file_list, verbose=False, new=False,
1643
1584
file_deletion_strategy='safe'):
1644
1585
if file_deletion_strategy == 'force':
1645
note(gettext("(The --force option is deprecated, rather use --no-backup "
1586
note("(The --force option is deprecated, rather use --no-backup "
1647
1588
file_deletion_strategy = 'no-backup'
1649
1590
tree, file_list = WorkingTree.open_containing_paths(file_list)
1789
1730
last_revision = wt.last_revision()
1791
self.add_cleanup(b.repository.lock_read().unlock)
1792
graph = b.repository.get_graph()
1793
revisions = [revid for revid, parents in
1794
graph.iter_ancestry([last_revision])]
1795
for revision_id in reversed(revisions):
1796
if _mod_revision.is_null(revision_id):
1732
revision_ids = b.repository.get_ancestry(last_revision)
1734
for revision_id in revision_ids:
1798
1735
self.outf.write(revision_id + '\n')
1904
1841
repository = branch.repository
1905
1842
layout = describe_layout(repository, branch, tree).lower()
1906
1843
format = describe_format(a_bzrdir, repository, branch, tree)
1907
self.outf.write(gettext("Created a {0} (format: {1})\n").format(
1844
self.outf.write("Created a %s (format: %s)\n" % (layout, format))
1909
1845
if repository.is_shared():
1910
1846
#XXX: maybe this can be refactored into transport.path_or_url()
1911
1847
url = repository.bzrdir.root_transport.external_url()
2110
2046
elif ':' in prefix:
2111
2047
old_label, new_label = prefix.split(":")
2113
raise errors.BzrCommandError(gettext(
2049
raise errors.BzrCommandError(
2114
2050
'--prefix expects two values separated by a colon'
2115
' (eg "old/:new/")'))
2051
' (eg "old/:new/")')
2117
2053
if revision and len(revision) > 2:
2118
raise errors.BzrCommandError(gettext('bzr diff --revision takes exactly'
2119
' one or two revision specifiers'))
2054
raise errors.BzrCommandError('bzr diff --revision takes exactly'
2055
' one or two revision specifiers')
2121
2057
if using is not None and format is not None:
2122
raise errors.BzrCommandError(gettext(
2123
'{0} and {1} are mutually exclusive').format(
2124
'--using', '--format'))
2058
raise errors.BzrCommandError('--using and --format are mutually '
2126
2061
(old_tree, new_tree,
2127
2062
old_branch, new_branch,
2360
2295
:Other filtering:
2362
The --match option can be used for finding revisions that match a
2363
regular expression in a commit message, committer, author or bug.
2364
Specifying the option several times will match any of the supplied
2365
expressions. --match-author, --match-bugs, --match-committer and
2366
--match-message can be used to only match a specific field.
2297
The --message option can be used for finding revisions that match a
2298
regular expression in a commit message.
2368
2300
:Tips & tricks:
2441
2373
Option('show-diff',
2442
2374
short_name='p',
2443
2375
help='Show changes made in each revision as a patch.'),
2444
Option('include-merged',
2376
Option('include-merges',
2445
2377
help='Show merged revisions like --levels 0 does.'),
2446
Option('include-merges', hidden=True,
2447
help='Historical alias for --include-merged.'),
2448
Option('omit-merges',
2449
help='Do not report commits with more than one parent.'),
2450
2378
Option('exclude-common-ancestry',
2451
2379
help='Display only the revisions that are not part'
2452
2380
' of both ancestries (require -rX..Y)'
2454
Option('signatures',
2455
help='Show digital signature validity'),
2458
help='Show revisions whose properties match this '
2461
ListOption('match-message',
2462
help='Show revisions whose message matches this '
2465
ListOption('match-committer',
2466
help='Show revisions whose committer matches this '
2469
ListOption('match-author',
2470
help='Show revisions whose authors match this '
2473
ListOption('match-bugs',
2474
help='Show revisions whose bugs match this '
2478
2383
encoding_type = 'replace'
2507
2404
_get_info_for_log_files,
2509
2406
direction = (forward and 'forward') or 'reverse'
2510
if symbol_versioning.deprecated_passed(include_merges):
2511
ui.ui_factory.show_user_warning(
2512
'deprecated_command_option',
2513
deprecated_name='--include-merges',
2514
recommended_name='--include-merged',
2515
deprecated_in_version='2.5',
2516
command=self.invoked_as)
2517
if include_merged is None:
2518
include_merged = include_merges
2520
raise errors.BzrCommandError(gettext(
2521
'{0} and {1} are mutually exclusive').format(
2522
'--include-merges', '--include-merged'))
2523
if include_merged is None:
2524
include_merged = False
2525
2407
if (exclude_common_ancestry
2526
2408
and (revision is None or len(revision) != 2)):
2527
raise errors.BzrCommandError(gettext(
2528
'--exclude-common-ancestry requires -r with two revisions'))
2409
raise errors.BzrCommandError(
2410
'--exclude-common-ancestry requires -r with two revisions')
2530
2412
if levels is None:
2533
raise errors.BzrCommandError(gettext(
2534
'{0} and {1} are mutually exclusive').format(
2535
'--levels', '--include-merged'))
2415
raise errors.BzrCommandError(
2416
'--levels and --include-merges are mutually exclusive')
2537
2418
if change is not None:
2538
2419
if len(change) > 1:
2539
2420
raise errors.RangeInChangeOption()
2540
2421
if revision is not None:
2541
raise errors.BzrCommandError(gettext(
2542
'{0} and {1} are mutually exclusive').format(
2543
'--revision', '--change'))
2422
raise errors.BzrCommandError(
2423
'--revision and --change are mutually exclusive')
2545
2425
revision = change
2552
2432
revision, file_list, self.add_cleanup)
2553
2433
for relpath, file_id, kind in file_info_list:
2554
2434
if file_id is None:
2555
raise errors.BzrCommandError(gettext(
2556
"Path unknown at end or start of revision range: %s") %
2435
raise errors.BzrCommandError(
2436
"Path unknown at end or start of revision range: %s" %
2558
2438
# If the relpath is the top of the tree, we log everything
2559
2439
if relpath == '':
2576
2456
self.add_cleanup(b.lock_read().unlock)
2577
2457
rev1, rev2 = _get_revision_range(revision, b, self.name())
2579
if b.get_config().validate_signatures_in_log():
2583
if not gpg.GPGStrategy.verify_signatures_available():
2584
raise errors.GpgmeNotInstalled(None)
2586
2459
# Decide on the type of delta & diff filtering to use
2587
2460
# TODO: add an --all-files option to make this configurable & consistent
2588
2461
if not verbose:
2645
2506
start_revision=rev1, end_revision=rev2, limit=limit,
2646
2507
message_search=message, delta_type=delta_type,
2647
2508
diff_type=diff_type, _match_using_deltas=match_using_deltas,
2648
exclude_common_ancestry=exclude_common_ancestry, match=match_dict,
2649
signature=signatures, omit_merges=omit_merges,
2509
exclude_common_ancestry=exclude_common_ancestry,
2651
2511
Logger(b, rqst).show(lf)
2669
2529
# b is taken from revision[0].get_branch(), and
2670
2530
# show_log will use its revision_history. Having
2671
2531
# different branches will lead to weird behaviors.
2672
raise errors.BzrCommandError(gettext(
2532
raise errors.BzrCommandError(
2673
2533
"bzr %s doesn't accept two revisions in different"
2674
" branches.") % command_name)
2534
" branches." % command_name)
2675
2535
if start_spec.spec is None:
2676
2536
# Avoid loading all the history.
2677
2537
rev1 = RevisionInfo(branch, None, None)
2763
2623
null=False, kind=None, show_ids=False, path=None, directory=None):
2765
2625
if kind and kind not in ('file', 'directory', 'symlink'):
2766
raise errors.BzrCommandError(gettext('invalid kind specified'))
2626
raise errors.BzrCommandError('invalid kind specified')
2768
2628
if verbose and null:
2769
raise errors.BzrCommandError(gettext('Cannot set both --verbose and --null'))
2629
raise errors.BzrCommandError('Cannot set both --verbose and --null')
2770
2630
all = not (unknown or versioned or ignored)
2772
2632
selection = {'I':ignored, '?':unknown, 'V':versioned}
2951
2811
self.outf.write("%s\n" % pattern)
2953
2813
if not name_pattern_list:
2954
raise errors.BzrCommandError(gettext("ignore requires at least one "
2955
"NAME_PATTERN or --default-rules."))
2814
raise errors.BzrCommandError("ignore requires at least one "
2815
"NAME_PATTERN or --default-rules.")
2956
2816
name_pattern_list = [globbing.normalize_pattern(p)
2957
2817
for p in name_pattern_list]
2958
2818
bad_patterns = ''
2959
bad_patterns_count = 0
2960
2819
for p in name_pattern_list:
2961
2820
if not globbing.Globster.is_pattern_valid(p):
2962
bad_patterns_count += 1
2963
2821
bad_patterns += ('\n %s' % p)
2964
2822
if bad_patterns:
2965
msg = (ngettext('Invalid ignore pattern found. %s',
2966
'Invalid ignore patterns found. %s',
2967
bad_patterns_count) % bad_patterns)
2823
msg = ('Invalid ignore pattern(s) found. %s' % bad_patterns)
2968
2824
ui.ui_factory.show_error(msg)
2969
2825
raise errors.InvalidPattern('')
2970
2826
for name_pattern in name_pattern_list:
2971
2827
if (name_pattern[0] == '/' or
2972
2828
(len(name_pattern) > 1 and name_pattern[1] == ':')):
2973
raise errors.BzrCommandError(gettext(
2974
"NAME_PATTERN should not be an absolute path"))
2829
raise errors.BzrCommandError(
2830
"NAME_PATTERN should not be an absolute path")
2975
2831
tree, relpath = WorkingTree.open_containing(directory)
2976
2832
ignores.tree_ignores_add_patterns(tree, name_pattern_list)
2977
2833
ignored = globbing.Globster(name_pattern_list)
2984
2840
if ignored.match(filename):
2985
2841
matches.append(filename)
2986
2842
if len(matches) > 0:
2987
self.outf.write(gettext("Warning: the following files are version "
2988
"controlled and match your ignore pattern:\n%s"
2843
self.outf.write("Warning: the following files are version controlled and"
2844
" match your ignore pattern:\n%s"
2989
2845
"\nThese files will continue to be version controlled"
2990
" unless you 'bzr remove' them.\n") % ("\n".join(matches),))
2846
" unless you 'bzr remove' them.\n" % ("\n".join(matches),))
2993
2849
class cmd_ignored(Command):
3099
2954
export(rev_tree, dest, format, root, subdir, filtered=filters,
3100
2955
per_file_timestamps=per_file_timestamps)
3101
2956
except errors.NoSuchExportFormat, e:
3102
raise errors.BzrCommandError(gettext('Unsupported export format: %s') % e.format)
2957
raise errors.BzrCommandError('Unsupported export format: %s' % e.format)
3105
2960
class cmd_cat(Command):
3125
2980
def run(self, filename, revision=None, name_from_revision=False,
3126
2981
filters=False, directory=None):
3127
2982
if revision is not None and len(revision) != 1:
3128
raise errors.BzrCommandError(gettext("bzr cat --revision takes exactly"
3129
" one revision specifier"))
2983
raise errors.BzrCommandError("bzr cat --revision takes exactly"
2984
" one revision specifier")
3130
2985
tree, branch, relpath = \
3131
2986
_open_directory_or_containing_tree_or_branch(filename, directory)
3132
2987
self.add_cleanup(branch.lock_read().unlock)
3143
2998
old_file_id = rev_tree.path2id(relpath)
3145
# TODO: Split out this code to something that generically finds the
3146
# best id for a path across one or more trees; it's like
3147
# find_ids_across_trees but restricted to find just one. -- mbp
3149
3000
if name_from_revision:
3150
3001
# Try in revision if requested
3151
3002
if old_file_id is None:
3152
raise errors.BzrCommandError(gettext(
3153
"{0!r} is not present in revision {1}").format(
3003
raise errors.BzrCommandError(
3004
"%r is not present in revision %s" % (
3154
3005
filename, rev_tree.get_revision_id()))
3156
actual_file_id = old_file_id
3007
content = rev_tree.get_file_text(old_file_id)
3158
3009
cur_file_id = tree.path2id(relpath)
3159
if cur_file_id is not None and rev_tree.has_id(cur_file_id):
3160
actual_file_id = cur_file_id
3161
elif old_file_id is not None:
3162
actual_file_id = old_file_id
3164
raise errors.BzrCommandError(gettext(
3165
"{0!r} is not present in revision {1}").format(
3011
if cur_file_id is not None:
3012
# Then try with the actual file id
3014
content = rev_tree.get_file_text(cur_file_id)
3016
except errors.NoSuchId:
3017
# The actual file id didn't exist at that time
3019
if not found and old_file_id is not None:
3020
# Finally try with the old file id
3021
content = rev_tree.get_file_text(old_file_id)
3024
# Can't be found anywhere
3025
raise errors.BzrCommandError(
3026
"%r is not present in revision %s" % (
3166
3027
filename, rev_tree.get_revision_id()))
3168
from bzrlib.filter_tree import ContentFilterTree
3169
filter_tree = ContentFilterTree(rev_tree,
3170
rev_tree._content_filter_stack)
3171
content = filter_tree.get_file_text(actual_file_id)
3029
from bzrlib.filters import (
3030
ContentFilterContext,
3031
filtered_output_bytes,
3033
filters = rev_tree._content_filter_stack(relpath)
3034
chunks = content.splitlines(True)
3035
content = filtered_output_bytes(chunks, filters,
3036
ContentFilterContext(relpath, rev_tree))
3038
self.outf.writelines(content)
3173
content = rev_tree.get_file_text(actual_file_id)
3175
self.outf.write(content)
3041
self.outf.write(content)
3178
3044
class cmd_local_time_offset(Command):
3239
3105
to trigger updates to external systems like bug trackers. The --fixes
3240
3106
option can be used to record the association between a revision and
3241
3107
one or more bugs. See ``bzr help bugs`` for details.
3109
A selective commit may fail in some cases where the committed
3110
tree would be invalid. Consider::
3115
bzr commit foo -m "committing foo"
3116
bzr mv foo/bar foo/baz
3119
bzr commit foo/bar -m "committing bar but not baz"
3121
In the example above, the last commit will fail by design. This gives
3122
the user the opportunity to decide whether they want to commit the
3123
rename at the same time, separately first, or not at all. (As a general
3124
rule, when in doubt, Bazaar has a policy of Doing the Safe Thing.)
3126
# TODO: Run hooks on tree to-be-committed, and after commit.
3128
# TODO: Strict commit that fails if there are deleted files.
3129
# (what does "deleted files" mean ??)
3131
# TODO: Give better message for -s, --summary, used by tla people
3133
# XXX: verbose currently does nothing
3244
3135
_see_also = ['add', 'bugs', 'hooks', 'uncommit']
3245
3136
takes_args = ['selected*']
3277
3168
Option('show-diff', short_name='p',
3278
3169
help='When no message is supplied, show the diff along'
3279
3170
' with the status summary in the message editor.'),
3281
help='When committing to a foreign version control '
3282
'system do not push data that can not be natively '
3285
3172
aliases = ['ci', 'checkin']
3287
3174
def _iter_bug_fix_urls(self, fixes, branch):
3288
default_bugtracker = None
3289
3175
# Configure the properties for bug fixing attributes.
3290
3176
for fixed_bug in fixes:
3291
3177
tokens = fixed_bug.split(':')
3292
if len(tokens) == 1:
3293
if default_bugtracker is None:
3294
branch_config = branch.get_config()
3295
default_bugtracker = branch_config.get_user_option(
3297
if default_bugtracker is None:
3298
raise errors.BzrCommandError(gettext(
3299
"No tracker specified for bug %s. Use the form "
3300
"'tracker:id' or specify a default bug tracker "
3301
"using the `bugtracker` option.\nSee "
3302
"\"bzr help bugs\" for more information on this "
3303
"feature. Commit refused.") % fixed_bug)
3304
tag = default_bugtracker
3306
elif len(tokens) != 2:
3307
raise errors.BzrCommandError(gettext(
3178
if len(tokens) != 2:
3179
raise errors.BzrCommandError(
3308
3180
"Invalid bug %s. Must be in the form of 'tracker:id'. "
3309
3181
"See \"bzr help bugs\" for more information on this "
3310
"feature.\nCommit refused.") % fixed_bug)
3312
tag, bug_id = tokens
3182
"feature.\nCommit refused." % fixed_bug)
3183
tag, bug_id = tokens
3314
3185
yield bugtracker.get_bug_url(tag, branch, bug_id)
3315
3186
except errors.UnknownBugTrackerAbbreviation:
3316
raise errors.BzrCommandError(gettext(
3317
'Unrecognized bug %s. Commit refused.') % fixed_bug)
3187
raise errors.BzrCommandError(
3188
'Unrecognized bug %s. Commit refused.' % fixed_bug)
3318
3189
except errors.MalformedBugIdentifier, e:
3319
raise errors.BzrCommandError(gettext(
3320
"%s\nCommit refused.") % (str(e),))
3190
raise errors.BzrCommandError(
3191
"%s\nCommit refused." % (str(e),))
3322
3193
def run(self, message=None, file=None, verbose=False, selected_list=None,
3323
3194
unchanged=False, strict=False, local=False, fixes=None,
3324
author=None, show_diff=False, exclude=None, commit_time=None,
3195
author=None, show_diff=False, exclude=None, commit_time=None):
3326
3196
from bzrlib.errors import (
3327
3197
PointlessCommit,
3328
3198
ConflictsInTree,
3341
3210
commit_stamp, offset = timestamp.parse_patch_date(commit_time)
3342
3211
except ValueError, e:
3343
raise errors.BzrCommandError(gettext(
3344
"Could not parse --commit-time: " + str(e)))
3212
raise errors.BzrCommandError(
3213
"Could not parse --commit-time: " + str(e))
3215
# TODO: Need a blackbox test for invoking the external editor; may be
3216
# slightly problematic to run this cross-platform.
3218
# TODO: do more checks that the commit will succeed before
3219
# spending the user's valuable time typing a commit message.
3346
3221
properties = {}
3380
3255
message = message.replace('\r\n', '\n')
3381
3256
message = message.replace('\r', '\n')
3383
raise errors.BzrCommandError(gettext(
3384
"please specify either --message or --file"))
3258
raise errors.BzrCommandError(
3259
"please specify either --message or --file")
3386
3261
def get_message(commit_obj):
3387
3262
"""Callback to get commit message"""
3404
3279
# make_commit_message_template_encoded returns user encoding.
3405
3280
# We probably want to be using edit_commit_message instead to
3407
my_message = set_commit_message(commit_obj)
3408
if my_message is None:
3409
start_message = generate_commit_message_template(commit_obj)
3410
my_message = edit_commit_message_encoded(text,
3411
start_message=start_message)
3412
if my_message is None:
3413
raise errors.BzrCommandError(gettext("please specify a commit"
3414
" message with either --message or --file"))
3415
if my_message == "":
3416
raise errors.BzrCommandError(gettext("Empty commit message specified."
3417
" Please specify a commit message with either"
3418
" --message or --file or leave a blank message"
3419
" with --message \"\"."))
3282
start_message = generate_commit_message_template(commit_obj)
3283
my_message = edit_commit_message_encoded(text,
3284
start_message=start_message)
3285
if my_message is None:
3286
raise errors.BzrCommandError("please specify a commit"
3287
" message with either --message or --file")
3288
if my_message == "":
3289
raise errors.BzrCommandError("empty commit message specified")
3420
3290
return my_message
3422
3292
# The API permits a commit with a filter of [] to mean 'select nothing'
3430
3300
reporter=None, verbose=verbose, revprops=properties,
3431
3301
authors=author, timestamp=commit_stamp,
3432
3302
timezone=offset,
3433
exclude=tree.safe_relpath_files(exclude),
3303
exclude=tree.safe_relpath_files(exclude))
3435
3304
except PointlessCommit:
3436
raise errors.BzrCommandError(gettext("No changes to commit."
3437
" Please 'bzr add' the files you want to commit, or use"
3438
" --unchanged to force an empty commit."))
3305
raise errors.BzrCommandError("No changes to commit."
3306
" Use --unchanged to commit anyhow.")
3439
3307
except ConflictsInTree:
3440
raise errors.BzrCommandError(gettext('Conflicts detected in working '
3308
raise errors.BzrCommandError('Conflicts detected in working '
3441
3309
'tree. Use "bzr conflicts" to list, "bzr resolve FILE" to'
3443
3311
except StrictCommitFailed:
3444
raise errors.BzrCommandError(gettext("Commit refused because there are"
3445
" unknown files in the working tree."))
3312
raise errors.BzrCommandError("Commit refused because there are"
3313
" unknown files in the working tree.")
3446
3314
except errors.BoundBranchOutOfDate, e:
3447
e.extra_help = (gettext("\n"
3315
e.extra_help = ("\n"
3448
3316
'To commit to master branch, run update and then commit.\n'
3449
3317
'You can also pass --local to commit to continue working '
3707
3575
def remove_alias(self, alias_name):
3708
3576
if alias_name is None:
3709
raise errors.BzrCommandError(gettext(
3710
'bzr alias --remove expects an alias to remove.'))
3577
raise errors.BzrCommandError(
3578
'bzr alias --remove expects an alias to remove.')
3711
3579
# If alias is not found, print something like:
3712
3580
# unalias: foo: not found
3713
3581
c = _mod_config.GlobalConfig()
3792
3660
if typestring == "sftp":
3793
3661
from bzrlib.tests import stub_sftp
3794
3662
return stub_sftp.SFTPAbsoluteServer
3795
elif typestring == "memory":
3663
if typestring == "memory":
3796
3664
from bzrlib.tests import test_server
3797
3665
return memory.MemoryServer
3798
elif typestring == "fakenfs":
3666
if typestring == "fakenfs":
3799
3667
from bzrlib.tests import test_server
3800
3668
return test_server.FakeNFSServer
3801
3669
msg = "No known transport type %s. Supported types are: sftp\n" %\
3835
3703
Option('randomize', type=str, argname="SEED",
3836
3704
help='Randomize the order of tests using the given'
3837
3705
' seed or "now" for the current time.'),
3838
ListOption('exclude', type=str, argname="PATTERN",
3840
help='Exclude tests that match this regular'
3706
Option('exclude', type=str, argname="PATTERN",
3708
help='Exclude tests that match this regular'
3842
3710
Option('subunit',
3843
3711
help='Output test progress via subunit.'),
3844
3712
Option('strict', help='Fail on missing dependencies or '
3867
3732
first=False, list_only=False,
3868
3733
randomize=None, exclude=None, strict=False,
3869
3734
load_list=None, debugflag=None, starting_with=None, subunit=False,
3870
parallel=None, lsprof_tests=False,
3735
parallel=None, lsprof_tests=False):
3872
3736
from bzrlib import tests
3874
3738
if testspecs_list is not None:
3880
3744
from bzrlib.tests import SubUnitBzrRunner
3881
3745
except ImportError:
3882
raise errors.BzrCommandError(gettext("subunit not available. subunit "
3883
"needs to be installed to use --subunit."))
3746
raise errors.BzrCommandError("subunit not available. subunit "
3747
"needs to be installed to use --subunit.")
3884
3748
self.additional_selftest_args['runner_class'] = SubUnitBzrRunner
3885
3749
# On Windows, disable automatic conversion of '\n' to '\r\n' in
3886
3750
# stdout, which would corrupt the subunit stream.
3895
3759
self.additional_selftest_args.setdefault(
3896
3760
'suite_decorators', []).append(parallel)
3898
raise errors.BzrCommandError(gettext(
3762
raise errors.BzrCommandError(
3899
3763
"--benchmark is no longer supported from bzr 2.2; "
3900
"use bzr-usertest instead"))
3764
"use bzr-usertest instead")
3901
3765
test_suite_factory = None
3903
exclude_pattern = None
3905
exclude_pattern = '(' + '|'.join(exclude) + ')'
3907
self._disable_fsync()
3908
3766
selftest_kwargs = {"verbose": verbose,
3909
3767
"pattern": pattern,
3910
3768
"stop_on_failure": one,
3933
3791
return int(not result)
3935
def _disable_fsync(self):
3936
"""Change the 'os' functionality to not synchronize."""
3937
self._orig_fsync = getattr(os, 'fsync', None)
3938
if self._orig_fsync is not None:
3939
os.fsync = lambda filedes: None
3940
self._orig_fdatasync = getattr(os, 'fdatasync', None)
3941
if self._orig_fdatasync is not None:
3942
os.fdatasync = lambda filedes: None
3945
3794
class cmd_version(Command):
3946
3795
__doc__ = """Show version of bzr."""
3999
3848
The source of the merge can be specified either in the form of a branch,
4000
3849
or in the form of a path to a file containing a merge directive generated
4001
3850
with bzr send. If neither is specified, the default is the upstream branch
4002
or the branch most recently merged using --remember. The source of the
4003
merge may also be specified in the form of a path to a file in another
4004
branch: in this case, only the modifications to that file are merged into
4005
the current working tree.
3851
or the branch most recently merged using --remember.
4007
3853
When merging from a branch, by default bzr will try to merge in all new
4008
3854
work from the other branch, automatically determining an appropriate base
4015
3861
through OTHER, excluding BASE but including OTHER, will be merged. If this
4016
3862
causes some revisions to be skipped, i.e. if the destination branch does
4017
3863
not already contain revision BASE, such a merge is commonly referred to as
4018
a "cherrypick". Unlike a normal merge, Bazaar does not currently track
4019
cherrypicks. The changes look like a normal commit, and the history of the
4020
changes from the other branch is not stored in the commit.
4022
3866
Revision numbers are always relative to the source branch.
4029
3873
Use bzr resolve when you have fixed a problem. See also bzr conflicts.
4031
If there is no default branch set, the first merge will set it (use
4032
--no-remember to avoid setting it). After that, you can omit the branch
4033
to use the default. To change the default, use --remember. The value will
4034
only be saved if the remote location can be accessed.
3875
If there is no default branch set, the first merge will set it. After
3876
that, you can omit the branch to use the default. To change the
3877
default, use --remember. The value will only be saved if the remote
3878
location can be accessed.
4036
3880
The results of the merge are placed into the destination working
4037
3881
directory, where they can be reviewed (with bzr diff), tested, and then
4038
3882
committed to record the result of the merge.
4040
3884
merge refuses to run if there are any uncommitted changes, unless
4041
--force is given. If --force is given, then the changes from the source
4042
will be merged with the current working tree, including any uncommitted
4043
changes in the tree. The --force option can also be used to create a
3885
--force is given. The --force option can also be used to create a
4044
3886
merge revision which has more than two parents.
4046
3888
If one would like to merge changes from the working tree of the other
4106
3948
def run(self, location=None, revision=None, force=False,
4107
merge_type=None, show_base=False, reprocess=None, remember=None,
3949
merge_type=None, show_base=False, reprocess=None, remember=False,
4108
3950
uncommitted=False, pull=False,
4109
3951
directory=None,
4148
3986
mergeable = None
4150
3988
if uncommitted:
4151
raise errors.BzrCommandError(gettext('Cannot use --uncommitted'
4152
' with bundles or merge directives.'))
3989
raise errors.BzrCommandError('Cannot use --uncommitted'
3990
' with bundles or merge directives.')
4154
3992
if revision is not None:
4155
raise errors.BzrCommandError(gettext(
4156
'Cannot use -r with merge directives or bundles'))
3993
raise errors.BzrCommandError(
3994
'Cannot use -r with merge directives or bundles')
4157
3995
merger, verified = _mod_merge.Merger.from_mergeable(tree,
4158
3996
mergeable, None)
4160
3998
if merger is None and uncommitted:
4161
3999
if revision is not None and len(revision) > 0:
4162
raise errors.BzrCommandError(gettext('Cannot use --uncommitted and'
4163
' --revision at the same time.'))
4000
raise errors.BzrCommandError('Cannot use --uncommitted and'
4001
' --revision at the same time.')
4164
4002
merger = self.get_merger_from_uncommitted(tree, location, None)
4165
4003
allow_pending = False
4174
4012
self.sanity_check_merger(merger)
4175
4013
if (merger.base_rev_id == merger.other_rev_id and
4176
4014
merger.other_rev_id is not None):
4177
# check if location is a nonexistent file (and not a branch) to
4178
# disambiguate the 'Nothing to do'
4179
if merger.interesting_files:
4180
if not merger.other_tree.has_filename(
4181
merger.interesting_files[0]):
4182
note(gettext("merger: ") + str(merger))
4183
raise errors.PathsDoNotExist([location])
4184
note(gettext('Nothing to do.'))
4015
note('Nothing to do.')
4186
if pull and not preview:
4187
4018
if merger.interesting_files is not None:
4188
raise errors.BzrCommandError(gettext('Cannot pull individual files'))
4019
raise errors.BzrCommandError('Cannot pull individual files')
4189
4020
if (merger.base_rev_id == tree.last_revision()):
4190
4021
result = tree.pull(merger.other_branch, False,
4191
4022
merger.other_rev_id)
4192
4023
result.report(self.outf)
4194
4025
if merger.this_basis is None:
4195
raise errors.BzrCommandError(gettext(
4026
raise errors.BzrCommandError(
4196
4027
"This branch has no commits."
4197
" (perhaps you would prefer 'bzr pull')"))
4028
" (perhaps you would prefer 'bzr pull')")
4199
4030
return self._do_preview(merger)
4200
4031
elif interactive:
4260
4091
# Use reprocess if the merger supports it
4261
4092
merger.reprocess = merger.merge_type.supports_reprocess
4262
4093
if merger.reprocess and not merger.merge_type.supports_reprocess:
4263
raise errors.BzrCommandError(gettext("Conflict reduction is not supported"
4264
" for merge type %s.") %
4094
raise errors.BzrCommandError("Conflict reduction is not supported"
4095
" for merge type %s." %
4265
4096
merger.merge_type)
4266
4097
if merger.reprocess and merger.show_base:
4267
raise errors.BzrCommandError(gettext("Cannot do conflict reduction and"
4098
raise errors.BzrCommandError("Cannot do conflict reduction and"
4270
4101
def _get_merger_from_branch(self, tree, location, revision, remember,
4271
4102
possible_transports, pb):
4298
4129
if other_revision_id is None:
4299
4130
other_revision_id = _mod_revision.ensure_null(
4300
4131
other_branch.last_revision())
4301
# Remember where we merge from. We need to remember if:
4302
# - user specify a location (and we don't merge from the parent
4304
# - user ask to remember or there is no previous location set to merge
4305
# from and user didn't ask to *not* remember
4306
if (user_location is not None
4308
or (remember is None
4309
and tree.branch.get_submit_branch() is None)))):
4132
# Remember where we merge from
4133
if ((remember or tree.branch.get_submit_branch() is None) and
4134
user_location is not None):
4310
4135
tree.branch.set_submit_branch(other_branch.base)
4311
4136
# Merge tags (but don't set them in the master branch yet, the user
4312
4137
# might revert this merge). Commit will propagate them.
4375
4200
stored_location_type = "parent"
4376
4201
mutter("%s", stored_location)
4377
4202
if stored_location is None:
4378
raise errors.BzrCommandError(gettext("No location specified or remembered"))
4203
raise errors.BzrCommandError("No location specified or remembered")
4379
4204
display_url = urlutils.unescape_for_display(stored_location, 'utf-8')
4380
note(gettext("{0} remembered {1} location {2}").format(verb_string,
4381
stored_location_type, display_url))
4205
note(u"%s remembered %s location %s", verb_string,
4206
stored_location_type, display_url)
4382
4207
return stored_location
4648
4473
type=_parse_revision_str,
4649
4474
help='Filter on local branch revisions (inclusive). '
4650
4475
'See "help revisionspec" for details.'),
4651
Option('include-merged',
4476
Option('include-merges',
4652
4477
'Show all revisions in addition to the mainline ones.'),
4653
Option('include-merges', hidden=True,
4654
help='Historical alias for --include-merged.'),
4656
4479
encoding_type = 'replace'
4660
4483
theirs_only=False,
4661
4484
log_format=None, long=False, short=False, line=False,
4662
4485
show_ids=False, verbose=False, this=False, other=False,
4663
include_merged=None, revision=None, my_revision=None,
4665
include_merges=symbol_versioning.DEPRECATED_PARAMETER):
4486
include_merges=False, revision=None, my_revision=None,
4666
4488
from bzrlib.missing import find_unmerged, iter_log_revisions
4667
4489
def message(s):
4668
4490
if not is_quiet():
4669
4491
self.outf.write(s)
4671
if symbol_versioning.deprecated_passed(include_merges):
4672
ui.ui_factory.show_user_warning(
4673
'deprecated_command_option',
4674
deprecated_name='--include-merges',
4675
recommended_name='--include-merged',
4676
deprecated_in_version='2.5',
4677
command=self.invoked_as)
4678
if include_merged is None:
4679
include_merged = include_merges
4681
raise errors.BzrCommandError(gettext(
4682
'{0} and {1} are mutually exclusive').format(
4683
'--include-merges', '--include-merged'))
4684
if include_merged is None:
4685
include_merged = False
4687
4494
mine_only = this
4727
4534
local_extra, remote_extra = find_unmerged(
4728
4535
local_branch, remote_branch, restrict,
4729
4536
backward=not reverse,
4730
include_merged=include_merged,
4537
include_merges=include_merges,
4731
4538
local_revid_range=local_revid_range,
4732
4539
remote_revid_range=remote_revid_range)
4756
4561
if remote_extra and not mine_only:
4757
4562
if printed_local is True:
4758
4563
message("\n\n\n")
4759
message(ngettext("You are missing %d revision:\n",
4760
"You are missing %d revisions:\n",
4761
len(remote_extra)) %
4564
message("You are missing %d revision(s):\n" %
4762
4565
len(remote_extra))
4763
4566
for revision in iter_log_revisions(remote_extra,
4764
4567
remote_branch.repository,
4769
4572
if mine_only and not local_extra:
4770
4573
# We checked local, and found nothing extra
4771
message(gettext('This branch has no new revisions.\n'))
4574
message('This branch is up to date.\n')
4772
4575
elif theirs_only and not remote_extra:
4773
4576
# We checked remote, and found nothing extra
4774
message(gettext('Other branch has no new revisions.\n'))
4577
message('Other branch is up to date.\n')
4775
4578
elif not (mine_only or theirs_only or local_extra or
4777
4580
# We checked both branches, and neither one had extra
4779
message(gettext("Branches are up to date.\n"))
4582
message("Branches are up to date.\n")
4780
4583
self.cleanup_now()
4781
4584
if not status_code and parent is None and other_branch is not None:
4782
4585
self.add_cleanup(local_branch.lock_write().unlock)
4906
4708
@display_command
4907
4709
def run(self, filename, all=False, long=False, revision=None,
4908
4710
show_ids=False, directory=None):
4909
from bzrlib.annotate import (
4711
from bzrlib.annotate import annotate_file, annotate_file_tree
4912
4712
wt, branch, relpath = \
4913
4713
_open_directory_or_containing_tree_or_branch(filename, directory)
4914
4714
if wt is not None:
4929
4729
annotate_file_tree(wt, file_id, self.outf, long, all,
4930
4730
show_ids=show_ids)
4932
annotate_file_tree(tree, file_id, self.outf, long, all,
4933
show_ids=show_ids, branch=branch)
4732
file_version = tree.inventory[file_id].revision
4733
annotate_file(branch, file_version, file_id, long, all, self.outf,
4936
4737
class cmd_re_sign(Command):
4944
4745
def run(self, revision_id_list=None, revision=None, directory=u'.'):
4945
4746
if revision_id_list is not None and revision is not None:
4946
raise errors.BzrCommandError(gettext('You can only supply one of revision_id or --revision'))
4747
raise errors.BzrCommandError('You can only supply one of revision_id or --revision')
4947
4748
if revision_id_list is None and revision is None:
4948
raise errors.BzrCommandError(gettext('You must supply either --revision or a revision_id'))
4749
raise errors.BzrCommandError('You must supply either --revision or a revision_id')
4949
4750
b = WorkingTree.open_containing(directory)[0].branch
4950
4751
self.add_cleanup(b.lock_write().unlock)
4951
4752
return self._run(b, revision_id_list, revision)
5021
4822
location = b.get_old_bound_location()
5022
4823
except errors.UpgradeRequired:
5023
raise errors.BzrCommandError(gettext('No location supplied. '
5024
'This format does not remember old locations.'))
4824
raise errors.BzrCommandError('No location supplied. '
4825
'This format does not remember old locations.')
5026
4827
if location is None:
5027
4828
if b.get_bound_location() is not None:
5028
raise errors.BzrCommandError(gettext('Branch is already bound'))
4829
raise errors.BzrCommandError('Branch is already bound')
5030
raise errors.BzrCommandError(gettext('No location supplied '
5031
'and no previous location known'))
4831
raise errors.BzrCommandError('No location supplied '
4832
'and no previous location known')
5032
4833
b_other = Branch.open(location)
5034
4835
b.bind(b_other)
5035
4836
except errors.DivergedBranches:
5036
raise errors.BzrCommandError(gettext('These branches have diverged.'
5037
' Try merging, and then bind again.'))
4837
raise errors.BzrCommandError('These branches have diverged.'
4838
' Try merging, and then bind again.')
5038
4839
if b.get_config().has_explicit_nickname():
5039
4840
b.nick = b_other.nick
5080
4881
takes_options = ['verbose', 'revision',
5081
4882
Option('dry-run', help='Don\'t actually make changes.'),
5082
4883
Option('force', help='Say yes to all questions.'),
5084
help='Keep tags that point to removed revisions.'),
5085
4884
Option('local',
5086
4885
help="Only remove the commits from the local branch"
5087
4886
" when in a checkout."
5092
4891
encoding_type = 'replace'
5094
def run(self, location=None, dry_run=False, verbose=False,
5095
revision=None, force=False, local=False, keep_tags=False):
4893
def run(self, location=None,
4894
dry_run=False, verbose=False,
4895
revision=None, force=False, local=False):
5096
4896
if location is None:
5097
4897
location = u'.'
5098
4898
control, relpath = bzrdir.BzrDir.open_containing(location)
5107
4907
self.add_cleanup(tree.lock_write().unlock)
5109
4909
self.add_cleanup(b.lock_write().unlock)
5110
return self._run(b, tree, dry_run, verbose, revision, force,
4910
return self._run(b, tree, dry_run, verbose, revision, force, local=local)
5113
def _run(self, b, tree, dry_run, verbose, revision, force, local,
4912
def _run(self, b, tree, dry_run, verbose, revision, force, local=False):
5115
4913
from bzrlib.log import log_formatter, show_log
5116
4914
from bzrlib.uncommit import uncommit
5147
4945
end_revision=last_revno)
5150
self.outf.write(gettext('Dry-run, pretending to remove'
5151
' the above revisions.\n'))
4948
self.outf.write('Dry-run, pretending to remove'
4949
' the above revisions.\n')
5153
self.outf.write(gettext('The above revision(s) will be removed.\n'))
4951
self.outf.write('The above revision(s) will be removed.\n')
5156
4954
if not ui.ui_factory.confirm_action(
5157
gettext(u'Uncommit these revisions'),
4955
'Uncommit these revisions',
5158
4956
'bzrlib.builtins.uncommit',
5160
self.outf.write(gettext('Canceled\n'))
4958
self.outf.write('Canceled\n')
5163
4961
mutter('Uncommitting from {%s} to {%s}',
5164
4962
last_rev_id, rev_id)
5165
4963
uncommit(b, tree=tree, dry_run=dry_run, verbose=verbose,
5166
revno=revno, local=local, keep_tags=keep_tags)
5167
self.outf.write(gettext('You can restore the old tip by running:\n'
5168
' bzr pull . -r revid:%s\n') % last_rev_id)
4964
revno=revno, local=local)
4965
self.outf.write('You can restore the old tip by running:\n'
4966
' bzr pull . -r revid:%s\n' % last_rev_id)
5171
4969
class cmd_break_lock(Command):
5290
5086
if not allow_writes:
5291
5087
url = 'readonly+' + url
5292
5088
t = transport.get_transport(url)
5294
protocol(t, host, port, inet, client_timeout)
5295
except TypeError, e:
5296
# We use symbol_versioning.deprecated_in just so that people
5297
# grepping can find it here.
5298
# symbol_versioning.deprecated_in((2, 5, 0))
5299
symbol_versioning.warn(
5300
'Got TypeError(%s)\ntrying to call protocol: %s.%s\n'
5301
'Most likely it needs to be updated to support a'
5302
' "timeout" parameter (added in bzr 2.5.0)'
5303
% (e, protocol.__module__, protocol),
5305
protocol(t, host, port, inet)
5089
protocol(t, host, port, inet)
5308
5092
class cmd_join(Command):
5331
5115
containing_tree = WorkingTree.open_containing(parent_dir)[0]
5332
5116
repo = containing_tree.branch.repository
5333
5117
if not repo.supports_rich_root():
5334
raise errors.BzrCommandError(gettext(
5118
raise errors.BzrCommandError(
5335
5119
"Can't join trees because %s doesn't support rich root data.\n"
5336
"You can use bzr upgrade on the repository.")
5120
"You can use bzr upgrade on the repository."
5341
5125
except errors.BadReferenceTarget, e:
5342
5126
# XXX: Would be better to just raise a nicely printable
5343
5127
# exception from the real origin. Also below. mbp 20070306
5344
raise errors.BzrCommandError(
5345
gettext("Cannot join {0}. {1}").format(tree, e.reason))
5128
raise errors.BzrCommandError("Cannot join %s. %s" %
5348
5132
containing_tree.subsume(sub_tree)
5349
5133
except errors.BadSubsumeSource, e:
5350
raise errors.BzrCommandError(
5351
gettext("Cannot join {0}. {1}").format(tree, e.reason))
5134
raise errors.BzrCommandError("Cannot join %s. %s" %
5354
5138
class cmd_split(Command):
5446
5230
elif stored_public_branch is None:
5447
5231
branch.set_public_branch(public_branch)
5448
5232
if not include_bundle and public_branch is None:
5449
raise errors.BzrCommandError(gettext('No public branch specified or'
5233
raise errors.BzrCommandError('No public branch specified or'
5451
5235
base_revision_id = None
5452
5236
if revision is not None:
5453
5237
if len(revision) > 2:
5454
raise errors.BzrCommandError(gettext('bzr merge-directive takes '
5455
'at most two one revision identifiers'))
5238
raise errors.BzrCommandError('bzr merge-directive takes '
5239
'at most two one revision identifiers')
5456
5240
revision_id = revision[-1].as_revision_id(branch)
5457
5241
if len(revision) == 2:
5458
5242
base_revision_id = revision[0].as_revision_id(branch)
5460
5244
revision_id = branch.last_revision()
5461
5245
revision_id = ensure_null(revision_id)
5462
5246
if revision_id == NULL_REVISION:
5463
raise errors.BzrCommandError(gettext('No revisions to bundle.'))
5247
raise errors.BzrCommandError('No revisions to bundle.')
5464
5248
directive = merge_directive.MergeDirective2.from_objects(
5465
5249
branch.repository, revision_id, time.time(),
5466
5250
osutils.local_time_offset(), submit_branch,
5510
5294
source branch defaults to that containing the working directory, but can
5511
5295
be changed using --from.
5513
Both the submit branch and the public branch follow the usual behavior with
5514
respect to --remember: If there is no default location set, the first send
5515
will set it (use --no-remember to avoid setting it). After that, you can
5516
omit the location to use the default. To change the default, use
5517
--remember. The value will only be saved if the location can be accessed.
5519
5297
In order to calculate those changes, bzr must analyse the submit branch.
5520
5298
Therefore it is most efficient for the submit branch to be a local mirror.
5521
5299
If a public location is known for the submit_branch, that location is used
5592
5370
def run(self, submit_branch=None, public_branch=None, no_bundle=False,
5593
no_patch=False, revision=None, remember=None, output=None,
5371
no_patch=False, revision=None, remember=False, output=None,
5594
5372
format=None, mail_to=None, message=None, body=None,
5595
5373
strict=None, **kwargs):
5596
5374
from bzrlib.send import send
5720
5498
self.add_cleanup(branch.lock_write().unlock)
5722
5500
if tag_name is None:
5723
raise errors.BzrCommandError(gettext("No tag specified to delete."))
5501
raise errors.BzrCommandError("No tag specified to delete.")
5724
5502
branch.tags.delete_tag(tag_name)
5725
note(gettext('Deleted tag %s.') % tag_name)
5503
note('Deleted tag %s.' % tag_name)
5728
5506
if len(revision) != 1:
5729
raise errors.BzrCommandError(gettext(
5507
raise errors.BzrCommandError(
5730
5508
"Tags can only be placed on a single revision, "
5732
5510
revision_id = revision[0].as_revision_id(branch)
5734
5512
revision_id = branch.last_revision()
5735
5513
if tag_name is None:
5736
5514
tag_name = branch.automatic_tag_name(revision_id)
5737
5515
if tag_name is None:
5738
raise errors.BzrCommandError(gettext(
5739
"Please specify a tag name."))
5741
existing_target = branch.tags.lookup_tag(tag_name)
5742
except errors.NoSuchTag:
5743
existing_target = None
5744
if not force and existing_target not in (None, revision_id):
5516
raise errors.BzrCommandError(
5517
"Please specify a tag name.")
5518
if (not force) and branch.tags.has_tag(tag_name):
5745
5519
raise errors.TagAlreadyExists(tag_name)
5746
if existing_target == revision_id:
5747
note(gettext('Tag %s already exists for that revision.') % tag_name)
5749
branch.tags.set_tag(tag_name, revision_id)
5750
if existing_target is None:
5751
note(gettext('Created tag %s.') % tag_name)
5753
note(gettext('Updated tag %s.') % tag_name)
5520
branch.tags.set_tag(tag_name, revision_id)
5521
note('Created tag %s.' % tag_name)
5756
5524
class cmd_tags(Command):
5783
5551
self.add_cleanup(branch.lock_read().unlock)
5785
# Restrict to the specified range
5786
tags = self._tags_for_range(branch, revision)
5553
graph = branch.repository.get_graph()
5554
rev1, rev2 = _get_revision_range(revision, branch, self.name())
5555
revid1, revid2 = rev1.rev_id, rev2.rev_id
5556
# only show revisions between revid1 and revid2 (inclusive)
5557
tags = [(tag, revid) for tag, revid in tags if
5558
graph.is_between(revid, revid1, revid2)]
5787
5559
if sort is None:
5788
5560
sort = tag_sort_methods.get()
5789
5561
sort(branch, tags)
5794
5566
revno = branch.revision_id_to_dotted_revno(revid)
5795
5567
if isinstance(revno, tuple):
5796
5568
revno = '.'.join(map(str, revno))
5797
except (errors.NoSuchRevision,
5798
errors.GhostRevisionsHaveNoRevno):
5569
except errors.NoSuchRevision:
5799
5570
# Bad tag data/merges can lead to tagged revisions
5800
5571
# which are not in this branch. Fail gracefully ...
5804
5575
for tag, revspec in tags:
5805
5576
self.outf.write('%-20s %s\n' % (tag, revspec))
5807
def _tags_for_range(self, branch, revision):
5809
rev1, rev2 = _get_revision_range(revision, branch, self.name())
5810
revid1, revid2 = rev1.rev_id, rev2.rev_id
5811
# _get_revision_range will always set revid2 if it's not specified.
5812
# If revid1 is None, it means we want to start from the branch
5813
# origin which is always a valid ancestor. If revid1 == revid2, the
5814
# ancestry check is useless.
5815
if revid1 and revid1 != revid2:
5816
# FIXME: We really want to use the same graph than
5817
# branch.iter_merge_sorted_revisions below, but this is not
5818
# easily available -- vila 2011-09-23
5819
if branch.repository.get_graph().is_ancestor(revid2, revid1):
5820
# We don't want to output anything in this case...
5822
# only show revisions between revid1 and revid2 (inclusive)
5823
tagged_revids = branch.tags.get_reverse_tag_dict()
5825
for r in branch.iter_merge_sorted_revisions(
5826
start_revision_id=revid2, stop_revision_id=revid1,
5827
stop_rule='include'):
5828
revid_tags = tagged_revids.get(r[0], None)
5830
found.extend([(tag, r[0]) for tag in revid_tags])
5834
5579
class cmd_reconfigure(Command):
5835
5580
__doc__ = """Reconfigure the type of a bzr directory.
5849
5594
takes_args = ['location?']
5850
5595
takes_options = [
5851
5596
RegistryOption.from_kwargs(
5854
help='The relation between branch and tree.',
5598
title='Target type',
5599
help='The type to reconfigure the directory to.',
5855
5600
value_switches=True, enum_switch=False,
5856
5601
branch='Reconfigure to be an unbound branch with no working tree.',
5857
5602
tree='Reconfigure to be an unbound branch with a working tree.',
5858
5603
checkout='Reconfigure to be a bound branch with a working tree.',
5859
5604
lightweight_checkout='Reconfigure to be a lightweight'
5860
5605
' checkout (with no local history).',
5862
RegistryOption.from_kwargs(
5864
title='Repository type',
5865
help='Location fo the repository.',
5866
value_switches=True, enum_switch=False,
5867
5606
standalone='Reconfigure to be a standalone branch '
5868
5607
'(i.e. stop using shared repository).',
5869
5608
use_shared='Reconfigure to use a shared repository.',
5871
RegistryOption.from_kwargs(
5873
title='Trees in Repository',
5874
help='Whether new branches in the repository have trees.',
5875
value_switches=True, enum_switch=False,
5876
5609
with_trees='Reconfigure repository to create '
5877
5610
'working trees on branches by default.',
5878
5611
with_no_trees='Reconfigure repository to not create '
5895
def run(self, location=None, bind_to=None, force=False,
5896
tree_type=None, repository_type=None, repository_trees=None,
5897
stacked_on=None, unstacked=None):
5628
def run(self, location=None, target_type=None, bind_to=None, force=False,
5898
5631
directory = bzrdir.BzrDir.open(location)
5899
5632
if stacked_on and unstacked:
5900
raise errors.BzrCommandError(gettext("Can't use both --stacked-on and --unstacked"))
5633
raise BzrCommandError("Can't use both --stacked-on and --unstacked")
5901
5634
elif stacked_on is not None:
5902
5635
reconfigure.ReconfigureStackedOn().apply(directory, stacked_on)
5903
5636
elif unstacked:
5905
5638
# At the moment you can use --stacked-on and a different
5906
5639
# reconfiguration shape at the same time; there seems no good reason
5908
if (tree_type is None and
5909
repository_type is None and
5910
repository_trees is None):
5641
if target_type is None:
5911
5642
if stacked_on or unstacked:
5914
raise errors.BzrCommandError(gettext('No target configuration '
5916
reconfiguration = None
5917
if tree_type == 'branch':
5645
raise errors.BzrCommandError('No target configuration '
5647
elif target_type == 'branch':
5918
5648
reconfiguration = reconfigure.Reconfigure.to_branch(directory)
5919
elif tree_type == 'tree':
5649
elif target_type == 'tree':
5920
5650
reconfiguration = reconfigure.Reconfigure.to_tree(directory)
5921
elif tree_type == 'checkout':
5651
elif target_type == 'checkout':
5922
5652
reconfiguration = reconfigure.Reconfigure.to_checkout(
5923
5653
directory, bind_to)
5924
elif tree_type == 'lightweight-checkout':
5654
elif target_type == 'lightweight-checkout':
5925
5655
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
5926
5656
directory, bind_to)
5928
reconfiguration.apply(force)
5929
reconfiguration = None
5930
if repository_type == 'use-shared':
5657
elif target_type == 'use-shared':
5931
5658
reconfiguration = reconfigure.Reconfigure.to_use_shared(directory)
5932
elif repository_type == 'standalone':
5659
elif target_type == 'standalone':
5933
5660
reconfiguration = reconfigure.Reconfigure.to_standalone(directory)
5935
reconfiguration.apply(force)
5936
reconfiguration = None
5937
if repository_trees == 'with-trees':
5661
elif target_type == 'with-trees':
5938
5662
reconfiguration = reconfigure.Reconfigure.set_repository_trees(
5939
5663
directory, True)
5940
elif repository_trees == 'with-no-trees':
5664
elif target_type == 'with-no-trees':
5941
5665
reconfiguration = reconfigure.Reconfigure.set_repository_trees(
5942
5666
directory, False)
5944
reconfiguration.apply(force)
5945
reconfiguration = None
5667
reconfiguration.apply(force)
5948
5670
class cmd_switch(Command):
6136
5858
name = current_view
6139
raise errors.BzrCommandError(gettext(
6140
"Both --delete and a file list specified"))
5861
raise errors.BzrCommandError(
5862
"Both --delete and a file list specified")
6142
raise errors.BzrCommandError(gettext(
6143
"Both --delete and --switch specified"))
5864
raise errors.BzrCommandError(
5865
"Both --delete and --switch specified")
6145
5867
tree.views.set_view_info(None, {})
6146
self.outf.write(gettext("Deleted all views.\n"))
5868
self.outf.write("Deleted all views.\n")
6147
5869
elif name is None:
6148
raise errors.BzrCommandError(gettext("No current view to delete"))
5870
raise errors.BzrCommandError("No current view to delete")
6150
5872
tree.views.delete_view(name)
6151
self.outf.write(gettext("Deleted '%s' view.\n") % name)
5873
self.outf.write("Deleted '%s' view.\n" % name)
6154
raise errors.BzrCommandError(gettext(
6155
"Both --switch and a file list specified"))
5876
raise errors.BzrCommandError(
5877
"Both --switch and a file list specified")
6157
raise errors.BzrCommandError(gettext(
6158
"Both --switch and --all specified"))
5879
raise errors.BzrCommandError(
5880
"Both --switch and --all specified")
6159
5881
elif switch == 'off':
6160
5882
if current_view is None:
6161
raise errors.BzrCommandError(gettext("No current view to disable"))
5883
raise errors.BzrCommandError("No current view to disable")
6162
5884
tree.views.set_view_info(None, view_dict)
6163
self.outf.write(gettext("Disabled '%s' view.\n") % (current_view))
5885
self.outf.write("Disabled '%s' view.\n" % (current_view))
6165
5887
tree.views.set_view_info(switch, view_dict)
6166
5888
view_str = views.view_display_str(tree.views.lookup_view())
6167
self.outf.write(gettext("Using '{0}' view: {1}\n").format(switch, view_str))
5889
self.outf.write("Using '%s' view: %s\n" % (switch, view_str))
6170
self.outf.write(gettext('Views defined:\n'))
5892
self.outf.write('Views defined:\n')
6171
5893
for view in sorted(view_dict):
6172
5894
if view == current_view:
6176
5898
view_str = views.view_display_str(view_dict[view])
6177
5899
self.outf.write('%s %-20s %s\n' % (active, view, view_str))
6179
self.outf.write(gettext('No views defined.\n'))
5901
self.outf.write('No views defined.\n')
6180
5902
elif file_list:
6181
5903
if name is None:
6182
5904
# No name given and no current view set
6184
5906
elif name == 'off':
6185
raise errors.BzrCommandError(gettext(
6186
"Cannot change the 'off' pseudo view"))
5907
raise errors.BzrCommandError(
5908
"Cannot change the 'off' pseudo view")
6187
5909
tree.views.set_view(name, sorted(file_list))
6188
5910
view_str = views.view_display_str(tree.views.lookup_view())
6189
self.outf.write(gettext("Using '{0}' view: {1}\n").format(name, view_str))
5911
self.outf.write("Using '%s' view: %s\n" % (name, view_str))
6191
5913
# list the files
6192
5914
if name is None:
6193
5915
# No name given and no current view set
6194
self.outf.write(gettext('No current view.\n'))
5916
self.outf.write('No current view.\n')
6196
5918
view_str = views.view_display_str(tree.views.lookup_view(name))
6197
self.outf.write(gettext("'{0}' view is: {1}\n").format(name, view_str))
5919
self.outf.write("'%s' view is: %s\n" % (name, view_str))
6200
5922
class cmd_hooks(Command):
6466
6178
('cmd_version_info', [], 'bzrlib.cmd_version_info'),
6467
6179
('cmd_resolve', ['resolved'], 'bzrlib.conflicts'),
6468
6180
('cmd_conflicts', [], 'bzrlib.conflicts'),
6469
('cmd_sign_my_commits', [], 'bzrlib.commit_signature_commands'),
6470
('cmd_verify_signatures', [],
6471
'bzrlib.commit_signature_commands'),
6181
('cmd_sign_my_commits', [], 'bzrlib.sign_my_commits'),
6472
6182
('cmd_test_script', [], 'bzrlib.cmd_test_script'),
6474
6184
builtin_command_registry.register_lazy(name, aliases, module_name)