52
50
revision as _mod_revision,
61
from breezy.branch import Branch
62
from breezy.conflicts import ConflictList
63
from breezy.transport import memory
64
from breezy.smtp_connection import SMTPConnection
65
from breezy.workingtree import WorkingTree
66
from breezy.i18n import gettext, ngettext
59
from bzrlib.branch import Branch
60
from bzrlib.conflicts import ConflictList
61
from bzrlib.transport import memory
62
from bzrlib.revisionspec import RevisionSpec, RevisionInfo
63
from bzrlib.smtp_connection import SMTPConnection
64
from bzrlib.workingtree import WorkingTree
65
from bzrlib.i18n import gettext, ngettext
69
from .commands import (
68
from bzrlib.commands import (
71
70
builtin_command_registry,
73
from bzrlib.option import (
79
78
_parse_revision_str,
81
from .revisionspec import (
80
from bzrlib.trace import mutter, note, warning, is_quiet, get_verbosity_level
91
from .trace import mutter, note, warning, is_quiet, get_verbosity_level
94
86
def _get_branch_location(control_dir, possible_transports=None):
476
469
gettext('You cannot specify a NULL revision.'))
477
470
rev_id = rev.as_revision_id(b)
478
471
self.print_revision(revisions, rev_id)
473
b.repository.unlock()
476
class cmd_dump_btree(Command):
477
__doc__ = """Dump the contents of a btree index file to stdout.
479
PATH is a btree index file, it can be any URL. This includes things like
480
.bzr/repository/pack-names, or .bzr/repository/indices/a34b3a...ca4a4.iix
482
By default, the tuples stored in the index file will be displayed. With
483
--raw, we will uncompress the pages, but otherwise display the raw bytes
487
# TODO: Do we want to dump the internal nodes as well?
488
# TODO: It would be nice to be able to dump the un-parsed information,
489
# rather than only going through iter_all_entries. However, this is
490
# good enough for a start
492
encoding_type = 'exact'
493
takes_args = ['path']
494
takes_options = [Option('raw', help='Write the uncompressed bytes out,'
495
' rather than the parsed tuples.'),
498
def run(self, path, raw=False):
499
dirname, basename = osutils.split(path)
500
t = transport.get_transport(dirname)
502
self._dump_raw_bytes(t, basename)
504
self._dump_entries(t, basename)
506
def _get_index_and_bytes(self, trans, basename):
507
"""Create a BTreeGraphIndex and raw bytes."""
508
bt = btree_index.BTreeGraphIndex(trans, basename, None)
509
bytes = trans.get_bytes(basename)
510
bt._file = cStringIO.StringIO(bytes)
511
bt._size = len(bytes)
514
def _dump_raw_bytes(self, trans, basename):
517
# We need to parse at least the root node.
518
# This is because the first page of every row starts with an
519
# uncompressed header.
520
bt, bytes = self._get_index_and_bytes(trans, basename)
521
for page_idx, page_start in enumerate(xrange(0, len(bytes),
522
btree_index._PAGE_SIZE)):
523
page_end = min(page_start + btree_index._PAGE_SIZE, len(bytes))
524
page_bytes = bytes[page_start:page_end]
526
self.outf.write('Root node:\n')
527
header_end, data = bt._parse_header_from_bytes(page_bytes)
528
self.outf.write(page_bytes[:header_end])
530
self.outf.write('\nPage %d\n' % (page_idx,))
531
if len(page_bytes) == 0:
532
self.outf.write('(empty)\n');
534
decomp_bytes = zlib.decompress(page_bytes)
535
self.outf.write(decomp_bytes)
536
self.outf.write('\n')
538
def _dump_entries(self, trans, basename):
540
st = trans.stat(basename)
541
except errors.TransportNotPossible:
542
# We can't stat, so we'll fake it because we have to do the 'get()'
544
bt, _ = self._get_index_and_bytes(trans, basename)
546
bt = btree_index.BTreeGraphIndex(trans, basename, st.st_size)
547
for node in bt.iter_all_entries():
548
# Node is made up of:
549
# (index, key, value, [references])
553
refs_as_tuples = None
555
refs_as_tuples = static_tuple.as_tuples(refs)
556
as_tuple = (tuple(node[1]), node[2], refs_as_tuples)
557
self.outf.write('%s\n' % (as_tuple,))
481
560
class cmd_remove_tree(Command):
893
972
self.outf.write('\n')
896
class cmd_cp(Command):
897
__doc__ = """Copy a file.
900
brz cp OLDNAME NEWNAME
902
brz cp SOURCE... DESTINATION
904
If the last argument is a versioned directory, all the other names
905
are copied into it. Otherwise, there must be exactly two arguments
906
and the file is copied to a new name.
908
Files cannot be copied between branches. Only files can be copied
912
takes_args = ['names*']
915
encoding_type = 'replace'
917
def run(self, names_list):
919
if names_list is None:
921
if len(names_list) < 2:
922
raise errors.BzrCommandError(gettext("missing file argument"))
923
tree, rel_names = WorkingTree.open_containing_paths(names_list, canonicalize=False)
924
for file_name in rel_names[0:-1]:
926
raise errors.BzrCommandError(gettext("can not copy root of branch"))
927
self.add_cleanup(tree.lock_tree_write().unlock)
928
into_existing = osutils.isdir(names_list[-1])
929
if not into_existing:
931
(src, dst) = rel_names
933
raise errors.BzrCommandError(gettext('to copy multiple files the'
934
' destination must be a versioned'
938
pairs = [(n, osutils.joinpath([rel_names[-1], osutils.basename(n)]))
939
for n in rel_names[:-1]]
941
for src, dst in pairs:
943
src_kind = tree.stored_kind(src)
944
except errors.NoSuchFile:
945
raise errors.BzrCommandError(
946
gettext('Could not copy %s => %s: %s is not versioned.')
949
raise errors.BzrCommandError(
950
gettext('Could not copy %s => %s . %s is not versioned\.'
952
if src_kind == 'directory':
953
raise errors.BzrCommandError(
954
gettext('Could not copy %s => %s . %s is a directory.'
956
dst_parent = osutils.split(dst)[0]
959
dst_parent_kind = tree.stored_kind(dst_parent)
960
except errors.NoSuchFile:
961
raise errors.BzrCommandError(
962
gettext('Could not copy %s => %s: %s is not versioned.')
963
% (src, dst, dst_parent))
964
if dst_parent_kind != 'directory':
965
raise errors.BzrCommandError(
966
gettext('Could not copy to %s: %s is not a directory.')
967
% (dst_parent, dst_parent))
969
tree.copy_one(src, dst)
972
975
class cmd_mv(Command):
973
976
__doc__ = """Move or rename a file.
976
brz mv OLDNAME NEWNAME
979
bzr mv OLDNAME NEWNAME
978
brz mv SOURCE... DESTINATION
981
bzr mv SOURCE... DESTINATION
980
983
If the last argument is a versioned directory, all the other names
981
984
are moved into it. Otherwise, there must be exactly two arguments
1434
1435
help="Bind new branch to from location."),
1437
aliases = ['get', 'clone']
1437
1439
def run(self, from_location, to_location=None, revision=None,
1438
1440
hardlink=False, stacked=False, standalone=False, no_tree=False,
1439
1441
use_existing_dir=False, switch=False, bind=False,
1440
1442
files_from=None):
1441
from breezy import switch as _mod_switch
1443
from bzrlib import switch as _mod_switch
1444
from bzrlib.tag import _merge_tags_if_possible
1445
if self.invoked_as in ['get', 'clone']:
1446
ui.ui_factory.show_user_warning(
1447
'deprecated_command',
1448
deprecated_name=self.invoked_as,
1449
recommended_name='branch',
1450
deprecated_in_version='2.4')
1442
1451
accelerator_tree, br_from = controldir.ControlDir.open_tree_or_branch(
1444
1453
if not (hardlink or files_from):
1489
1498
if to_dir is None:
1491
1500
# preserve whatever source format we have.
1492
to_dir = br_from.controldir.sprout(
1493
to_transport.base, revision_id,
1494
possible_transports=[to_transport],
1495
accelerator_tree=accelerator_tree, hardlink=hardlink,
1496
stacked=stacked, force_new_repo=standalone,
1497
create_tree_if_local=not no_tree, source_branch=br_from)
1501
to_dir = br_from.bzrdir.sprout(to_transport.base, revision_id,
1502
possible_transports=[to_transport],
1503
accelerator_tree=accelerator_tree,
1504
hardlink=hardlink, stacked=stacked,
1505
force_new_repo=standalone,
1506
create_tree_if_local=not no_tree,
1507
source_branch=br_from)
1498
1508
branch = to_dir.open_branch(
1499
1509
possible_transports=[
1500
br_from.controldir.root_transport, to_transport])
1510
br_from.bzrdir.root_transport, to_transport])
1501
1511
except errors.NoSuchRevision:
1502
1512
to_transport.delete_tree('.')
1503
1513
msg = gettext("The branch {0} has no revision {1}.").format(
1510
1520
to_repo = to_dir.create_repository()
1511
1521
to_repo.fetch(br_from.repository, revision_id=revision_id)
1512
1522
branch = br_from.sprout(to_dir, revision_id=revision_id)
1513
br_from.tags.merge_to(branch.tags)
1523
_merge_tags_if_possible(br_from, branch)
1515
1524
# If the source branch is stacked, the new branch may
1516
1525
# be stacked whether we asked for that explicitly or not.
1517
1526
# We therefore need a try/except here and not just 'if stacked:'
1519
1528
note(gettext('Created new stacked branch referring to %s.') %
1520
1529
branch.get_stacked_on_url())
1521
except (errors.NotStacked, _mod_branch.UnstackableBranchFormat,
1522
errors.UnstackableRepositoryFormat) as e:
1530
except (errors.NotStacked, errors.UnstackableBranchFormat,
1531
errors.UnstackableRepositoryFormat), e:
1523
1532
note(ngettext('Branched %d revision.', 'Branched %d revisions.', branch.revno()) % branch.revno())
1525
1534
# Bind to the parent
1699
1708
If there are any uncommitted changes in the tree, they will be carried
1700
1709
across and remain as uncommitted changes after the update. To discard
1701
these changes, use 'brz revert'. The uncommitted changes may conflict
1710
these changes, use 'bzr revert'. The uncommitted changes may conflict
1702
1711
with the changes brought in by the change in basis revision.
1704
If the tree's branch is bound to a master branch, brz will also update
1713
If the tree's branch is bound to a master branch, bzr will also update
1705
1714
the branch from the master.
1707
1716
You cannot update just a single file or directory, because each Bazaar
1708
1717
working tree has just a single basis revision. If you want to restore a
1709
file that has been removed locally, use 'brz revert' instead of 'brz
1718
file that has been removed locally, use 'bzr revert' instead of 'bzr
1710
1719
update'. If you want to restore a file to its state in a previous
1711
revision, use 'brz revert' with a '-r' option, or use 'brz cat' to write
1720
revision, use 'bzr revert' with a '-r' option, or use 'bzr cat' to write
1712
1721
out the old content of that file to a new location.
1714
1723
The 'dir' argument, if given, must be the location of the root of a
2105
2114
branch = create_branch(to_transport.base, format=format,
2106
2115
possible_transports=[to_transport],
2107
2116
force_new_tree=force_new_tree)
2108
a_controldir = branch.controldir
2117
a_bzrdir = branch.bzrdir
2110
from .transport.local import LocalTransport
2111
if a_controldir.has_branch():
2119
from bzrlib.transport.local import LocalTransport
2120
if a_bzrdir.has_branch():
2112
2121
if (isinstance(to_transport, LocalTransport)
2113
and not a_controldir.has_workingtree()):
2122
and not a_bzrdir.has_workingtree()):
2114
2123
raise errors.BranchExistsWithoutWorkingTree(location)
2115
2124
raise errors.AlreadyBranchError(location)
2116
branch = a_controldir.create_branch()
2117
if not no_tree and not a_controldir.has_workingtree():
2118
a_controldir.create_workingtree()
2125
branch = a_bzrdir.create_branch()
2126
if not no_tree and not a_bzrdir.has_workingtree():
2127
a_bzrdir.create_workingtree()
2119
2128
if append_revisions_only:
2121
2130
branch.set_append_revisions_only(True)
2123
2132
raise errors.BzrCommandError(gettext('This branch format cannot be set'
2124
2133
' to append-revisions-only. Try --default.'))
2125
2134
if not is_quiet():
2126
from .info import describe_layout, describe_format
2135
from bzrlib.info import describe_layout, describe_format
2128
tree = a_controldir.open_workingtree(recommend_upgrade=False)
2137
tree = a_bzrdir.open_workingtree(recommend_upgrade=False)
2129
2138
except (errors.NoWorkingTree, errors.NotLocalUrl):
2131
2140
repository = branch.repository
2132
2141
layout = describe_layout(repository, branch, tree).lower()
2133
format = describe_format(a_controldir, repository, branch, tree)
2142
format = describe_format(a_bzrdir, repository, branch, tree)
2134
2143
self.outf.write(gettext("Created a {0} (format: {1})\n").format(
2135
2144
layout, format))
2136
2145
if repository.is_shared():
2137
2146
#XXX: maybe this can be refactored into transport.path_or_url()
2138
url = repository.controldir.root_transport.external_url()
2147
url = repository.bzrdir.root_transport.external_url()
2140
2149
url = urlutils.local_path_from_url(url)
2141
except urlutils.InvalidURL:
2150
except errors.InvalidURL:
2143
2152
self.outf.write(gettext("Using shared repository: %s\n") % url)
2188
2197
def run(self, location, format=None, no_trees=False):
2189
2198
if format is None:
2190
format = controldir.format_registry.make_controldir('default')
2199
format = controldir.format_registry.make_bzrdir('default')
2192
2201
if location is None:
2195
2204
to_transport = transport.get_transport(location)
2197
if format.fixed_components:
2198
repo_format_name = None
2200
repo_format_name = format.repository_format.get_format_string()
2202
2206
(repo, newdir, require_stacking, repository_policy) = (
2203
2207
format.initialize_on_transport_ex(to_transport,
2204
2208
create_prefix=True, make_working_trees=not no_trees,
2205
2209
shared_repo=True, force_new_repo=True,
2206
2210
use_existing_dir=True,
2207
repo_format_name=repo_format_name))
2211
repo_format_name=format.repository_format.get_format_string()))
2208
2212
if not is_quiet():
2209
from .info import show_bzrdir_info
2213
from bzrlib.info import show_bzrdir_info
2210
2214
show_bzrdir_info(newdir, verbose=0, outfile=self.outf)
2240
2244
Shows the difference in the working tree versus the last commit::
2244
2248
Difference between the working tree and revision 1::
2248
2252
Difference between revision 3 and revision 1::
2252
2256
Difference between revision 3 and revision 1 for branch xxx::
2256
2260
The changes introduced by revision 2 (equivalent to -r1..2)::
2260
2264
To see the changes introduced by revision X::
2264
2268
Note that in the case of a merge, the -c option shows the changes
2265
2269
compared to the left hand parent. To see the changes against
2266
2270
another parent, use::
2268
brz diff -r<chosen_parent>..X
2272
bzr diff -r<chosen_parent>..X
2270
2274
The changes between the current revision and the previous revision
2271
2275
(equivalent to -c-1 and -r-2..-1)
2275
2279
Show just the differences for file NEWS::
2279
2283
Show the differences in working tree xxx for file NEWS::
2283
2287
Show the differences from branch xxx to this working tree:
2287
2291
Show the differences between two branches for file NEWS::
2289
brz diff --old xxx --new yyy NEWS
2291
Same as 'brz diff' but prefix paths with old/ and new/::
2293
brz diff --prefix old/:new/
2293
bzr diff --old xxx --new yyy NEWS
2295
Same as 'bzr diff' but prefix paths with old/ and new/::
2297
bzr diff --prefix old/:new/
2295
2299
Show the differences using a custom diff program with options::
2297
brz diff --using /usr/bin/diff --diff-options -wu
2301
bzr diff --using /usr/bin/diff --diff-options -wu
2299
2303
_see_also = ['status']
2300
2304
takes_args = ['file*']
2301
2305
takes_options = [
2302
Option('diff-options', type=text_type,
2306
Option('diff-options', type=str,
2303
2307
help='Pass these options to the external diff program.'),
2304
Option('prefix', type=text_type,
2308
Option('prefix', type=str,
2305
2309
short_name='p',
2306
2310
help='Set prefixes added to old and new filenames, as '
2307
2311
'two values separated by a colon. (eg "old/:new/").'),
2309
2313
help='Branch/tree to compare from.',
2313
2317
help='Branch/tree to compare to.',
2318
2322
Option('using',
2319
2323
help='Use this command to compare files.',
2322
2326
RegistryOption('format',
2323
2327
short_name='F',
2324
2328
help='Diff format to use.',
2325
lazy_registry=('breezy.diff', 'format_registry'),
2329
lazy_registry=('bzrlib.diff', 'format_registry'),
2326
2330
title='Diff format'),
2327
2331
Option('context',
2328
2332
help='How many lines of context to show.',
2335
2339
@display_command
2336
2340
def run(self, revision=None, file_list=None, diff_options=None,
2337
prefix=None, old=None, new=None, using=None, format=None,
2341
prefix=None, old=None, new=None, using=None, format=None,
2339
from .diff import (get_trees_and_branches_to_diff_locked,
2343
from bzrlib.diff import (get_trees_and_branches_to_diff_locked,
2340
2344
show_diff_trees)
2346
if (prefix is None) or (prefix == '0'):
2343
2347
# diff -p0 format
2346
elif prefix == u'1' or prefix is None:
2347
2351
old_label = 'old/'
2348
2352
new_label = 'new/'
2349
elif u':' in prefix:
2350
old_label, new_label = prefix.split(u":")
2354
old_label, new_label = prefix.split(":")
2352
2356
raise errors.BzrCommandError(gettext(
2353
2357
'--prefix expects two values separated by a colon'
2354
2358
' (eg "old/:new/")'))
2356
2360
if revision and len(revision) > 2:
2357
raise errors.BzrCommandError(gettext('brz diff --revision takes exactly'
2361
raise errors.BzrCommandError(gettext('bzr diff --revision takes exactly'
2358
2362
' one or two revision specifiers'))
2360
2364
if using is not None and format is not None:
2607
2612
GUI tools and IDEs are often better at exploring history than command
2608
2613
line tools: you may prefer qlog or viz from qbzr or bzr-gtk, the
2609
bzr-explorer shell, or the Loggerhead web interface. See the Bazaar
2610
Plugin Guide <http://doc.bazaar.canonical.com/plugins/en/> and
2614
bzr-explorer shell, or the Loggerhead web interface. See the Plugin
2615
Guide <http://doc.bazaar.canonical.com/plugins/en/> and
2611
2616
<http://wiki.bazaar.canonical.com/IDEIntegration>.
2613
You may find it useful to add the aliases below to ``breezy.conf``::
2618
You may find it useful to add the aliases below to ``bazaar.conf``::
2617
2622
top = log -l10 --line
2618
2623
show = log -v -p
2620
``brz tip`` will then show the latest revision while ``brz top``
2625
``bzr tip`` will then show the latest revision while ``bzr top``
2621
2626
will show the last 10 mainline revisions. To see the details of a
2622
particular revision X, ``brz show -rX``.
2627
particular revision X, ``bzr show -rX``.
2624
2629
If you are interested in looking deeper into a particular merge X,
2625
use ``brz log -n0 -rX``.
2630
use ``bzr log -n0 -rX``.
2627
``brz log -v`` on a branch with lots of history is currently
2632
``bzr log -v`` on a branch with lots of history is currently
2628
2633
very slow. A fix for this issue is currently under development.
2629
2634
With or without that fix, it is recommended that a revision range
2630
2635
be given when using the -v option.
2632
brz has a generic full-text matching plugin, brz-search, that can be
2637
bzr has a generic full-text matching plugin, bzr-search, that can be
2633
2638
used to find revisions matching user names, commit messages, etc.
2634
2639
Among other features, this plugin can find all revisions containing
2635
2640
a list of words but not others.
3124
3144
Ignore the top level Makefile::
3126
brz ignore ./Makefile
3146
bzr ignore ./Makefile
3128
3148
Ignore .class files in all directories...::
3130
brz ignore "*.class"
3150
bzr ignore "*.class"
3132
3152
...but do not ignore "special.class"::
3134
brz ignore "!special.class"
3154
bzr ignore "!special.class"
3136
3156
Ignore files whose name begins with the "#" character::
3140
Ignore .o files under the lib directory::
3142
brz ignore "lib/**/*.o"
3144
Ignore .o files under the lib directory::
3146
brz ignore "RE:lib/.*\\.o"
3160
Ignore .o files under the lib directory::
3162
bzr ignore "lib/**/*.o"
3164
Ignore .o files under the lib directory::
3166
bzr ignore "RE:lib/.*\.o"
3148
3168
Ignore everything but the "debian" toplevel directory::
3150
brz ignore "RE:(?!debian/).*"
3170
bzr ignore "RE:(?!debian/).*"
3152
3172
Ignore everything except the "local" toplevel directory,
3153
3173
but always ignore autosave files ending in ~, even under local/::
3156
brz ignore "!./local"
3176
bzr ignore "!./local"
3160
3180
_see_also = ['status', 'ignored', 'patterns']
3161
3181
takes_args = ['name_pattern*']
3162
3182
takes_options = ['directory',
3163
3183
Option('default-rules',
3164
help='Display the default ignore rules that brz uses.')
3184
help='Display the default ignore rules that bzr uses.')
3167
3187
def run(self, name_pattern_list=None, default_rules=None,
3168
3188
directory=u'.'):
3169
from breezy import ignores
3189
from bzrlib import ignores
3170
3190
if default_rules is not None:
3171
3191
# dump the default rules and exit
3172
3192
for pattern in ignores.USER_DEFAULTS:
3460
3479
A common mistake is to forget to add a new file or directory before
3461
3480
running the commit command. The --strict option checks for unknown
3462
3481
files and aborts the commit if any are found. More advanced pre-commit
3463
checks can be implemented by defining hooks. See ``brz help hooks``
3482
checks can be implemented by defining hooks. See ``bzr help hooks``
3466
3485
:Things to note:
3468
3487
If you accidentially commit the wrong changes or make a spelling
3469
3488
mistake in the commit message say, you can use the uncommit command
3470
to undo it. See ``brz help uncommit`` for details.
3489
to undo it. See ``bzr help uncommit`` for details.
3472
3491
Hooks can also be configured to run after a commit. This allows you
3473
3492
to trigger updates to external systems like bug trackers. The --fixes
3474
3493
option can be used to record the association between a revision and
3475
one or more bugs. See ``brz help bugs`` for details.
3494
one or more bugs. See ``bzr help bugs`` for details.
3478
3497
_see_also = ['add', 'bugs', 'hooks', 'uncommit']
3479
3498
takes_args = ['selected*']
3480
3499
takes_options = [
3481
ListOption('exclude', type=text_type, short_name='x',
3500
ListOption('exclude', type=str, short_name='x',
3482
3501
help="Do not consider changes made to a given path."),
3483
Option('message', type=text_type,
3502
Option('message', type=unicode,
3484
3503
short_name='m',
3485
3504
help="Description of the new revision."),
3487
3506
Option('unchanged',
3488
3507
help='Commit even if nothing has changed.'),
3489
Option('file', type=text_type,
3508
Option('file', type=str,
3490
3509
short_name='F',
3491
3510
argname='msgfile',
3492
3511
help='Take commit message from this file.'),
3493
3512
Option('strict',
3494
3513
help="Refuse to commit if there are unknown "
3495
3514
"files in the working tree."),
3496
Option('commit-time', type=text_type,
3515
Option('commit-time', type=str,
3497
3516
help="Manually set a commit time using commit date "
3498
3517
"format, e.g. '2009-10-10 08:00:00 +0100'."),
3499
ListOption('fixes', type=text_type,
3518
ListOption('fixes', type=str,
3500
3519
help="Mark a bug as being fixed by this revision "
3501
"(see \"brz help bugs\")."),
3502
ListOption('author', type=text_type,
3520
"(see \"bzr help bugs\")."),
3521
ListOption('author', type=unicode,
3503
3522
help="Set the author's name, if it's different "
3504
3523
"from the committer."),
3505
3524
Option('local',
3533
3552
"No tracker specified for bug %s. Use the form "
3534
3553
"'tracker:id' or specify a default bug tracker "
3535
3554
"using the `bugtracker` option.\nSee "
3536
"\"brz help bugs\" for more information on this "
3555
"\"bzr help bugs\" for more information on this "
3537
3556
"feature. Commit refused.") % fixed_bug)
3538
3557
tag = default_bugtracker
3539
3558
bug_id = tokens[0]
3540
3559
elif len(tokens) != 2:
3541
3560
raise errors.BzrCommandError(gettext(
3542
3561
"Invalid bug %s. Must be in the form of 'tracker:id'. "
3543
"See \"brz help bugs\" for more information on this "
3562
"See \"bzr help bugs\" for more information on this "
3544
3563
"feature.\nCommit refused.") % fixed_bug)
3546
3565
tag, bug_id = tokens
3548
3567
yield bugtracker.get_bug_url(tag, branch, bug_id)
3549
except bugtracker.UnknownBugTrackerAbbreviation:
3568
except errors.UnknownBugTrackerAbbreviation:
3550
3569
raise errors.BzrCommandError(gettext(
3551
3570
'Unrecognized bug %s. Commit refused.') % fixed_bug)
3552
except bugtracker.MalformedBugIdentifier as e:
3571
except errors.MalformedBugIdentifier, e:
3553
3572
raise errors.BzrCommandError(gettext(
3554
u"%s\nCommit refused.") % (e,))
3573
"%s\nCommit refused.") % (str(e),))
3556
3575
def run(self, message=None, file=None, verbose=False, selected_list=None,
3557
3576
unchanged=False, strict=False, local=False, fixes=None,
3558
3577
author=None, show_diff=False, exclude=None, commit_time=None,
3560
from .commit import (
3579
from bzrlib.errors import (
3561
3580
PointlessCommit,
3563
from .errors import (
3564
3581
ConflictsInTree,
3565
3582
StrictCommitFailed
3567
from .msgeditor import (
3584
from bzrlib.msgeditor import (
3568
3585
edit_commit_message_encoded,
3569
3586
generate_commit_message_template,
3570
3587
make_commit_message_template_encoded,
3955
3975
def print_aliases(self):
3956
3976
"""Print out the defined aliases in a similar format to bash."""
3957
3977
aliases = _mod_config.GlobalConfig().get_aliases()
3958
for key, value in sorted(viewitems(aliases)):
3959
self.outf.write('brz alias %s="%s"\n' % (key, value))
3978
for key, value in sorted(aliases.iteritems()):
3979
self.outf.write('bzr alias %s="%s"\n' % (key, value))
3961
3981
@display_command
3962
3982
def print_alias(self, alias_name):
3963
from .commands import get_alias
3983
from bzrlib.commands import get_alias
3964
3984
alias = get_alias(alias_name)
3965
3985
if alias is None:
3966
self.outf.write("brz alias: %s: not found\n" % alias_name)
3986
self.outf.write("bzr alias: %s: not found\n" % alias_name)
3968
3988
self.outf.write(
3969
'brz alias %s="%s"\n' % (alias_name, ' '.join(alias)))
3989
'bzr alias %s="%s"\n' % (alias_name, ' '.join(alias)))
3971
3991
def set_alias(self, alias_name, alias_command):
3972
3992
"""Save the alias in the global config."""
4018
4038
Run only tests relating to 'ignore'::
4022
4042
Disable plugins and list tests as they're run::
4024
brz --no-plugins selftest -v
4044
bzr --no-plugins selftest -v
4026
4046
# NB: this is used from the class without creating an instance, which is
4027
4047
# why it does not have a self parameter.
4028
4048
def get_transport_type(typestring):
4029
4049
"""Parse and return a transport specifier."""
4030
4050
if typestring == "sftp":
4031
from .tests import stub_sftp
4051
from bzrlib.tests import stub_sftp
4032
4052
return stub_sftp.SFTPAbsoluteServer
4033
4053
elif typestring == "memory":
4034
from .tests import test_server
4054
from bzrlib.tests import test_server
4035
4055
return memory.MemoryServer
4036
4056
elif typestring == "fakenfs":
4037
from .tests import test_server
4057
from bzrlib.tests import test_server
4038
4058
return test_server.FakeNFSServer
4039
4059
msg = "No known transport type %s. Supported types are: sftp\n" %\
4067
4087
help='List the tests instead of running them.'),
4068
4088
RegistryOption('parallel',
4069
4089
help="Run the test suite in parallel.",
4070
lazy_registry=('breezy.tests', 'parallel_registry'),
4090
lazy_registry=('bzrlib.tests', 'parallel_registry'),
4071
4091
value_switches=False,
4073
Option('randomize', type=text_type, argname="SEED",
4093
Option('randomize', type=str, argname="SEED",
4074
4094
help='Randomize the order of tests using the given'
4075
4095
' seed or "now" for the current time.'),
4076
ListOption('exclude', type=text_type, argname="PATTERN",
4096
ListOption('exclude', type=str, argname="PATTERN",
4077
4097
short_name='x',
4078
4098
help='Exclude tests that match this regular'
4079
4099
' expression.'),
4081
help='Output test progress via subunit v1.'),
4083
help='Output test progress via subunit v2.'),
4101
help='Output test progress via subunit.'),
4084
4102
Option('strict', help='Fail on missing dependencies or '
4085
4103
'known failures.'),
4086
Option('load-list', type=text_type, argname='TESTLISTFILE',
4104
Option('load-list', type=str, argname='TESTLISTFILE',
4087
4105
help='Load a test id list from a text file.'),
4088
ListOption('debugflag', type=text_type, short_name='E',
4106
ListOption('debugflag', type=str, short_name='E',
4089
4107
help='Turn on a selftest debug flag.'),
4090
ListOption('starting-with', type=text_type, argname='TESTID',
4108
ListOption('starting-with', type=str, argname='TESTID',
4091
4109
param_name='starting_with', short_name='s',
4093
4111
'Load only the tests starting with TESTID.'),
4115
4134
# too heavily. The call should be as early as possible, as
4116
4135
# error reporting for past duplicate imports won't have useful
4118
if sys.version_info[0] < 3:
4119
# TODO(pad.lv/1696545): Allow proxying on Python 3, since
4120
# disallowing it currently leads to failures in many places.
4121
lazy_import.disallow_proxying()
4137
lazy_import.disallow_proxying()
4126
raise errors.BzrCommandError("tests not available. Install the "
4127
"breezy tests to run the breezy testsuite.")
4139
from bzrlib import tests
4129
4141
if testspecs_list is not None:
4130
4142
pattern = '|'.join(testspecs_list)
4135
from .tests import SubUnitBzrRunnerv1
4147
from bzrlib.tests import SubUnitBzrRunner
4136
4148
except ImportError:
4137
raise errors.BzrCommandError(gettext(
4138
"subunit not available. subunit needs to be installed "
4139
"to use --subunit."))
4140
self.additional_selftest_args['runner_class'] = SubUnitBzrRunnerv1
4149
raise errors.BzrCommandError(gettext("subunit not available. subunit "
4150
"needs to be installed to use --subunit."))
4151
self.additional_selftest_args['runner_class'] = SubUnitBzrRunner
4141
4152
# On Windows, disable automatic conversion of '\n' to '\r\n' in
4142
4153
# stdout, which would corrupt the subunit stream.
4143
4154
# FIXME: This has been fixed in subunit trunk (>0.0.5) so the
4264
4266
The source of the merge can be specified either in the form of a branch,
4265
4267
or in the form of a path to a file containing a merge directive generated
4266
with brz send. If neither is specified, the default is the upstream branch
4268
with bzr send. If neither is specified, the default is the upstream branch
4267
4269
or the branch most recently merged using --remember. The source of the
4268
4270
merge may also be specified in the form of a path to a file in another
4269
4271
branch: in this case, only the modifications to that file are merged into
4270
4272
the current working tree.
4272
When merging from a branch, by default brz will try to merge in all new
4274
When merging from a branch, by default bzr will try to merge in all new
4273
4275
work from the other branch, automatically determining an appropriate base
4274
4276
revision. If this fails, you may need to give an explicit base.
4276
To pick a different ending revision, pass "--revision OTHER". brz will
4278
To pick a different ending revision, pass "--revision OTHER". bzr will
4277
4279
try to merge in all new work up to and including revision OTHER.
4279
4281
If you specify two values, "--revision BASE..OTHER", only revisions BASE
4532
4534
raise errors.BzrCommandError(gettext("Cannot do conflict reduction and"
4533
4535
" show base."))
4535
if (merger.merge_type.requires_file_merge_plan and
4536
(not getattr(merger.this_tree, 'plan_file_merge', None) or
4537
not getattr(merger.other_tree, 'plan_file_merge', None) or
4538
(merger.base_tree is not None and
4539
not getattr(merger.base_tree, 'plan_file_merge', None)))):
4540
raise errors.BzrCommandError(
4541
gettext('Plan file merge unsupported: '
4542
'Merge type incompatible with tree formats.'))
4544
4537
def _get_merger_from_branch(self, tree, location, revision, remember,
4545
4538
possible_transports, pb):
4546
4539
"""Produce a merger from a location, assuming it refers to a branch."""
4540
from bzrlib.tag import _merge_tags_if_possible
4547
4541
# find the branch locations
4548
4542
other_loc, user_location = self._select_branch_location(tree, location,
4698
4692
" merges. Not cherrypicking or"
4699
4693
" multi-merges."))
4700
4694
repository = tree.branch.repository
4701
interesting_files = None
4695
interesting_ids = None
4702
4696
new_conflicts = []
4703
4697
conflicts = tree.conflicts()
4704
4698
if file_list is not None:
4705
interesting_files = set()
4699
interesting_ids = set()
4706
4700
for filename in file_list:
4707
if not tree.is_versioned(filename):
4701
file_id = tree.path2id(filename)
4708
4703
raise errors.NotVersionedError(filename)
4709
interesting_files.add(filename)
4710
if tree.kind(filename) != "directory":
4704
interesting_ids.add(file_id)
4705
if tree.kind(file_id) != "directory":
4713
for path, ie in tree.iter_entries_by_dir(specific_files=[filename]):
4714
interesting_files.add(path)
4708
# FIXME: Support nested trees
4709
for name, ie in tree.root_inventory.iter_entries(file_id):
4710
interesting_ids.add(ie.file_id)
4715
4711
new_conflicts = conflicts.select_conflicts(tree, file_list)[0]
4717
4713
# Remerge only supports resolving contents conflicts
4718
4714
allowed_conflicts = ('text conflict', 'contents conflict')
4719
4715
restore_files = [c.path for c in conflicts
4720
4716
if c.typestring in allowed_conflicts]
4721
_mod_merge.transform_tree(tree, tree.basis_tree(), interesting_files)
4717
_mod_merge.transform_tree(tree, tree.basis_tree(), interesting_ids)
4722
4718
tree.set_conflicts(ConflictList(new_conflicts))
4723
4719
if file_list is not None:
4724
4720
restore_files = file_list
4940
4936
log_format=None, long=False, short=False, line=False,
4941
4937
show_ids=False, verbose=False, this=False, other=False,
4942
4938
include_merged=None, revision=None, my_revision=None,
4944
from breezy.missing import find_unmerged, iter_log_revisions
4940
include_merges=symbol_versioning.DEPRECATED_PARAMETER):
4941
from bzrlib.missing import find_unmerged, iter_log_revisions
4945
4942
def message(s):
4946
4943
if not is_quiet():
4947
4944
self.outf.write(s)
4946
if symbol_versioning.deprecated_passed(include_merges):
4947
ui.ui_factory.show_user_warning(
4948
'deprecated_command_option',
4949
deprecated_name='--include-merges',
4950
recommended_name='--include-merged',
4951
deprecated_in_version='2.5',
4952
command=self.invoked_as)
4953
if include_merged is None:
4954
include_merged = include_merges
4956
raise errors.BzrCommandError(gettext(
4957
'{0} and {1} are mutually exclusive').format(
4958
'--include-merges', '--include-merged'))
4949
4959
if include_merged is None:
4950
4960
include_merged = False
5199
5209
if wt is not None and revision is None:
5200
5210
# If there is a tree and we're not annotating historical
5201
5211
# versions, annotate the working tree's content.
5202
annotate_file_tree(wt, relpath, self.outf, long, all,
5203
show_ids=show_ids, file_id=file_id)
5212
annotate_file_tree(wt, file_id, self.outf, long, all,
5205
annotate_file_tree(tree, relpath, self.outf, long, all,
5206
show_ids=show_ids, branch=branch, file_id=file_id)
5215
annotate_file_tree(tree, file_id, self.outf, long, all,
5216
show_ids=show_ids, branch=branch)
5209
5219
class cmd_re_sign(Command):
5817
5826
help='Branch to generate the submission from, '
5818
5827
'rather than the one containing the working directory.',
5819
5828
short_name='f',
5821
5830
Option('output', short_name='o',
5822
5831
help='Write merge directive to this file or directory; '
5823
5832
'use - for stdout.',
5825
5834
Option('strict',
5826
5835
help='Refuse to send if there are uncommitted changes in'
5827
5836
' the working tree, --no-strict disables the check.'),
5828
5837
Option('mail-to', help='Mail the request to this address.',
5832
Option('body', help='Body for the email.', type=text_type),
5841
Option('body', help='Body for the email.', type=unicode),
5833
5842
RegistryOption('format',
5834
5843
help='Use the specified output format.',
5835
lazy_registry=('breezy.send', 'format_registry')),
5844
lazy_registry=('bzrlib.send', 'format_registry')),
5838
5847
def run(self, submit_branch=None, public_branch=None, no_bundle=False,
5839
5848
no_patch=False, revision=None, remember=None, output=None,
5840
5849
format=None, mail_to=None, message=None, body=None,
5841
5850
strict=None, **kwargs):
5842
from .send import send
5851
from bzrlib.send import send
5843
5852
return send(submit_branch, revision, public_branch, remember,
5844
5853
format, no_bundle, no_patch, output,
5845
5854
kwargs.get('from', '.'), mail_to, message, body,
6672
6675
if tree is None:
6673
6676
tree = branch.basis_tree()
6674
6677
if path is None:
6675
info = viewitems(branch._get_all_reference_info())
6678
info = branch._get_all_reference_info().iteritems()
6676
6679
self._display_reference_info(tree, branch, info)
6678
if not tree.is_versioned(path):
6681
file_id = tree.path2id(path)
6679
6683
raise errors.NotVersionedError(path)
6680
6684
if location is None:
6681
info = [(path, branch.get_reference_info(path))]
6685
info = [(file_id, branch.get_reference_info(file_id))]
6682
6686
self._display_reference_info(tree, branch, info)
6684
branch.set_reference_info(
6685
path, location, file_id=tree.path2id(path))
6688
branch.set_reference_info(file_id, path, location)
6687
6690
def _display_reference_info(self, tree, branch, info):
6689
for path, (location, file_id) in info:
6692
for file_id, (path, location) in info:
6694
path = tree.id2path(file_id)
6695
except errors.NoSuchId:
6690
6697
ref_list.append((path, location))
6691
6698
for path, location in sorted(ref_list):
6692
6699
self.outf.write('%s %s\n' % (path, location))
6696
6703
__doc__ = """Export command helps and error messages in po format."""
6699
takes_options = [Option('plugin',
6706
takes_options = [Option('plugin',
6700
6707
help='Export help text from named command '\
6701
6708
'(defaults to all built in commands).',
6703
6710
Option('include-duplicates',
6704
6711
help='Output multiple copies of the same msgid '
6705
6712
'string if it appears more than once.'),
6708
6715
def run(self, plugin=None, include_duplicates=False):
6709
from .export_pot import export_pot
6716
from bzrlib.export_pot import export_pot
6710
6717
export_pot(self.outf, plugin, include_duplicates)
6713
class cmd_import(Command):
6714
__doc__ = """Import sources from a directory, tarball or zip file
6716
This command will import a directory, tarball or zip file into a bzr
6717
tree, replacing any versioned files already present. If a directory is
6718
specified, it is used as the target. If the directory does not exist, or
6719
is not versioned, it is created.
6721
Tarballs may be gzip or bzip2 compressed. This is autodetected.
6723
If the tarball or zip has a single root directory, that directory is
6724
stripped when extracting the tarball. This is not done for directories.
6727
takes_args = ['source', 'tree?']
6729
def run(self, source, tree=None):
6730
from .upstream_import import do_import
6731
do_import(source, tree)
6734
class cmd_link_tree(Command):
6735
__doc__ = """Hardlink matching files to another tree.
6737
Only files with identical content and execute bit will be linked.
6740
takes_args = ['location']
6742
def run(self, location):
6743
from .transform import link_tree
6744
target_tree = WorkingTree.open_containing(".")[0]
6745
source_tree = WorkingTree.open(location)
6746
target_tree.lock_write()
6748
source_tree.lock_read()
6750
link_tree(target_tree, source_tree)
6752
source_tree.unlock()
6754
target_tree.unlock()
6757
class cmd_fetch_ghosts(Command):
6758
__doc__ = """Attempt to retrieve ghosts from another branch.
6760
If the other branch is not supplied, the last-pulled branch is used.
6764
aliases = ['fetch-missing']
6765
takes_args = ['branch?']
6766
takes_options = [Option('no-fix', help="Skip additional synchonization.")]
6768
def run(self, branch=None, no_fix=False):
6769
from .fetch_ghosts import GhostFetcher
6770
installed, failed = GhostFetcher.from_cmdline(branch).run()
6771
if len(installed) > 0:
6772
self.outf.write("Installed:\n")
6773
for rev in installed:
6774
self.outf.write(rev + "\n")
6776
self.outf.write("Still missing:\n")
6778
self.outf.write(rev + "\n")
6779
if not no_fix and len(installed) > 0:
6780
cmd_reconcile().run(".")
6783
6720
def _register_lazy_builtins():
6784
6721
# register lazy builtins from other modules; called at startup and should
6785
6722
# be only called once.
6786
6723
for (name, aliases, module_name) in [
6787
('cmd_bisect', [], 'breezy.bisect'),
6788
('cmd_bundle_info', [], 'breezy.bundle.commands'),
6789
('cmd_config', [], 'breezy.config'),
6790
('cmd_dump_btree', [], 'breezy.bzr.debug_commands'),
6791
('cmd_dpush', [], 'breezy.foreign'),
6792
('cmd_version_info', [], 'breezy.cmd_version_info'),
6793
('cmd_resolve', ['resolved'], 'breezy.conflicts'),
6794
('cmd_conflicts', [], 'breezy.conflicts'),
6795
('cmd_ping', [], 'breezy.bzr.smart.ping'),
6796
('cmd_sign_my_commits', [], 'breezy.commit_signature_commands'),
6797
('cmd_verify_signatures', [], 'breezy.commit_signature_commands'),
6798
('cmd_test_script', [], 'breezy.cmd_test_script'),
6724
('cmd_bundle_info', [], 'bzrlib.bundle.commands'),
6725
('cmd_config', [], 'bzrlib.config'),
6726
('cmd_dpush', [], 'bzrlib.foreign'),
6727
('cmd_version_info', [], 'bzrlib.cmd_version_info'),
6728
('cmd_resolve', ['resolved'], 'bzrlib.conflicts'),
6729
('cmd_conflicts', [], 'bzrlib.conflicts'),
6730
('cmd_ping', [], 'bzrlib.smart.ping'),
6731
('cmd_sign_my_commits', [], 'bzrlib.commit_signature_commands'),
6732
('cmd_verify_signatures', [], 'bzrlib.commit_signature_commands'),
6733
('cmd_test_script', [], 'bzrlib.cmd_test_script'),
6800
6735
builtin_command_registry.register_lazy(name, aliases, module_name)