1
# Copyright (C) 2004-2010 Canonical Ltd
1
# Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
1180
1180
' directory exists, but does not already'
1181
1181
' have a control directory. This flag will'
1182
1182
' allow branch to proceed.'),
1184
help="Bind new branch to from location."),
1186
1184
aliases = ['get', 'clone']
1188
1186
def run(self, from_location, to_location=None, revision=None,
1189
1187
hardlink=False, stacked=False, standalone=False, no_tree=False,
1190
use_existing_dir=False, switch=False, bind=False):
1188
use_existing_dir=False, switch=False):
1191
1189
from bzrlib import switch as _mod_switch
1192
1190
from bzrlib.tag import _merge_tags_if_possible
1193
1191
accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch(
1246
1244
except (errors.NotStacked, errors.UnstackableBranchFormat,
1247
1245
errors.UnstackableRepositoryFormat), e:
1248
1246
note('Branched %d revision(s).' % branch.revno())
1250
# Bind to the parent
1251
parent_branch = Branch.open(from_location)
1252
branch.bind(parent_branch)
1253
note('New branch bound to %s' % from_location)
1255
1248
# Switch to the new branch
1256
1249
wt, _ = WorkingTree.open_containing('.')
2191
2184
:Tips & tricks:
2193
2186
GUI tools and IDEs are often better at exploring history than command
2194
line tools: you may prefer qlog or viz from qbzr or bzr-gtk, the
2195
bzr-explorer shell, or the Loggerhead web interface. See the Plugin
2196
Guide <http://doc.bazaar.canonical.com/plugins/en/> and
2197
<http://wiki.bazaar.canonical.com/IDEIntegration>.
2187
line tools. You may prefer qlog or glog from the QBzr and Bzr-Gtk packages
2188
respectively for example. (TortoiseBzr uses qlog for displaying logs.) See
2189
http://bazaar-vcs.org/BzrPlugins and http://bazaar-vcs.org/IDEIntegration.
2191
Web interfaces are often better at exploring history than command line
2192
tools, particularly for branches on servers. You may prefer Loggerhead
2193
or one of its alternatives. See http://bazaar-vcs.org/WebInterface.
2199
2195
You may find it useful to add the aliases below to ``bazaar.conf``::
2606
2602
After adding, editing or deleting that file either indirectly by
2607
2603
using this command or directly by using an editor, be sure to commit
2610
Patterns prefixed with '!' are exceptions to ignore patterns and take
2611
precedence over regular ignores. Such exceptions are used to specify
2612
files that should be versioned which would otherwise be ignored.
2614
Patterns prefixed with '!!' act as regular ignore patterns, but have
2615
precedence over the '!' exception patterns.
2617
2606
Note: ignore patterns containing shell wildcards must be quoted from
2618
2607
the shell on Unix.
2623
2612
bzr ignore ./Makefile
2625
Ignore .class files in all directories...::
2614
Ignore class files in all directories::
2627
2616
bzr ignore "*.class"
2629
...but do not ignore "special.class"::
2631
bzr ignore "!special.class"
2633
2618
Ignore .o files under the lib directory::
2635
2620
bzr ignore "lib/**/*.o"
2641
2626
Ignore everything but the "debian" toplevel directory::
2643
2628
bzr ignore "RE:(?!debian/).*"
2645
Ignore everything except the "local" toplevel directory,
2646
but always ignore "*~" autosave files, even under local/::
2649
bzr ignore "!./local"
2653
2631
_see_also = ['status', 'ignored', 'patterns']
2877
2853
chunks = content.splitlines(True)
2878
2854
content = filtered_output_bytes(chunks, filters,
2879
2855
ContentFilterContext(relpath, rev_tree))
2881
2856
self.outf.writelines(content)
2884
2858
self.outf.write(content)
3662
3636
committed to record the result of the merge.
3664
3638
merge refuses to run if there are any uncommitted changes, unless
3665
--force is given. The --force option can also be used to create a
3666
merge revision which has more than two parents.
3668
If one would like to merge changes from the working tree of the other
3669
branch without merging any committed revisions, the --uncommitted option
3672
3641
To select only some changes to merge, use "merge -i", which will prompt
3673
3642
you to apply each diff hunk and file change, similar to "shelve".
4110
4072
created as above. Directories containing unknown files will not be
4113
The working tree contains a list of revisions that have been merged but
4114
not yet committed. These revisions will be included as additional parents
4115
of the next commit. Normally, using revert clears that list as well as
4116
reverting the files. If any files are specified, revert leaves the list
4117
of uncommitted merges alone and reverts only the files. Use ``bzr revert
4118
.`` in the tree root to revert all files but keep the recorded merges,
4119
and ``bzr revert --forget-merges`` to clear the pending merge list without
4075
The working tree contains a list of pending merged revisions, which will
4076
be included as parents in the next commit. Normally, revert clears that
4077
list as well as reverting the files. If any files are specified, revert
4078
leaves the pending merge list alone and reverts only the files. Use "bzr
4079
revert ." in the tree root to revert all files but keep the merge record,
4080
and "bzr revert --forget-merges" to clear the pending merge list without
4120
4081
reverting any files.
4122
Using "bzr revert --forget-merges", it is possible to apply all of the
4123
changes from a branch in a single revision. To do this, perform the merge
4124
as desired. Then doing revert with the "--forget-merges" option will keep
4125
the content of the tree as it was, but it will clear the list of pending
4126
merges. The next commit will then contain all of the changes that are
4127
present in the other branch, but without any other parent revisions.
4128
Because this technique forgets where these changes originated, it may
4129
cause additional conflicts on later merges involving the same source and
4083
Using "bzr revert --forget-merges", it is possible to apply the changes
4084
from an arbitrary merge as a single revision. To do this, perform the
4085
merge as desired. Then doing revert with the "--forget-merges" option will
4086
keep the content of the tree as it was, but it will clear the list of
4087
pending merges. The next commit will then contain all of the changes that
4088
would have been in the merge, but without any mention of the other parent
4089
revisions. Because this technique forgets where these changes originated,
4090
it may cause additional conflicts on later merges involving the source and
4130
4091
target branches.
4405
4366
adding new commands, providing additional network transports and
4406
4367
customizing log output.
4408
See the Bazaar Plugin Guide <http://doc.bazaar.canonical.com/plugins/en/>
4409
for further information on plugins including where to find them and how to
4410
install them. Instructions are also provided there on how to write new
4411
plugins using the Python programming language.
4369
See the Bazaar web site, http://bazaar-vcs.org, for further
4370
information on plugins including where to find them and how to
4371
install them. Instructions are also provided there on how to
4372
write new plugins using the Python programming language.
4413
4374
takes_options = ['verbose']
4756
4717
CAUTION: Locks should only be broken when you are sure that the process
4757
4718
holding the lock has been stopped.
4759
You can get information on what locks are open via the 'bzr info
4760
[location]' command.
4720
You can get information on what locks are open via the 'bzr info' command.
4764
bzr break-lock bzr+ssh://example.com/bzr/foo
4766
4725
takes_args = ['location?']
5039
4998
directly from the merge directive, without retrieving data from a
5042
`bzr send` creates a compact data set that, when applied using bzr
5043
merge, has the same effect as merging from the source branch.
5045
By default the merge directive is self-contained and can be applied to any
5046
branch containing submit_branch in its ancestory without needing access to
5049
If --no-bundle is specified, then Bazaar doesn't send the contents of the
5050
revisions, but only a structured request to merge from the
5051
public_location. In that case the public_branch is needed and it must be
5052
up-to-date and accessible to the recipient. The public_branch is always
5053
included if known, so that people can check it later.
5055
The submit branch defaults to the parent of the source branch, but can be
5056
overridden. Both submit branch and public branch will be remembered in
5057
branch.conf the first time they are used for a particular branch. The
5058
source branch defaults to that containing the working directory, but can
5059
be changed using --from.
5061
In order to calculate those changes, bzr must analyse the submit branch.
5062
Therefore it is most efficient for the submit branch to be a local mirror.
5063
If a public location is known for the submit_branch, that location is used
5064
in the merge directive.
5066
The default behaviour is to send the merge directive by mail, unless -o is
5067
given, in which case it is sent to a file.
5001
If --no-bundle is specified, then public_branch is needed (and must be
5002
up-to-date), so that the receiver can perform the merge using the
5003
public_branch. The public_branch is always included if known, so that
5004
people can check it later.
5006
The submit branch defaults to the parent, but can be overridden. Both
5007
submit branch and public branch will be remembered if supplied.
5009
If a public_branch is known for the submit_branch, that public submit
5010
branch is used in the merge instructions. This means that a local mirror
5011
can be used as your actual submit branch, once you have set public_branch
5069
5014
Mail is sent using your preferred mail program. This should be transparent
5070
5015
on Windows (it uses MAPI). On Linux, it requires the xdg-email utility.
5091
5036
The merge directives created by bzr send may be applied using bzr merge or
5092
5037
bzr pull by specifying a file containing a merge directive as the location.
5094
bzr send makes extensive use of public locations to map local locations into
5095
URLs that can be used by other people. See `bzr help configuration` to
5096
set them, and use `bzr info` to display them.
5099
5040
encoding_type = 'exact'
5465
5406
that of the master.
5468
takes_args = ['to_location?']
5409
takes_args = ['to_location']
5469
5410
takes_options = [Option('force',
5470
5411
help='Switch even if local commits will be lost.'),
5472
5412
Option('create-branch', short_name='b',
5473
5413
help='Create the target branch from this one before'
5474
5414
' switching to it.'),
5477
def run(self, to_location=None, force=False, create_branch=False,
5417
def run(self, to_location, force=False, create_branch=False):
5479
5418
from bzrlib import switch
5480
5419
tree_location = '.'
5481
revision = _get_one_revision('switch', revision)
5482
5420
control_dir = bzrdir.BzrDir.open_containing(tree_location)[0]
5483
if to_location is None:
5484
if revision is None:
5485
raise errors.BzrCommandError('You must supply either a'
5486
' revision or a location')
5489
5422
branch = control_dir.open_branch()
5490
5423
had_explicit_nick = branch.get_config().has_explicit_nickname()
5504
5437
to_branch = branch.bzrdir.sprout(to_location,
5505
5438
possible_transports=[branch.bzrdir.root_transport],
5506
5439
source_branch=branch).open_branch()
5441
# from_branch = control_dir.open_branch()
5442
# except errors.NotBranchError:
5443
# raise BzrCommandError('Cannot create a branch from this'
5444
# ' location when we cannot open this branch')
5445
# from_branch.bzrdir.sprout(
5509
5449
to_branch = Branch.open(to_location)
5511
5451
this_url = self._get_branch_location(control_dir)
5512
5452
to_branch = Branch.open(
5513
5453
urlutils.join(this_url, '..', to_location))
5514
if revision is not None:
5515
revision = revision.as_revision_id(to_branch)
5516
switch.switch(control_dir, to_branch, force, revision_id=revision)
5454
switch.switch(control_dir, to_branch, force)
5517
5455
if had_explicit_nick:
5518
5456
branch = control_dir.open_branch() #get the new branch!
5519
5457
branch.nick = to_branch.nick
5802
5740
enum_switch=False, value_switches=True,
5803
5741
apply="Apply changes and remove from the shelf.",
5804
5742
dry_run="Show changes, but do not apply or remove them.",
5805
preview="Instead of unshelving the changes, show the diff that "
5806
"would result from unshelving.",
5807
5743
delete_only="Delete changes without applying them.",
5808
5744
keep="Apply changes but don't delete them.",