747
747
# The destination doesn't exist; create it.
748
748
# XXX: Refactor the create_prefix/no_create_prefix code into a
749
749
# common helper function
751
def make_directory(transport):
755
def redirected(redirected_transport, e, redirection_notice):
756
return transport.get_transport(e.get_target_url())
751
to_transport.mkdir('.')
759
to_transport = transport.do_catching_redirections(
760
make_directory, to_transport, redirected)
752
761
except errors.FileExists:
753
762
if not use_existing_dir:
754
763
raise errors.BzrCommandError("Target directory %s"
763
772
" leading parent directories."
765
774
_create_prefix(to_transport)
775
except errors.TooManyRedirections:
776
raise errors.BzrCommandError("Too many redirections trying "
777
"to make %s." % location)
767
779
# Now the target directory exists, but doesn't have a .bzr
768
780
# directory. So we need to create it, along with any work to create
1916
1928
Ignore class files in all directories::
1918
bzr ignore '*.class'
1920
Ignore .o files under the lib directory::
1922
bzr ignore 'lib/**/*.o'
1924
Ignore .o files under the lib directory::
1926
bzr ignore 'RE:lib/.*\.o'
1930
bzr ignore "*.class"
1932
Ignore .o files under the lib directory::
1934
bzr ignore "lib/**/*.o"
1936
Ignore .o files under the lib directory::
1938
bzr ignore "RE:lib/.*\.o"
1929
1941
_see_also = ['status', 'ignored']
2114
2126
def run(self, filename, revision=None, name_from_revision=False):
2115
2127
if revision is not None and len(revision) != 1:
2116
2128
raise errors.BzrCommandError("bzr cat --revision takes exactly"
2129
" one revision specifier")
2130
tree, branch, relpath = \
2131
bzrdir.BzrDir.open_containing_tree_or_branch(filename)
2121
tree, b, relpath = \
2122
bzrdir.BzrDir.open_containing_tree_or_branch(filename)
2123
except errors.NotBranchError:
2134
return self._run(tree, branch, relpath, filename, revision,
2126
if revision is not None and revision[0].get_branch() is not None:
2127
b = Branch.open(revision[0].get_branch())
2139
def _run(self, tree, b, relpath, filename, revision, name_from_revision):
2128
2140
if tree is None:
2129
2141
tree = b.basis_tree()
2130
2142
if revision is None:
2438
2450
Set the current user::
2440
bzr whoami 'Frank Chu <fchu@example.com>'
2452
bzr whoami "Frank Chu <fchu@example.com>"
2442
2454
takes_options = [ Option('email',
2443
2455
help='Display email address only.'),
2592
2604
' expression.'),
2593
2605
Option('strict', help='Fail on missing dependencies or '
2594
2606
'known failures.'),
2607
Option('coverage', type=str, argname="DIRECTORY",
2608
help='Generate line coverage report in this'
2596
2611
encoding_type = 'replace'
2599
2614
transport=None, benchmark=None,
2600
2615
lsprof_timed=None, cache_dir=None,
2601
2616
first=False, list_only=False,
2602
randomize=None, exclude=None, strict=False):
2617
randomize=None, exclude=None, strict=False, coverage=None):
2603
2618
import bzrlib.ui
2604
2619
from bzrlib.tests import selftest
2605
2620
import bzrlib.benchmarks as benchmarks
2687
2703
branch1 = Branch.open_containing(branch)[0]
2688
2704
branch2 = Branch.open_containing(other)[0]
2690
last1 = ensure_null(branch1.last_revision())
2691
last2 = ensure_null(branch2.last_revision())
2693
graph = branch1.repository.get_graph(branch2.repository)
2694
base_rev_id = graph.find_unique_lca(last1, last2)
2696
print 'merge base is revision %s' % base_rev_id
2709
last1 = ensure_null(branch1.last_revision())
2710
last2 = ensure_null(branch2.last_revision())
2712
graph = branch1.repository.get_graph(branch2.repository)
2713
base_rev_id = graph.find_unique_lca(last1, last2)
2715
print 'merge base is revision %s' % base_rev_id
2699
2722
class cmd_merge(Command):
2817
2840
merger = _mod_merge.Merger.from_uncommitted(tree, other_tree,
2819
2842
allow_pending = False
2843
if other_path != '':
2844
merger.interesting_files = [other_path]
2821
2846
if merger is None:
2822
2847
merger, allow_pending = self._get_merger_from_branch(tree,
3072
3097
last committed revision is used.
3074
3099
To remove only some changes, without reverting to a prior version, use
3075
merge instead. For example, "merge . --r-2..-3" will remove the changes
3076
introduced by -2, without affecting the changes introduced by -1. Or
3077
to remove certain changes on a hunk-by-hunk basis, see the Shelf plugin.
3100
merge instead. For example, "merge . --revision -2..-3" will remove the
3101
changes introduced by -2, without affecting the changes introduced by -1.
3102
Or to remove certain changes on a hunk-by-hunk basis, see the Shelf plugin.
3079
3104
By default, any files that have been manually changed will be backed up
3080
3105
first. (Files changed only by merge are not backed up.) Backup files have
3422
3447
takes_options = ['revision']
3424
3449
def run(self, revision_id_list=None, revision=None):
3425
import bzrlib.gpg as gpg
3426
3450
if revision_id_list is not None and revision is not None:
3427
3451
raise errors.BzrCommandError('You can only supply one of revision_id or --revision')
3428
3452
if revision_id_list is None and revision is None:
3429
3453
raise errors.BzrCommandError('You must supply either --revision or a revision_id')
3430
3454
b = WorkingTree.open_containing(u'.')[0].branch
3457
return self._run(b, revision_id_list, revision)
3461
def _run(self, b, revision_id_list, revision):
3462
import bzrlib.gpg as gpg
3431
3463
gpg_strategy = gpg.GPGStrategy(b.get_config())
3432
3464
if revision_id_list is not None:
3433
for revision_id in revision_id_list:
3434
b.repository.sign_revision(revision_id, gpg_strategy)
3465
b.repository.start_write_group()
3467
for revision_id in revision_id_list:
3468
b.repository.sign_revision(revision_id, gpg_strategy)
3470
b.repository.abort_write_group()
3473
b.repository.commit_write_group()
3435
3474
elif revision is not None:
3436
3475
if len(revision) == 1:
3437
3476
revno, rev_id = revision[0].in_history(b)
3438
b.repository.sign_revision(rev_id, gpg_strategy)
3477
b.repository.start_write_group()
3479
b.repository.sign_revision(rev_id, gpg_strategy)
3481
b.repository.abort_write_group()
3484
b.repository.commit_write_group()
3439
3485
elif len(revision) == 2:
3440
3486
# are they both on rh- if so we can walk between them
3441
3487
# might be nice to have a range helper for arbitrary
3446
3492
to_revno = b.revno()
3447
3493
if from_revno is None or to_revno is None:
3448
3494
raise errors.BzrCommandError('Cannot sign a range of non-revision-history revisions')
3449
for revno in range(from_revno, to_revno + 1):
3450
b.repository.sign_revision(b.get_rev_id(revno),
3495
b.repository.start_write_group()
3497
for revno in range(from_revno, to_revno + 1):
3498
b.repository.sign_revision(b.get_rev_id(revno),
3501
b.repository.abort_write_group()
3504
b.repository.commit_write_group()
3453
3506
raise errors.BzrCommandError('Please supply either one revision, or a range.')
3530
3583
def run(self, location=None,
3531
3584
dry_run=False, verbose=False,
3532
3585
revision=None, force=False):
3533
from bzrlib.log import log_formatter, show_log
3534
from bzrlib.uncommit import uncommit
3536
3586
if location is None:
3537
3587
location = u'.'
3538
3588
control, relpath = bzrdir.BzrDir.open_containing(location)
3544
3594
b = control.open_branch()
3596
if tree is not None:
3601
return self._run(b, tree, dry_run, verbose, revision, force)
3603
if tree is not None:
3608
def _run(self, b, tree, dry_run, verbose, revision, force):
3609
from bzrlib.log import log_formatter, show_log
3610
from bzrlib.uncommit import uncommit
3612
last_revno, last_rev_id = b.last_revision_info()
3547
3615
if revision is None:
3617
rev_id = last_rev_id
3550
3619
# 'bzr uncommit -r 10' actually means uncommit
3551
3620
# so that the final tree is at revno 10.
3552
3621
# but bzrlib.uncommit.uncommit() actually uncommits
3553
3622
# the revisions that are supplied.
3554
3623
# So we need to offset it by one
3555
revno = revision[0].in_history(b).revno+1
3624
revno = revision[0].in_history(b).revno + 1
3625
if revno <= last_revno:
3626
rev_id = b.get_rev_id(revno)
3557
if revno <= b.revno():
3558
rev_id = b.get_rev_id(revno)
3559
3628
if rev_id is None or _mod_revision.is_null(rev_id):
3560
3629
self.outf.write('No revisions to uncommit.\n')
3652
3721
from bzrlib.smart import medium, server
3653
3722
from bzrlib.transport import get_transport
3654
3723
from bzrlib.transport.chroot import ChrootServer
3655
from bzrlib.transport.remote import BZR_DEFAULT_PORT, BZR_DEFAULT_INTERFACE
3656
3724
if directory is None:
3657
3725
directory = os.getcwd()
3658
3726
url = urlutils.local_path_to_url(directory)
3665
3733
smart_server = medium.SmartServerPipeStreamMedium(
3666
3734
sys.stdin, sys.stdout, t)
3668
host = BZR_DEFAULT_INTERFACE
3736
host = medium.BZR_DEFAULT_INTERFACE
3669
3737
if port is None:
3670
port = BZR_DEFAULT_PORT
3738
port = medium.BZR_DEFAULT_PORT
3672
3740
if ':' in port:
3673
3741
host, port = port.split(':')
3898
3966
for that mirror.
3900
3968
Mail is sent using your preferred mail program. This should be transparent
3901
on Windows (it uses MAPI). On *nix, it requires the xdg-email utility. If
3902
the preferred client can't be found (or used), your editor will be used.
3969
on Windows (it uses MAPI). On Linux, it requires the xdg-email utility.
3970
If the preferred client can't be found (or used), your editor will be used.
3904
3972
To use a specific mail program, set the mail_client configuration option.
3905
3973
(For Thunderbird 1.5, this works around some bugs.) Supported values for
3965
4033
outfile = open(output, 'wb')
3967
4035
branch = Branch.open_containing(from_)[0]
4036
# we may need to write data into branch's repository to calculate
3968
4039
if output is None:
3969
4040
config = branch.get_config()
3970
4041
if mail_to is None:
3971
4042
mail_to = config.get_user_option('submit_to')
3973
raise errors.BzrCommandError('No mail-to address'
3975
4043
mail_client = config.get_mail_client()
3976
4044
if remember and submit_branch is None:
3977
4045
raise errors.BzrCommandError(
4256
4325
value_switches=True, enum_switch=False,
4257
4326
branch='Reconfigure to a branch.',
4258
4327
tree='Reconfigure to a tree.',
4259
checkout='Reconfigure to a checkout.'),
4328
checkout='Reconfigure to a checkout.',
4329
lightweight_checkout='Reconfigure to a lightweight'
4260
4331
Option('bind-to', help='Branch to bind checkout to.',
4262
4333
Option('force',
4275
4346
elif target_type == 'checkout':
4276
4347
reconfiguration = reconfigure.Reconfigure.to_checkout(directory,
4349
elif target_type == 'lightweight-checkout':
4350
reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
4278
4352
reconfiguration.apply(force)
4355
class cmd_switch(Command):
4356
"""Set the branch of a checkout and update.
4358
For lightweight checkouts, this changes the branch being referenced.
4359
For heavyweight checkouts, this checks that there are no local commits
4360
versus the current bound branch, then it makes the local branch a mirror
4361
of the new location and binds to it.
4363
In both cases, the working tree is updated and uncommitted changes
4364
are merged. The user can commit or revert these as they desire.
4366
Pending merges need to be committed or reverted before using switch.
4369
takes_args = ['to_location']
4370
takes_options = [Option('force',
4371
help='Switch even if local commits will be lost.')
4374
def run(self, to_location, force=False):
4375
from bzrlib import switch
4376
to_branch = Branch.open(to_location)
4378
control_dir = bzrdir.BzrDir.open_containing(tree_location)[0]
4379
switch.switch(control_dir, to_branch, force)
4380
note('Switched to branch: %s',
4381
urlutils.unescape_for_display(to_branch.base, 'utf-8'))
4281
4384
def _create_prefix(cur_transport):
4282
4385
needed = [cur_transport]
4283
4386
# Recurse upwards until we can create a directory successfully