230
234
Not versioned and not matching an ignore pattern.
232
Additionally for directories, symlinks and files with an executable
233
bit, Bazaar indicates their type using a trailing character: '/', '@'
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.
236
241
To see ignored files use 'bzr ignored'. For details on the
237
242
changes to file texts, use 'bzr diff'.
278
286
def run(self, show_ids=False, file_list=None, revision=None, short=False,
279
versioned=False, no_pending=False, verbose=False):
287
versioned=False, no_pending=False, verbose=False,
280
289
from bzrlib.status import show_tree_status
282
291
if revision and len(revision) > 2:
283
raise errors.BzrCommandError('bzr status --revision takes exactly'
284
' one or two revision specifiers')
292
raise errors.BzrCommandError(gettext('bzr status --revision takes exactly'
293
' one or two revision specifiers'))
286
295
tree, relfile_list = WorkingTree.open_containing_paths(file_list)
287
296
# Avoid asking for specific files when that is not needed.
296
305
show_tree_status(tree, show_ids=show_ids,
297
306
specific_files=relfile_list, revision=revision,
298
307
to_file=self.outf, short=short, versioned=versioned,
299
show_pending=(not no_pending), verbose=verbose)
308
show_pending=(not no_pending), verbose=verbose,
309
classify=not no_classify)
302
312
class cmd_cat_revision(Command):
324
334
def run(self, revision_id=None, revision=None, directory=u'.'):
325
335
if revision_id is not None and revision is not None:
326
raise errors.BzrCommandError('You can only supply one of'
327
' revision_id or --revision')
336
raise errors.BzrCommandError(gettext('You can only supply one of'
337
' revision_id or --revision'))
328
338
if revision_id is None and revision is None:
329
raise errors.BzrCommandError('You must supply either'
330
' --revision or a revision_id')
339
raise errors.BzrCommandError(gettext('You must supply either'
340
' --revision or a revision_id'))
332
342
b = bzrdir.BzrDir.open_containing_tree_or_branch(directory)[1]
334
344
revisions = b.repository.revisions
335
345
if revisions is None:
336
raise errors.BzrCommandError('Repository %r does not support '
337
'access to raw revision texts')
346
raise errors.BzrCommandError(gettext('Repository %r does not support '
347
'access to raw revision texts'))
339
349
b.repository.lock_read()
345
355
self.print_revision(revisions, revision_id)
346
356
except errors.NoSuchRevision:
347
msg = "The repository %s contains no revision %s." % (
357
msg = gettext("The repository {0} contains no revision {1}.").format(
348
358
b.repository.base, revision_id)
349
359
raise errors.BzrCommandError(msg)
350
360
elif revision is not None:
351
361
for rev in revision:
353
363
raise errors.BzrCommandError(
354
'You cannot specify a NULL revision.')
364
gettext('You cannot specify a NULL revision.'))
355
365
rev_id = rev.as_revision_id(b)
356
366
self.print_revision(revisions, rev_id)
469
479
working = d.open_workingtree()
470
480
except errors.NoWorkingTree:
471
raise errors.BzrCommandError("No working tree to remove")
481
raise errors.BzrCommandError(gettext("No working tree to remove"))
472
482
except errors.NotLocalUrl:
473
raise errors.BzrCommandError("You cannot remove the working tree"
483
raise errors.BzrCommandError(gettext("You cannot remove the working tree"
484
" of a remote path"))
476
486
if (working.has_changes()):
477
487
raise errors.UncommittedChanges(working)
530
540
tree.reset_state(revision_ids)
531
541
except errors.BzrError, e:
532
542
if revision_ids is None:
533
extra = (', the header appears corrupt, try passing -r -1'
534
' to set the state to the last commit')
543
extra = (gettext(', the header appears corrupt, try passing -r -1'
544
' to set the state to the last commit'))
537
raise errors.BzrCommandError('failed to reset the tree state'
547
raise errors.BzrCommandError(gettext('failed to reset the tree state{0}').format(extra))
541
550
class cmd_revno(Command):
776
793
def run(self, revision=None, show_ids=False, kind=None, file_list=None):
777
794
if kind and kind not in ['file', 'directory', 'symlink']:
778
raise errors.BzrCommandError('invalid kind %r specified' % (kind,))
795
raise errors.BzrCommandError(gettext('invalid kind %r specified') % (kind,))
780
797
revision = _get_one_revision('inventory', revision)
781
798
work_tree, file_list = WorkingTree.open_containing_paths(file_list)
845
863
return self.run_auto(names_list, after, dry_run)
847
raise errors.BzrCommandError('--dry-run requires --auto.')
865
raise errors.BzrCommandError(gettext('--dry-run requires --auto.'))
848
866
if names_list is None:
850
868
if len(names_list) < 2:
851
raise errors.BzrCommandError("missing file argument")
869
raise errors.BzrCommandError(gettext("missing file argument"))
852
870
tree, rel_names = WorkingTree.open_containing_paths(names_list, canonicalize=False)
853
871
self.add_cleanup(tree.lock_tree_write().unlock)
854
872
self._run(tree, names_list, rel_names, after)
856
874
def run_auto(self, names_list, after, dry_run):
857
875
if names_list is not None and len(names_list) > 1:
858
raise errors.BzrCommandError('Only one path may be specified to'
876
raise errors.BzrCommandError(gettext('Only one path may be specified to'
861
raise errors.BzrCommandError('--after cannot be specified with'
879
raise errors.BzrCommandError(gettext('--after cannot be specified with'
863
881
work_tree, file_list = WorkingTree.open_containing_paths(
864
882
names_list, default_directory='.')
865
883
self.add_cleanup(work_tree.lock_tree_write().unlock)
962
980
match the remote one, use pull --overwrite. This will work even if the two
963
981
branches have diverged.
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.
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.
970
988
Note: The location can be specified either in the form of a branch,
971
989
or in the form of a path to a file containing a merge directive generated
990
1008
takes_args = ['location?']
991
1009
encoding_type = 'replace'
993
def run(self, location=None, remember=False, overwrite=False,
1011
def run(self, location=None, remember=None, overwrite=False,
994
1012
revision=None, verbose=False,
995
1013
directory=None, local=False,
996
1014
show_base=False):
1025
1043
stored_loc = branch_to.get_parent()
1026
1044
if location is None:
1027
1045
if stored_loc is None:
1028
raise errors.BzrCommandError("No pull location known or"
1046
raise errors.BzrCommandError(gettext("No pull location known or"
1031
1049
display_url = urlutils.unescape_for_display(stored_loc,
1032
1050
self.outf.encoding)
1033
1051
if not is_quiet():
1034
self.outf.write("Using saved parent location: %s\n" % display_url)
1052
self.outf.write(gettext("Using saved parent location: %s\n") % display_url)
1035
1053
location = stored_loc
1037
1055
revision = _get_one_revision('pull', revision)
1038
1056
if mergeable is not None:
1039
1057
if revision is not None:
1040
raise errors.BzrCommandError(
1041
'Cannot use -r with merge directives or bundles')
1058
raise errors.BzrCommandError(gettext(
1059
'Cannot use -r with merge directives or bundles'))
1042
1060
mergeable.install_revisions(branch_to.repository)
1043
1061
base_revision_id, revision_id, verified = \
1044
1062
mergeable.get_merge_request(branch_to.repository)
1061
1080
view_info=view_info)
1062
1081
result = tree_to.pull(
1063
1082
branch_from, overwrite, revision_id, change_reporter,
1064
possible_transports=possible_transports, local=local,
1065
show_base=show_base)
1083
local=local, show_base=show_base)
1067
1085
result = branch_to.pull(
1068
1086
branch_from, overwrite, revision_id, local=local)
1098
1116
do a merge (see bzr help merge) from the other branch, and commit that.
1099
1117
After that you will be able to do a push without '--overwrite'.
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.
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.
1107
1125
_see_also = ['pull', 'update', 'working-trees']
1135
1153
takes_args = ['location?']
1136
1154
encoding_type = 'replace'
1138
def run(self, location=None, remember=False, overwrite=False,
1156
def run(self, location=None, remember=None, overwrite=False,
1139
1157
create_prefix=False, verbose=False, revision=None,
1140
1158
use_existing_dir=False, directory=None, stacked_on=None,
1141
1159
stacked=False, strict=None, no_tree=False):
1172
1190
# error by the feedback given to them. RBC 20080227.
1173
1191
stacked_on = parent_url
1174
1192
if not stacked_on:
1175
raise errors.BzrCommandError(
1176
"Could not determine branch to refer to.")
1193
raise errors.BzrCommandError(gettext(
1194
"Could not determine branch to refer to."))
1178
1196
# Get the destination location
1179
1197
if location is None:
1180
1198
stored_loc = br_from.get_push_location()
1181
1199
if stored_loc is None:
1182
raise errors.BzrCommandError(
1183
"No push location known or specified.")
1200
raise errors.BzrCommandError(gettext(
1201
"No push location known or specified."))
1185
1203
display_url = urlutils.unescape_for_display(stored_loc,
1186
1204
self.outf.encoding)
1187
self.outf.write("Using saved push location: %s\n" % display_url)
1205
note(gettext("Using saved push location: %s") % display_url)
1188
1206
location = stored_loc
1190
1208
_show_push_branch(br_from, revision_id, location, self.outf,
1297
1315
branch = dir.open_branch()
1298
1316
except errors.NoSuchRevision:
1299
1317
to_transport.delete_tree('.')
1300
msg = "The branch %s has no revision %s." % (from_location,
1318
msg = gettext("The branch {0} has no revision {1}.").format(
1319
from_location, revision)
1302
1320
raise errors.BzrCommandError(msg)
1303
1321
_merge_tags_if_possible(br_from, branch)
1304
1322
# If the source branch is stacked, the new branch may
1305
1323
# be stacked whether we asked for that explicitly or not.
1306
1324
# We therefore need a try/except here and not just 'if stacked:'
1308
note('Created new stacked branch referring to %s.' %
1326
note(gettext('Created new stacked branch referring to %s.') %
1309
1327
branch.get_stacked_on_url())
1310
1328
except (errors.NotStacked, errors.UnstackableBranchFormat,
1311
1329
errors.UnstackableRepositoryFormat), e:
1312
note('Branched %d revision(s).' % branch.revno())
1330
note(ngettext('Branched %d revision.', 'Branched %d revisions.', branch.revno()) % branch.revno())
1314
1332
# Bind to the parent
1315
1333
parent_branch = Branch.open(from_location)
1316
1334
branch.bind(parent_branch)
1317
note('New branch bound to %s' % from_location)
1335
note(gettext('New branch bound to %s') % from_location)
1319
1337
# Switch to the new branch
1320
1338
wt, _ = WorkingTree.open_containing('.')
1321
1339
_mod_switch.switch(wt.bzrdir, branch)
1322
note('Switched to branch: %s',
1340
note(gettext('Switched to branch: %s'),
1323
1341
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))
1326
1377
class cmd_checkout(Command):
1327
1378
__doc__ = """Create a new checkout of an existing branch.
1455
1506
def run(self, dir='.', revision=None, show_base=None):
1456
1507
if revision is not None and len(revision) != 1:
1457
raise errors.BzrCommandError(
1458
"bzr update --revision takes exactly one revision")
1508
raise errors.BzrCommandError(gettext(
1509
"bzr update --revision takes exactly one revision"))
1459
1510
tree = WorkingTree.open_containing(dir)[0]
1460
1511
branch = tree.branch
1461
1512
possible_transports = []
1486
1537
revision_id = branch.last_revision()
1487
1538
if revision_id == _mod_revision.ensure_null(tree.last_revision()):
1488
1539
revno = branch.revision_id_to_dotted_revno(revision_id)
1489
note("Tree is up to date at revision %s of branch %s" %
1490
('.'.join(map(str, revno)), branch_location))
1540
note(gettext("Tree is up to date at revision {0} of branch {1}"
1541
).format('.'.join(map(str, revno)), branch_location))
1492
1543
view_info = _get_view_info_for_change_reporter(tree)
1493
1544
change_reporter = delta._ChangeReporter(
1501
1552
old_tip=old_tip,
1502
1553
show_base=show_base)
1503
1554
except errors.NoSuchRevision, e:
1504
raise errors.BzrCommandError(
1555
raise errors.BzrCommandError(gettext(
1505
1556
"branch has no revision %s\n"
1506
1557
"bzr update --revision only works"
1507
" for a revision in the branch history"
1558
" for a revision in the branch history")
1508
1559
% (e.revision))
1509
1560
revno = tree.branch.revision_id_to_dotted_revno(
1510
1561
_mod_revision.ensure_null(tree.last_revision()))
1511
note('Updated to revision %s of branch %s' %
1512
('.'.join(map(str, revno)), branch_location))
1562
note(gettext('Updated to revision {0} of branch {1}').format(
1563
'.'.join(map(str, revno)), branch_location))
1513
1564
parent_ids = tree.get_parent_ids()
1514
1565
if parent_ids[1:] and parent_ids[1:] != existing_pending_merges:
1515
note('Your local commits will now show as pending merges with '
1516
"'bzr status', and can be committed with 'bzr commit'.")
1566
note(gettext('Your local commits will now show as pending merges with '
1567
"'bzr status', and can be committed with 'bzr commit'."))
1517
1568
if conflicts != 0:
1591
1642
def run(self, file_list, verbose=False, new=False,
1592
1643
file_deletion_strategy='safe'):
1593
1644
if file_deletion_strategy == 'force':
1594
note("(The --force option is deprecated, rather use --no-backup "
1645
note(gettext("(The --force option is deprecated, rather use --no-backup "
1596
1647
file_deletion_strategy = 'no-backup'
1598
1649
tree, file_list = WorkingTree.open_containing_paths(file_list)
1738
1789
last_revision = wt.last_revision()
1740
revision_ids = b.repository.get_ancestry(last_revision)
1742
for revision_id in revision_ids:
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):
1743
1798
self.outf.write(revision_id + '\n')
1849
1904
repository = branch.repository
1850
1905
layout = describe_layout(repository, branch, tree).lower()
1851
1906
format = describe_format(a_bzrdir, repository, branch, tree)
1852
self.outf.write("Created a %s (format: %s)\n" % (layout, format))
1907
self.outf.write(gettext("Created a {0} (format: {1})\n").format(
1853
1909
if repository.is_shared():
1854
1910
#XXX: maybe this can be refactored into transport.path_or_url()
1855
1911
url = repository.bzrdir.root_transport.external_url()
2054
2110
elif ':' in prefix:
2055
2111
old_label, new_label = prefix.split(":")
2057
raise errors.BzrCommandError(
2113
raise errors.BzrCommandError(gettext(
2058
2114
'--prefix expects two values separated by a colon'
2059
' (eg "old/:new/")')
2115
' (eg "old/:new/")'))
2061
2117
if revision and len(revision) > 2:
2062
raise errors.BzrCommandError('bzr diff --revision takes exactly'
2063
' one or two revision specifiers')
2118
raise errors.BzrCommandError(gettext('bzr diff --revision takes exactly'
2119
' one or two revision specifiers'))
2065
2121
if using is not None and format is not None:
2066
raise errors.BzrCommandError('--using and --format are mutually '
2122
raise errors.BzrCommandError(gettext(
2123
'{0} and {1} are mutually exclusive').format(
2124
'--using', '--format'))
2069
2126
(old_tree, new_tree,
2070
2127
old_branch, new_branch,
2303
2360
:Other filtering:
2305
The --message option can be used for finding revisions that match a
2306
regular expression in a commit message.
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.
2308
2368
:Tips & tricks:
2381
2441
Option('show-diff',
2382
2442
short_name='p',
2383
2443
help='Show changes made in each revision as a patch.'),
2384
Option('include-merges',
2444
Option('include-merged',
2385
2445
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.'),
2386
2450
Option('exclude-common-ancestry',
2387
2451
help='Display only the revisions that are not part'
2388
2452
' 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 '
2391
2478
encoding_type = 'replace'
2412
2507
_get_info_for_log_files,
2414
2509
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
2415
2525
if (exclude_common_ancestry
2416
2526
and (revision is None or len(revision) != 2)):
2417
raise errors.BzrCommandError(
2418
'--exclude-common-ancestry requires -r with two revisions')
2527
raise errors.BzrCommandError(gettext(
2528
'--exclude-common-ancestry requires -r with two revisions'))
2420
2530
if levels is None:
2423
raise errors.BzrCommandError(
2424
'--levels and --include-merges are mutually exclusive')
2533
raise errors.BzrCommandError(gettext(
2534
'{0} and {1} are mutually exclusive').format(
2535
'--levels', '--include-merged'))
2426
2537
if change is not None:
2427
2538
if len(change) > 1:
2428
2539
raise errors.RangeInChangeOption()
2429
2540
if revision is not None:
2430
raise errors.BzrCommandError(
2431
'--revision and --change are mutually exclusive')
2541
raise errors.BzrCommandError(gettext(
2542
'{0} and {1} are mutually exclusive').format(
2543
'--revision', '--change'))
2433
2545
revision = change
2440
2552
revision, file_list, self.add_cleanup)
2441
2553
for relpath, file_id, kind in file_info_list:
2442
2554
if file_id is None:
2443
raise errors.BzrCommandError(
2444
"Path unknown at end or start of revision range: %s" %
2555
raise errors.BzrCommandError(gettext(
2556
"Path unknown at end or start of revision range: %s") %
2446
2558
# If the relpath is the top of the tree, we log everything
2447
2559
if relpath == '':
2464
2576
self.add_cleanup(b.lock_read().unlock)
2465
2577
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)
2467
2586
# Decide on the type of delta & diff filtering to use
2468
2587
# TODO: add an --all-files option to make this configurable & consistent
2469
2588
if not verbose:
2514
2645
start_revision=rev1, end_revision=rev2, limit=limit,
2515
2646
message_search=message, delta_type=delta_type,
2516
2647
diff_type=diff_type, _match_using_deltas=match_using_deltas,
2517
exclude_common_ancestry=exclude_common_ancestry,
2648
exclude_common_ancestry=exclude_common_ancestry, match=match_dict,
2649
signature=signatures, omit_merges=omit_merges,
2519
2651
Logger(b, rqst).show(lf)
2537
2669
# b is taken from revision[0].get_branch(), and
2538
2670
# show_log will use its revision_history. Having
2539
2671
# different branches will lead to weird behaviors.
2540
raise errors.BzrCommandError(
2672
raise errors.BzrCommandError(gettext(
2541
2673
"bzr %s doesn't accept two revisions in different"
2542
" branches." % command_name)
2674
" branches.") % command_name)
2543
2675
if start_spec.spec is None:
2544
2676
# Avoid loading all the history.
2545
2677
rev1 = RevisionInfo(branch, None, None)
2631
2763
null=False, kind=None, show_ids=False, path=None, directory=None):
2633
2765
if kind and kind not in ('file', 'directory', 'symlink'):
2634
raise errors.BzrCommandError('invalid kind specified')
2766
raise errors.BzrCommandError(gettext('invalid kind specified'))
2636
2768
if verbose and null:
2637
raise errors.BzrCommandError('Cannot set both --verbose and --null')
2769
raise errors.BzrCommandError(gettext('Cannot set both --verbose and --null'))
2638
2770
all = not (unknown or versioned or ignored)
2640
2772
selection = {'I':ignored, '?':unknown, 'V':versioned}
2819
2951
self.outf.write("%s\n" % pattern)
2821
2953
if not name_pattern_list:
2822
raise errors.BzrCommandError("ignore requires at least one "
2823
"NAME_PATTERN or --default-rules.")
2954
raise errors.BzrCommandError(gettext("ignore requires at least one "
2955
"NAME_PATTERN or --default-rules."))
2824
2956
name_pattern_list = [globbing.normalize_pattern(p)
2825
2957
for p in name_pattern_list]
2826
2958
bad_patterns = ''
2959
bad_patterns_count = 0
2827
2960
for p in name_pattern_list:
2828
2961
if not globbing.Globster.is_pattern_valid(p):
2962
bad_patterns_count += 1
2829
2963
bad_patterns += ('\n %s' % p)
2830
2964
if bad_patterns:
2831
msg = ('Invalid ignore pattern(s) found. %s' % bad_patterns)
2965
msg = (ngettext('Invalid ignore pattern found. %s',
2966
'Invalid ignore patterns found. %s',
2967
bad_patterns_count) % bad_patterns)
2832
2968
ui.ui_factory.show_error(msg)
2833
2969
raise errors.InvalidPattern('')
2834
2970
for name_pattern in name_pattern_list:
2835
2971
if (name_pattern[0] == '/' or
2836
2972
(len(name_pattern) > 1 and name_pattern[1] == ':')):
2837
raise errors.BzrCommandError(
2838
"NAME_PATTERN should not be an absolute path")
2973
raise errors.BzrCommandError(gettext(
2974
"NAME_PATTERN should not be an absolute path"))
2839
2975
tree, relpath = WorkingTree.open_containing(directory)
2840
2976
ignores.tree_ignores_add_patterns(tree, name_pattern_list)
2841
2977
ignored = globbing.Globster(name_pattern_list)
2848
2984
if ignored.match(filename):
2849
2985
matches.append(filename)
2850
2986
if len(matches) > 0:
2851
self.outf.write("Warning: the following files are version controlled and"
2852
" match your ignore pattern:\n%s"
2987
self.outf.write(gettext("Warning: the following files are version "
2988
"controlled and match your ignore pattern:\n%s"
2853
2989
"\nThese files will continue to be version controlled"
2854
" unless you 'bzr remove' them.\n" % ("\n".join(matches),))
2990
" unless you 'bzr remove' them.\n") % ("\n".join(matches),))
2857
2993
class cmd_ignored(Command):
2963
3099
export(rev_tree, dest, format, root, subdir, filtered=filters,
2964
3100
per_file_timestamps=per_file_timestamps)
2965
3101
except errors.NoSuchExportFormat, e:
2966
raise errors.BzrCommandError('Unsupported export format: %s' % e.format)
3102
raise errors.BzrCommandError(gettext('Unsupported export format: %s') % e.format)
2969
3105
class cmd_cat(Command):
2989
3125
def run(self, filename, revision=None, name_from_revision=False,
2990
3126
filters=False, directory=None):
2991
3127
if revision is not None and len(revision) != 1:
2992
raise errors.BzrCommandError("bzr cat --revision takes exactly"
2993
" one revision specifier")
3128
raise errors.BzrCommandError(gettext("bzr cat --revision takes exactly"
3129
" one revision specifier"))
2994
3130
tree, branch, relpath = \
2995
3131
_open_directory_or_containing_tree_or_branch(filename, directory)
2996
3132
self.add_cleanup(branch.lock_read().unlock)
3007
3143
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
3009
3149
if name_from_revision:
3010
3150
# Try in revision if requested
3011
3151
if old_file_id is None:
3012
raise errors.BzrCommandError(
3013
"%r is not present in revision %s" % (
3152
raise errors.BzrCommandError(gettext(
3153
"{0!r} is not present in revision {1}").format(
3014
3154
filename, rev_tree.get_revision_id()))
3016
content = rev_tree.get_file_text(old_file_id)
3156
actual_file_id = old_file_id
3018
3158
cur_file_id = tree.path2id(relpath)
3020
if cur_file_id is not None:
3021
# Then try with the actual file id
3023
content = rev_tree.get_file_text(cur_file_id)
3025
except errors.NoSuchId:
3026
# The actual file id didn't exist at that time
3028
if not found and old_file_id is not None:
3029
# Finally try with the old file id
3030
content = rev_tree.get_file_text(old_file_id)
3033
# Can't be found anywhere
3034
raise errors.BzrCommandError(
3035
"%r is not present in revision %s" % (
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(
3036
3166
filename, rev_tree.get_revision_id()))
3038
from bzrlib.filters import (
3039
ContentFilterContext,
3040
filtered_output_bytes,
3042
filters = rev_tree._content_filter_stack(relpath)
3043
chunks = content.splitlines(True)
3044
content = filtered_output_bytes(chunks, filters,
3045
ContentFilterContext(relpath, rev_tree))
3047
self.outf.writelines(content)
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)
3050
self.outf.write(content)
3173
content = rev_tree.get_file_text(actual_file_id)
3175
self.outf.write(content)
3053
3178
class cmd_local_time_offset(Command):
3160
3285
aliases = ['ci', 'checkin']
3162
3287
def _iter_bug_fix_urls(self, fixes, branch):
3288
default_bugtracker = None
3163
3289
# Configure the properties for bug fixing attributes.
3164
3290
for fixed_bug in fixes:
3165
3291
tokens = fixed_bug.split(':')
3166
if len(tokens) != 2:
3167
raise errors.BzrCommandError(
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(
3168
3308
"Invalid bug %s. Must be in the form of 'tracker:id'. "
3169
3309
"See \"bzr help bugs\" for more information on this "
3170
"feature.\nCommit refused." % fixed_bug)
3171
tag, bug_id = tokens
3310
"feature.\nCommit refused.") % fixed_bug)
3312
tag, bug_id = tokens
3173
3314
yield bugtracker.get_bug_url(tag, branch, bug_id)
3174
3315
except errors.UnknownBugTrackerAbbreviation:
3175
raise errors.BzrCommandError(
3176
'Unrecognized bug %s. Commit refused.' % fixed_bug)
3316
raise errors.BzrCommandError(gettext(
3317
'Unrecognized bug %s. Commit refused.') % fixed_bug)
3177
3318
except errors.MalformedBugIdentifier, e:
3178
raise errors.BzrCommandError(
3179
"%s\nCommit refused." % (str(e),))
3319
raise errors.BzrCommandError(gettext(
3320
"%s\nCommit refused.") % (str(e),))
3181
3322
def run(self, message=None, file=None, verbose=False, selected_list=None,
3182
3323
unchanged=False, strict=False, local=False, fixes=None,
3238
3380
message = message.replace('\r\n', '\n')
3239
3381
message = message.replace('\r', '\n')
3241
raise errors.BzrCommandError(
3242
"please specify either --message or --file")
3383
raise errors.BzrCommandError(gettext(
3384
"please specify either --message or --file"))
3244
3386
def get_message(commit_obj):
3245
3387
"""Callback to get commit message"""
3262
3404
# make_commit_message_template_encoded returns user encoding.
3263
3405
# We probably want to be using edit_commit_message instead to
3265
start_message = generate_commit_message_template(commit_obj)
3266
my_message = edit_commit_message_encoded(text,
3267
start_message=start_message)
3268
if my_message is None:
3269
raise errors.BzrCommandError("please specify a commit"
3270
" message with either --message or --file")
3271
if my_message == "":
3272
raise errors.BzrCommandError("empty commit message specified")
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 \"\"."))
3273
3420
return my_message
3275
3422
# The API permits a commit with a filter of [] to mean 'select nothing'
3286
3433
exclude=tree.safe_relpath_files(exclude),
3288
3435
except PointlessCommit:
3289
raise errors.BzrCommandError("No changes to commit."
3436
raise errors.BzrCommandError(gettext("No changes to commit."
3290
3437
" Please 'bzr add' the files you want to commit, or use"
3291
" --unchanged to force an empty commit.")
3438
" --unchanged to force an empty commit."))
3292
3439
except ConflictsInTree:
3293
raise errors.BzrCommandError('Conflicts detected in working '
3440
raise errors.BzrCommandError(gettext('Conflicts detected in working '
3294
3441
'tree. Use "bzr conflicts" to list, "bzr resolve FILE" to'
3296
3443
except StrictCommitFailed:
3297
raise errors.BzrCommandError("Commit refused because there are"
3298
" unknown files in the working tree.")
3444
raise errors.BzrCommandError(gettext("Commit refused because there are"
3445
" unknown files in the working tree."))
3299
3446
except errors.BoundBranchOutOfDate, e:
3300
e.extra_help = ("\n"
3447
e.extra_help = (gettext("\n"
3301
3448
'To commit to master branch, run update and then commit.\n'
3302
3449
'You can also pass --local to commit to continue working '
3560
3707
def remove_alias(self, alias_name):
3561
3708
if alias_name is None:
3562
raise errors.BzrCommandError(
3563
'bzr alias --remove expects an alias to remove.')
3709
raise errors.BzrCommandError(gettext(
3710
'bzr alias --remove expects an alias to remove.'))
3564
3711
# If alias is not found, print something like:
3565
3712
# unalias: foo: not found
3566
3713
c = _mod_config.GlobalConfig()
3645
3792
if typestring == "sftp":
3646
3793
from bzrlib.tests import stub_sftp
3647
3794
return stub_sftp.SFTPAbsoluteServer
3648
if typestring == "memory":
3795
elif typestring == "memory":
3649
3796
from bzrlib.tests import test_server
3650
3797
return memory.MemoryServer
3651
if typestring == "fakenfs":
3798
elif typestring == "fakenfs":
3652
3799
from bzrlib.tests import test_server
3653
3800
return test_server.FakeNFSServer
3654
3801
msg = "No known transport type %s. Supported types are: sftp\n" %\
3688
3835
Option('randomize', type=str, argname="SEED",
3689
3836
help='Randomize the order of tests using the given'
3690
3837
' seed or "now" for the current time.'),
3691
Option('exclude', type=str, argname="PATTERN",
3693
help='Exclude tests that match this regular'
3838
ListOption('exclude', type=str, argname="PATTERN",
3840
help='Exclude tests that match this regular'
3695
3842
Option('subunit',
3696
3843
help='Output test progress via subunit.'),
3697
3844
Option('strict', help='Fail on missing dependencies or '
3717
3867
first=False, list_only=False,
3718
3868
randomize=None, exclude=None, strict=False,
3719
3869
load_list=None, debugflag=None, starting_with=None, subunit=False,
3720
parallel=None, lsprof_tests=False):
3870
parallel=None, lsprof_tests=False,
3721
3872
from bzrlib import tests
3723
3874
if testspecs_list is not None:
3729
3880
from bzrlib.tests import SubUnitBzrRunner
3730
3881
except ImportError:
3731
raise errors.BzrCommandError("subunit not available. subunit "
3732
"needs to be installed to use --subunit.")
3882
raise errors.BzrCommandError(gettext("subunit not available. subunit "
3883
"needs to be installed to use --subunit."))
3733
3884
self.additional_selftest_args['runner_class'] = SubUnitBzrRunner
3734
3885
# On Windows, disable automatic conversion of '\n' to '\r\n' in
3735
3886
# stdout, which would corrupt the subunit stream.
3744
3895
self.additional_selftest_args.setdefault(
3745
3896
'suite_decorators', []).append(parallel)
3747
raise errors.BzrCommandError(
3898
raise errors.BzrCommandError(gettext(
3748
3899
"--benchmark is no longer supported from bzr 2.2; "
3749
"use bzr-usertest instead")
3900
"use bzr-usertest instead"))
3750
3901
test_suite_factory = None
3903
exclude_pattern = None
3905
exclude_pattern = '(' + '|'.join(exclude) + ')'
3907
self._disable_fsync()
3751
3908
selftest_kwargs = {"verbose": verbose,
3752
3909
"pattern": pattern,
3753
3910
"stop_on_failure": one,
3776
3933
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
3779
3945
class cmd_version(Command):
3780
3946
__doc__ = """Show version of bzr."""
3833
3999
The source of the merge can be specified either in the form of a branch,
3834
4000
or in the form of a path to a file containing a merge directive generated
3835
4001
with bzr send. If neither is specified, the default is the upstream branch
3836
or the branch most recently merged using --remember.
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.
3838
4007
When merging from a branch, by default bzr will try to merge in all new
3839
4008
work from the other branch, automatically determining an appropriate base
3846
4015
through OTHER, excluding BASE but including OTHER, will be merged. If this
3847
4016
causes some revisions to be skipped, i.e. if the destination branch does
3848
4017
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.
3851
4022
Revision numbers are always relative to the source branch.
3858
4029
Use bzr resolve when you have fixed a problem. See also bzr conflicts.
3860
If there is no default branch set, the first merge will set it. After
3861
that, you can omit the branch to use the default. To change the
3862
default, use --remember. The value will only be saved if the remote
3863
location can be accessed.
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.
3865
4036
The results of the merge are placed into the destination working
3866
4037
directory, where they can be reviewed (with bzr diff), tested, and then
3867
4038
committed to record the result of the merge.
3869
4040
merge refuses to run if there are any uncommitted changes, unless
3870
--force is given. The --force option can also be used to create a
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
3871
4044
merge revision which has more than two parents.
3873
4046
If one would like to merge changes from the working tree of the other
3933
4106
def run(self, location=None, revision=None, force=False,
3934
merge_type=None, show_base=False, reprocess=None, remember=False,
4107
merge_type=None, show_base=False, reprocess=None, remember=None,
3935
4108
uncommitted=False, pull=False,
3936
4109
directory=None,
3971
4148
mergeable = None
3973
4150
if uncommitted:
3974
raise errors.BzrCommandError('Cannot use --uncommitted'
3975
' with bundles or merge directives.')
4151
raise errors.BzrCommandError(gettext('Cannot use --uncommitted'
4152
' with bundles or merge directives.'))
3977
4154
if revision is not None:
3978
raise errors.BzrCommandError(
3979
'Cannot use -r with merge directives or bundles')
4155
raise errors.BzrCommandError(gettext(
4156
'Cannot use -r with merge directives or bundles'))
3980
4157
merger, verified = _mod_merge.Merger.from_mergeable(tree,
3981
4158
mergeable, None)
3983
4160
if merger is None and uncommitted:
3984
4161
if revision is not None and len(revision) > 0:
3985
raise errors.BzrCommandError('Cannot use --uncommitted and'
3986
' --revision at the same time.')
4162
raise errors.BzrCommandError(gettext('Cannot use --uncommitted and'
4163
' --revision at the same time.'))
3987
4164
merger = self.get_merger_from_uncommitted(tree, location, None)
3988
4165
allow_pending = False
3997
4174
self.sanity_check_merger(merger)
3998
4175
if (merger.base_rev_id == merger.other_rev_id and
3999
4176
merger.other_rev_id is not None):
4000
note('Nothing to do.')
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.'))
4002
4186
if pull and not preview:
4003
4187
if merger.interesting_files is not None:
4004
raise errors.BzrCommandError('Cannot pull individual files')
4188
raise errors.BzrCommandError(gettext('Cannot pull individual files'))
4005
4189
if (merger.base_rev_id == tree.last_revision()):
4006
4190
result = tree.pull(merger.other_branch, False,
4007
4191
merger.other_rev_id)
4008
4192
result.report(self.outf)
4010
4194
if merger.this_basis is None:
4011
raise errors.BzrCommandError(
4195
raise errors.BzrCommandError(gettext(
4012
4196
"This branch has no commits."
4013
" (perhaps you would prefer 'bzr pull')")
4197
" (perhaps you would prefer 'bzr pull')"))
4015
4199
return self._do_preview(merger)
4016
4200
elif interactive:
4076
4260
# Use reprocess if the merger supports it
4077
4261
merger.reprocess = merger.merge_type.supports_reprocess
4078
4262
if merger.reprocess and not merger.merge_type.supports_reprocess:
4079
raise errors.BzrCommandError("Conflict reduction is not supported"
4080
" for merge type %s." %
4263
raise errors.BzrCommandError(gettext("Conflict reduction is not supported"
4264
" for merge type %s.") %
4081
4265
merger.merge_type)
4082
4266
if merger.reprocess and merger.show_base:
4083
raise errors.BzrCommandError("Cannot do conflict reduction and"
4267
raise errors.BzrCommandError(gettext("Cannot do conflict reduction and"
4086
4270
def _get_merger_from_branch(self, tree, location, revision, remember,
4087
4271
possible_transports, pb):
4114
4298
if other_revision_id is None:
4115
4299
other_revision_id = _mod_revision.ensure_null(
4116
4300
other_branch.last_revision())
4117
# Remember where we merge from
4118
if ((remember or tree.branch.get_submit_branch() is None) and
4119
user_location is not None):
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)))):
4120
4310
tree.branch.set_submit_branch(other_branch.base)
4121
4311
# Merge tags (but don't set them in the master branch yet, the user
4122
4312
# might revert this merge). Commit will propagate them.
4185
4375
stored_location_type = "parent"
4186
4376
mutter("%s", stored_location)
4187
4377
if stored_location is None:
4188
raise errors.BzrCommandError("No location specified or remembered")
4378
raise errors.BzrCommandError(gettext("No location specified or remembered"))
4189
4379
display_url = urlutils.unescape_for_display(stored_location, 'utf-8')
4190
note(u"%s remembered %s location %s", verb_string,
4191
stored_location_type, display_url)
4380
note(gettext("{0} remembered {1} location {2}").format(verb_string,
4381
stored_location_type, display_url))
4192
4382
return stored_location
4458
4648
type=_parse_revision_str,
4459
4649
help='Filter on local branch revisions (inclusive). '
4460
4650
'See "help revisionspec" for details.'),
4461
Option('include-merges',
4651
Option('include-merged',
4462
4652
'Show all revisions in addition to the mainline ones.'),
4653
Option('include-merges', hidden=True,
4654
help='Historical alias for --include-merged.'),
4464
4656
encoding_type = 'replace'
4468
4660
theirs_only=False,
4469
4661
log_format=None, long=False, short=False, line=False,
4470
4662
show_ids=False, verbose=False, this=False, other=False,
4471
include_merges=False, revision=None, my_revision=None,
4663
include_merged=None, revision=None, my_revision=None,
4665
include_merges=symbol_versioning.DEPRECATED_PARAMETER):
4473
4666
from bzrlib.missing import find_unmerged, iter_log_revisions
4474
4667
def message(s):
4475
4668
if not is_quiet():
4476
4669
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
4479
4687
mine_only = this
4519
4727
local_extra, remote_extra = find_unmerged(
4520
4728
local_branch, remote_branch, restrict,
4521
4729
backward=not reverse,
4522
include_merges=include_merges,
4730
include_merged=include_merged,
4523
4731
local_revid_range=local_revid_range,
4524
4732
remote_revid_range=remote_revid_range)
4546
4756
if remote_extra and not mine_only:
4547
4757
if printed_local is True:
4548
4758
message("\n\n\n")
4549
message("You are missing %d revision(s):\n" %
4759
message(ngettext("You are missing %d revision:\n",
4760
"You are missing %d revisions:\n",
4761
len(remote_extra)) %
4550
4762
len(remote_extra))
4551
4763
for revision in iter_log_revisions(remote_extra,
4552
4764
remote_branch.repository,
4557
4769
if mine_only and not local_extra:
4558
4770
# We checked local, and found nothing extra
4559
message('This branch is up to date.\n')
4771
message(gettext('This branch has no new revisions.\n'))
4560
4772
elif theirs_only and not remote_extra:
4561
4773
# We checked remote, and found nothing extra
4562
message('Other branch is up to date.\n')
4774
message(gettext('Other branch has no new revisions.\n'))
4563
4775
elif not (mine_only or theirs_only or local_extra or
4565
4777
# We checked both branches, and neither one had extra
4567
message("Branches are up to date.\n")
4779
message(gettext("Branches are up to date.\n"))
4568
4780
self.cleanup_now()
4569
4781
if not status_code and parent is None and other_branch is not None:
4570
4782
self.add_cleanup(local_branch.lock_write().unlock)
4731
4944
def run(self, revision_id_list=None, revision=None, directory=u'.'):
4732
4945
if revision_id_list is not None and revision is not None:
4733
raise errors.BzrCommandError('You can only supply one of revision_id or --revision')
4946
raise errors.BzrCommandError(gettext('You can only supply one of revision_id or --revision'))
4734
4947
if revision_id_list is None and revision is None:
4735
raise errors.BzrCommandError('You must supply either --revision or a revision_id')
4948
raise errors.BzrCommandError(gettext('You must supply either --revision or a revision_id'))
4736
4949
b = WorkingTree.open_containing(directory)[0].branch
4737
4950
self.add_cleanup(b.lock_write().unlock)
4738
4951
return self._run(b, revision_id_list, revision)
4808
5021
location = b.get_old_bound_location()
4809
5022
except errors.UpgradeRequired:
4810
raise errors.BzrCommandError('No location supplied. '
4811
'This format does not remember old locations.')
5023
raise errors.BzrCommandError(gettext('No location supplied. '
5024
'This format does not remember old locations.'))
4813
5026
if location is None:
4814
5027
if b.get_bound_location() is not None:
4815
raise errors.BzrCommandError('Branch is already bound')
5028
raise errors.BzrCommandError(gettext('Branch is already bound'))
4817
raise errors.BzrCommandError('No location supplied '
4818
'and no previous location known')
5030
raise errors.BzrCommandError(gettext('No location supplied '
5031
'and no previous location known'))
4819
5032
b_other = Branch.open(location)
4821
5034
b.bind(b_other)
4822
5035
except errors.DivergedBranches:
4823
raise errors.BzrCommandError('These branches have diverged.'
4824
' Try merging, and then bind again.')
5036
raise errors.BzrCommandError(gettext('These branches have diverged.'
5037
' Try merging, and then bind again.'))
4825
5038
if b.get_config().has_explicit_nickname():
4826
5039
b.nick = b_other.nick
4867
5080
takes_options = ['verbose', 'revision',
4868
5081
Option('dry-run', help='Don\'t actually make changes.'),
4869
5082
Option('force', help='Say yes to all questions.'),
5084
help='Keep tags that point to removed revisions.'),
4870
5085
Option('local',
4871
5086
help="Only remove the commits from the local branch"
4872
5087
" when in a checkout."
4877
5092
encoding_type = 'replace'
4879
def run(self, location=None,
4880
dry_run=False, verbose=False,
4881
revision=None, force=False, local=False):
5094
def run(self, location=None, dry_run=False, verbose=False,
5095
revision=None, force=False, local=False, keep_tags=False):
4882
5096
if location is None:
4883
5097
location = u'.'
4884
5098
control, relpath = bzrdir.BzrDir.open_containing(location)
4893
5107
self.add_cleanup(tree.lock_write().unlock)
4895
5109
self.add_cleanup(b.lock_write().unlock)
4896
return self._run(b, tree, dry_run, verbose, revision, force, local=local)
5110
return self._run(b, tree, dry_run, verbose, revision, force,
4898
def _run(self, b, tree, dry_run, verbose, revision, force, local=False):
5113
def _run(self, b, tree, dry_run, verbose, revision, force, local,
4899
5115
from bzrlib.log import log_formatter, show_log
4900
5116
from bzrlib.uncommit import uncommit
4931
5147
end_revision=last_revno)
4934
self.outf.write('Dry-run, pretending to remove'
4935
' the above revisions.\n')
5150
self.outf.write(gettext('Dry-run, pretending to remove'
5151
' the above revisions.\n'))
4937
self.outf.write('The above revision(s) will be removed.\n')
5153
self.outf.write(gettext('The above revision(s) will be removed.\n'))
4940
5156
if not ui.ui_factory.confirm_action(
4941
'Uncommit these revisions',
5157
gettext(u'Uncommit these revisions'),
4942
5158
'bzrlib.builtins.uncommit',
4944
self.outf.write('Canceled\n')
5160
self.outf.write(gettext('Canceled\n'))
4947
5163
mutter('Uncommitting from {%s} to {%s}',
4948
5164
last_rev_id, rev_id)
4949
5165
uncommit(b, tree=tree, dry_run=dry_run, verbose=verbose,
4950
revno=revno, local=local)
4951
self.outf.write('You can restore the old tip by running:\n'
4952
' bzr pull . -r revid:%s\n' % last_rev_id)
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)
4955
5171
class cmd_break_lock(Command):
5101
5317
containing_tree = WorkingTree.open_containing(parent_dir)[0]
5102
5318
repo = containing_tree.branch.repository
5103
5319
if not repo.supports_rich_root():
5104
raise errors.BzrCommandError(
5320
raise errors.BzrCommandError(gettext(
5105
5321
"Can't join trees because %s doesn't support rich root data.\n"
5106
"You can use bzr upgrade on the repository."
5322
"You can use bzr upgrade on the repository.")
5111
5327
except errors.BadReferenceTarget, e:
5112
5328
# XXX: Would be better to just raise a nicely printable
5113
5329
# exception from the real origin. Also below. mbp 20070306
5114
raise errors.BzrCommandError("Cannot join %s. %s" %
5330
raise errors.BzrCommandError(
5331
gettext("Cannot join {0}. {1}").format(tree, e.reason))
5118
5334
containing_tree.subsume(sub_tree)
5119
5335
except errors.BadSubsumeSource, e:
5120
raise errors.BzrCommandError("Cannot join %s. %s" %
5336
raise errors.BzrCommandError(
5337
gettext("Cannot join {0}. {1}").format(tree, e.reason))
5124
5340
class cmd_split(Command):
5216
5432
elif stored_public_branch is None:
5217
5433
branch.set_public_branch(public_branch)
5218
5434
if not include_bundle and public_branch is None:
5219
raise errors.BzrCommandError('No public branch specified or'
5435
raise errors.BzrCommandError(gettext('No public branch specified or'
5221
5437
base_revision_id = None
5222
5438
if revision is not None:
5223
5439
if len(revision) > 2:
5224
raise errors.BzrCommandError('bzr merge-directive takes '
5225
'at most two one revision identifiers')
5440
raise errors.BzrCommandError(gettext('bzr merge-directive takes '
5441
'at most two one revision identifiers'))
5226
5442
revision_id = revision[-1].as_revision_id(branch)
5227
5443
if len(revision) == 2:
5228
5444
base_revision_id = revision[0].as_revision_id(branch)
5230
5446
revision_id = branch.last_revision()
5231
5447
revision_id = ensure_null(revision_id)
5232
5448
if revision_id == NULL_REVISION:
5233
raise errors.BzrCommandError('No revisions to bundle.')
5449
raise errors.BzrCommandError(gettext('No revisions to bundle.'))
5234
5450
directive = merge_directive.MergeDirective2.from_objects(
5235
5451
branch.repository, revision_id, time.time(),
5236
5452
osutils.local_time_offset(), submit_branch,
5280
5496
source branch defaults to that containing the working directory, but can
5281
5497
be changed using --from.
5499
Both the submit branch and the public branch follow the usual behavior with
5500
respect to --remember: If there is no default location set, the first send
5501
will set it (use --no-remember to avoid setting it). After that, you can
5502
omit the location to use the default. To change the default, use
5503
--remember. The value will only be saved if the location can be accessed.
5283
5505
In order to calculate those changes, bzr must analyse the submit branch.
5284
5506
Therefore it is most efficient for the submit branch to be a local mirror.
5285
5507
If a public location is known for the submit_branch, that location is used
5356
5578
def run(self, submit_branch=None, public_branch=None, no_bundle=False,
5357
no_patch=False, revision=None, remember=False, output=None,
5579
no_patch=False, revision=None, remember=None, output=None,
5358
5580
format=None, mail_to=None, message=None, body=None,
5359
5581
strict=None, **kwargs):
5360
5582
from bzrlib.send import send
5484
5706
self.add_cleanup(branch.lock_write().unlock)
5486
5708
if tag_name is None:
5487
raise errors.BzrCommandError("No tag specified to delete.")
5709
raise errors.BzrCommandError(gettext("No tag specified to delete."))
5488
5710
branch.tags.delete_tag(tag_name)
5489
note('Deleted tag %s.' % tag_name)
5711
note(gettext('Deleted tag %s.') % tag_name)
5492
5714
if len(revision) != 1:
5493
raise errors.BzrCommandError(
5715
raise errors.BzrCommandError(gettext(
5494
5716
"Tags can only be placed on a single revision, "
5496
5718
revision_id = revision[0].as_revision_id(branch)
5498
5720
revision_id = branch.last_revision()
5499
5721
if tag_name is None:
5500
5722
tag_name = branch.automatic_tag_name(revision_id)
5501
5723
if tag_name is None:
5502
raise errors.BzrCommandError(
5503
"Please specify a tag name.")
5504
if (not force) and branch.tags.has_tag(tag_name):
5724
raise errors.BzrCommandError(gettext(
5725
"Please specify a tag name."))
5727
existing_target = branch.tags.lookup_tag(tag_name)
5728
except errors.NoSuchTag:
5729
existing_target = None
5730
if not force and existing_target not in (None, revision_id):
5505
5731
raise errors.TagAlreadyExists(tag_name)
5506
branch.tags.set_tag(tag_name, revision_id)
5507
note('Created tag %s.' % tag_name)
5732
if existing_target == revision_id:
5733
note(gettext('Tag %s already exists for that revision.') % tag_name)
5735
branch.tags.set_tag(tag_name, revision_id)
5736
if existing_target is None:
5737
note(gettext('Created tag %s.') % tag_name)
5739
note(gettext('Updated tag %s.') % tag_name)
5510
5742
class cmd_tags(Command):
5537
5769
self.add_cleanup(branch.lock_read().unlock)
5539
graph = branch.repository.get_graph()
5540
rev1, rev2 = _get_revision_range(revision, branch, self.name())
5541
revid1, revid2 = rev1.rev_id, rev2.rev_id
5542
# only show revisions between revid1 and revid2 (inclusive)
5543
tags = [(tag, revid) for tag, revid in tags if
5544
graph.is_between(revid, revid1, revid2)]
5771
# Restrict to the specified range
5772
tags = self._tags_for_range(branch, revision)
5545
5773
if sort is None:
5546
5774
sort = tag_sort_methods.get()
5547
5775
sort(branch, tags)
5552
5780
revno = branch.revision_id_to_dotted_revno(revid)
5553
5781
if isinstance(revno, tuple):
5554
5782
revno = '.'.join(map(str, revno))
5555
except (errors.NoSuchRevision, errors.GhostRevisionsHaveNoRevno):
5783
except (errors.NoSuchRevision,
5784
errors.GhostRevisionsHaveNoRevno):
5556
5785
# Bad tag data/merges can lead to tagged revisions
5557
5786
# which are not in this branch. Fail gracefully ...
5561
5790
for tag, revspec in tags:
5562
5791
self.outf.write('%-20s %s\n' % (tag, revspec))
5793
def _tags_for_range(self, branch, revision):
5795
rev1, rev2 = _get_revision_range(revision, branch, self.name())
5796
revid1, revid2 = rev1.rev_id, rev2.rev_id
5797
# _get_revision_range will always set revid2 if it's not specified.
5798
# If revid1 is None, it means we want to start from the branch
5799
# origin which is always a valid ancestor. If revid1 == revid2, the
5800
# ancestry check is useless.
5801
if revid1 and revid1 != revid2:
5802
# FIXME: We really want to use the same graph than
5803
# branch.iter_merge_sorted_revisions below, but this is not
5804
# easily available -- vila 2011-09-23
5805
if branch.repository.get_graph().is_ancestor(revid2, revid1):
5806
# We don't want to output anything in this case...
5808
# only show revisions between revid1 and revid2 (inclusive)
5809
tagged_revids = branch.tags.get_reverse_tag_dict()
5811
for r in branch.iter_merge_sorted_revisions(
5812
start_revision_id=revid2, stop_revision_id=revid1,
5813
stop_rule='include'):
5814
revid_tags = tagged_revids.get(r[0], None)
5816
found.extend([(tag, r[0]) for tag in revid_tags])
5565
5820
class cmd_reconfigure(Command):
5566
5821
__doc__ = """Reconfigure the type of a bzr directory.
5580
5835
takes_args = ['location?']
5581
5836
takes_options = [
5582
5837
RegistryOption.from_kwargs(
5584
title='Target type',
5585
help='The type to reconfigure the directory to.',
5840
help='The relation between branch and tree.',
5586
5841
value_switches=True, enum_switch=False,
5587
5842
branch='Reconfigure to be an unbound branch with no working tree.',
5588
5843
tree='Reconfigure to be an unbound branch with a working tree.',
5589
5844
checkout='Reconfigure to be a bound branch with a working tree.',
5590
5845
lightweight_checkout='Reconfigure to be a lightweight'
5591
5846
' checkout (with no local history).',
5848
RegistryOption.from_kwargs(
5850
title='Repository type',
5851
help='Location fo the repository.',
5852
value_switches=True, enum_switch=False,
5592
5853
standalone='Reconfigure to be a standalone branch '
5593
5854
'(i.e. stop using shared repository).',
5594
5855
use_shared='Reconfigure to use a shared repository.',
5857
RegistryOption.from_kwargs(
5859
title='Trees in Repository',
5860
help='Whether new branches in the repository have trees.',
5861
value_switches=True, enum_switch=False,
5595
5862
with_trees='Reconfigure repository to create '
5596
5863
'working trees on branches by default.',
5597
5864
with_no_trees='Reconfigure repository to not create '
5614
def run(self, location=None, target_type=None, bind_to=None, force=False,
5881
def run(self, location=None, bind_to=None, force=False,
5882
tree_type=None, repository_type=None, repository_trees=None,
5883
stacked_on=None, unstacked=None):
5617
5884
directory = bzrdir.BzrDir.open(location)
5618
5885
if stacked_on and unstacked:
5619
raise BzrCommandError("Can't use both --stacked-on and --unstacked")
5886
raise errors.BzrCommandError(gettext("Can't use both --stacked-on and --unstacked"))
5620
5887
elif stacked_on is not None:
5621
5888
reconfigure.ReconfigureStackedOn().apply(directory, stacked_on)
5622
5889
elif unstacked:
5624
5891
# At the moment you can use --stacked-on and a different
5625
5892
# reconfiguration shape at the same time; there seems no good reason
5627
if target_type is None:
5894
if (tree_type is None and
5895
repository_type is None and
5896
repository_trees is None):
5628
5897
if stacked_on or unstacked:
5631
raise errors.BzrCommandError('No target configuration '
5633
elif target_type == 'branch':
5900
raise errors.BzrCommandError(gettext('No target configuration '
5902
reconfiguration = None
5903
if tree_type == 'branch':
5634
5904
reconfiguration = reconfigure.Reconfigure.to_branch(directory)
5635
elif target_type == 'tree':
5905
elif tree_type == 'tree':
5636
5906
reconfiguration = reconfigure.Reconfigure.to_tree(directory)
5637
elif target_type == 'checkout':
5907
elif tree_type == 'checkout':
5638
5908
reconfiguration = reconfigure.Reconfigure.to_checkout(
5639
5909
directory, bind_to)
5640
elif target_type == 'lightweight-checkout':
5910
elif tree_type == 'lightweight-checkout':
5641
5911
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
5642
5912
directory, bind_to)
5643
elif target_type == 'use-shared':
5914
reconfiguration.apply(force)
5915
reconfiguration = None
5916
if repository_type == 'use-shared':
5644
5917
reconfiguration = reconfigure.Reconfigure.to_use_shared(directory)
5645
elif target_type == 'standalone':
5918
elif repository_type == 'standalone':
5646
5919
reconfiguration = reconfigure.Reconfigure.to_standalone(directory)
5647
elif target_type == 'with-trees':
5921
reconfiguration.apply(force)
5922
reconfiguration = None
5923
if repository_trees == 'with-trees':
5648
5924
reconfiguration = reconfigure.Reconfigure.set_repository_trees(
5649
5925
directory, True)
5650
elif target_type == 'with-no-trees':
5926
elif repository_trees == 'with-no-trees':
5651
5927
reconfiguration = reconfigure.Reconfigure.set_repository_trees(
5652
5928
directory, False)
5653
reconfiguration.apply(force)
5930
reconfiguration.apply(force)
5931
reconfiguration = None
5656
5934
class cmd_switch(Command):
5844
6122
name = current_view
5847
raise errors.BzrCommandError(
5848
"Both --delete and a file list specified")
6125
raise errors.BzrCommandError(gettext(
6126
"Both --delete and a file list specified"))
5850
raise errors.BzrCommandError(
5851
"Both --delete and --switch specified")
6128
raise errors.BzrCommandError(gettext(
6129
"Both --delete and --switch specified"))
5853
6131
tree.views.set_view_info(None, {})
5854
self.outf.write("Deleted all views.\n")
6132
self.outf.write(gettext("Deleted all views.\n"))
5855
6133
elif name is None:
5856
raise errors.BzrCommandError("No current view to delete")
6134
raise errors.BzrCommandError(gettext("No current view to delete"))
5858
6136
tree.views.delete_view(name)
5859
self.outf.write("Deleted '%s' view.\n" % name)
6137
self.outf.write(gettext("Deleted '%s' view.\n") % name)
5862
raise errors.BzrCommandError(
5863
"Both --switch and a file list specified")
6140
raise errors.BzrCommandError(gettext(
6141
"Both --switch and a file list specified"))
5865
raise errors.BzrCommandError(
5866
"Both --switch and --all specified")
6143
raise errors.BzrCommandError(gettext(
6144
"Both --switch and --all specified"))
5867
6145
elif switch == 'off':
5868
6146
if current_view is None:
5869
raise errors.BzrCommandError("No current view to disable")
6147
raise errors.BzrCommandError(gettext("No current view to disable"))
5870
6148
tree.views.set_view_info(None, view_dict)
5871
self.outf.write("Disabled '%s' view.\n" % (current_view))
6149
self.outf.write(gettext("Disabled '%s' view.\n") % (current_view))
5873
6151
tree.views.set_view_info(switch, view_dict)
5874
6152
view_str = views.view_display_str(tree.views.lookup_view())
5875
self.outf.write("Using '%s' view: %s\n" % (switch, view_str))
6153
self.outf.write(gettext("Using '{0}' view: {1}\n").format(switch, view_str))
5878
self.outf.write('Views defined:\n')
6156
self.outf.write(gettext('Views defined:\n'))
5879
6157
for view in sorted(view_dict):
5880
6158
if view == current_view:
5884
6162
view_str = views.view_display_str(view_dict[view])
5885
6163
self.outf.write('%s %-20s %s\n' % (active, view, view_str))
5887
self.outf.write('No views defined.\n')
6165
self.outf.write(gettext('No views defined.\n'))
5888
6166
elif file_list:
5889
6167
if name is None:
5890
6168
# No name given and no current view set
5892
6170
elif name == 'off':
5893
raise errors.BzrCommandError(
5894
"Cannot change the 'off' pseudo view")
6171
raise errors.BzrCommandError(gettext(
6172
"Cannot change the 'off' pseudo view"))
5895
6173
tree.views.set_view(name, sorted(file_list))
5896
6174
view_str = views.view_display_str(tree.views.lookup_view())
5897
self.outf.write("Using '%s' view: %s\n" % (name, view_str))
6175
self.outf.write(gettext("Using '{0}' view: {1}\n").format(name, view_str))
5899
6177
# list the files
5900
6178
if name is None:
5901
6179
# No name given and no current view set
5902
self.outf.write('No current view.\n')
6180
self.outf.write(gettext('No current view.\n'))
5904
6182
view_str = views.view_display_str(tree.views.lookup_view(name))
5905
self.outf.write("'%s' view is: %s\n" % (name, view_str))
6183
self.outf.write(gettext("'{0}' view is: {1}\n").format(name, view_str))
5908
6186
class cmd_hooks(Command):
6164
6452
('cmd_version_info', [], 'bzrlib.cmd_version_info'),
6165
6453
('cmd_resolve', ['resolved'], 'bzrlib.conflicts'),
6166
6454
('cmd_conflicts', [], 'bzrlib.conflicts'),
6167
('cmd_sign_my_commits', [], 'bzrlib.sign_my_commits'),
6455
('cmd_sign_my_commits', [], 'bzrlib.commit_signature_commands'),
6456
('cmd_verify_signatures', [],
6457
'bzrlib.commit_signature_commands'),
6168
6458
('cmd_test_script', [], 'bzrlib.cmd_test_script'),
6170
6460
builtin_command_registry.register_lazy(name, aliases, module_name)