532
535
location can be accessed.
535
takes_options = ['remember', 'overwrite', 'revision', 'verbose']
538
takes_options = ['remember', 'overwrite', 'revision', 'verbose',
540
help='branch to pull into, '
541
'rather than the one containing the working directory',
536
546
takes_args = ['location?']
537
547
encoding_type = 'replace'
539
def run(self, location=None, remember=False, overwrite=False, revision=None, verbose=False):
549
def run(self, location=None, remember=False, overwrite=False,
550
revision=None, verbose=False,
540
552
# FIXME: too much stuff is in the command class
553
if directory is None:
542
tree_to = WorkingTree.open_containing(u'.')[0]
556
tree_to = WorkingTree.open_containing(directory)[0]
543
557
branch_to = tree_to.branch
544
558
except errors.NoWorkingTree:
546
branch_to = Branch.open_containing(u'.')[0]
560
branch_to = Branch.open_containing(directory)[0]
549
563
if location is not None:
585
598
old_rh = branch_to.revision_history()
586
599
if tree_to is not None:
587
count = tree_to.pull(branch_from, overwrite, rev_id)
600
count = tree_to.pull(branch_from, overwrite, rev_id,
601
delta.ChangeReporter(tree_to.inventory))
589
603
count = branch_to.pull(branch_from, overwrite, rev_id)
590
604
note('%d revision(s) pulled.' % (count,))
627
641
takes_options = ['remember', 'overwrite', 'verbose',
628
Option('create-prefix',
629
help='Create the path leading up to the branch '
630
'if it does not already exist'),
631
Option('use-existing-dir',
632
help='By default push will fail if the target'
633
' directory exists, but does not already'
634
' have a control directory. This flag will'
635
' allow push to proceed.'),
642
Option('create-prefix',
643
help='Create the path leading up to the branch '
644
'if it does not already exist'),
646
help='branch to push from, '
647
'rather than the one containing the working directory',
651
Option('use-existing-dir',
652
help='By default push will fail if the target'
653
' directory exists, but does not already'
654
' have a control directory. This flag will'
655
' allow push to proceed.'),
637
657
takes_args = ['location?']
638
658
encoding_type = 'replace'
640
660
def run(self, location=None, remember=False, overwrite=False,
641
create_prefix=False, verbose=False, use_existing_dir=False):
661
create_prefix=False, verbose=False,
662
use_existing_dir=False,
642
664
# FIXME: Way too big! Put this into a function called from the
645
br_from = Branch.open_containing('.')[0]
666
if directory is None:
668
br_from = Branch.open_containing(directory)[0]
646
669
stored_loc = br_from.get_push_location()
647
670
if location is None:
648
671
if stored_loc is None:
883
900
--basis is to speed up checking out from remote branches. When specified, it
884
901
uses the inventory and file contents from the basis branch in preference to the
885
902
branch being checked out.
904
See "help checkouts" for more information on checkouts.
887
906
takes_args = ['branch_location?', 'to_location?']
888
907
takes_options = ['revision', # , 'basis']
1180
1199
takes_args = ['location?']
1181
1200
takes_options = [
1182
RegistryOption('format',
1183
help='Specify a format for this branch. See "bzr '
1184
'help formats" for details',
1185
converter=bzrdir.format_registry.make_bzrdir,
1186
registry=bzrdir.format_registry,
1187
value_switches=True, title="Branch Format"),
1189
def run(self, location=None, format=None):
1201
RegistryOption('format',
1202
help='Specify a format for this branch. '
1203
'See "help formats".',
1204
registry=bzrdir.format_registry,
1205
converter=bzrdir.format_registry.make_bzrdir,
1206
value_switches=True,
1207
title="Branch Format",
1209
Option('append-revisions-only',
1210
help='Never change revnos or the existing log.'
1211
' Append revisions to it only.')
1213
def run(self, location=None, format=None, append_revisions_only=False):
1190
1214
if format is None:
1191
1215
format = bzrdir.format_registry.make_bzrdir('default')
1192
1216
if location is None:
1209
1233
existing_bzrdir = bzrdir.BzrDir.open(location)
1210
1234
except errors.NotBranchError:
1211
1235
# really a NotBzrDir error...
1212
bzrdir.BzrDir.create_branch_convenience(location, format=format)
1236
branch = bzrdir.BzrDir.create_branch_convenience(location,
1214
1239
from bzrlib.transport.local import LocalTransport
1215
1240
if existing_bzrdir.has_branch():
1218
1243
raise errors.BranchExistsWithoutWorkingTree(location)
1219
1244
raise errors.AlreadyBranchError(location)
1221
existing_bzrdir.create_branch()
1246
branch = existing_bzrdir.create_branch()
1222
1247
existing_bzrdir.create_workingtree()
1248
if append_revisions_only:
1250
branch.set_append_revisions_only(True)
1251
except errors.UpgradeRequired:
1252
raise errors.BzrCommandError('This branch format cannot be set'
1253
' to append-revisions-only. Try --experimental-branch6')
1225
1256
class cmd_init_repository(Command):
1493
1534
# find the file id to log:
1495
dir, fp = bzrdir.BzrDir.open_containing(location)
1496
b = dir.open_branch()
1536
tree, b, fp = bzrdir.BzrDir.open_containing_tree_or_branch(
1500
inv = dir.open_workingtree().inventory
1501
except (errors.NotBranchError, errors.NotLocalUrl):
1502
# either no tree, or is remote.
1503
inv = b.basis_tree().inventory
1540
tree = b.basis_tree()
1541
inv = tree.inventory
1504
1542
file_id = inv.path2id(fp)
1505
1543
if file_id is None:
1506
1544
raise errors.BzrCommandError(
1517
1555
dir, relpath = bzrdir.BzrDir.open_containing(location)
1518
1556
b = dir.open_branch()
1520
if revision is None:
1523
elif len(revision) == 1:
1524
rev1 = rev2 = revision[0].in_history(b).revno
1525
elif len(revision) == 2:
1526
if revision[1].get_branch() != revision[0].get_branch():
1527
# b is taken from revision[0].get_branch(), and
1528
# show_log will use its revision_history. Having
1529
# different branches will lead to weird behaviors.
1560
if revision is None:
1563
elif len(revision) == 1:
1564
rev1 = rev2 = revision[0].in_history(b).revno
1565
elif len(revision) == 2:
1566
if revision[1].get_branch() != revision[0].get_branch():
1567
# b is taken from revision[0].get_branch(), and
1568
# show_log will use its revision_history. Having
1569
# different branches will lead to weird behaviors.
1570
raise errors.BzrCommandError(
1571
"Log doesn't accept two revisions in different"
1573
if revision[0].spec is None:
1574
# missing begin-range means first revision
1577
rev1 = revision[0].in_history(b).revno
1579
if revision[1].spec is None:
1580
# missing end-range means last known revision
1583
rev2 = revision[1].in_history(b).revno
1530
1585
raise errors.BzrCommandError(
1531
"Log doesn't accept two revisions in different branches.")
1532
if revision[0].spec is None:
1533
# missing begin-range means first revision
1536
rev1 = revision[0].in_history(b).revno
1538
if revision[1].spec is None:
1539
# missing end-range means last known revision
1542
rev2 = revision[1].in_history(b).revno
1544
raise errors.BzrCommandError('bzr log --revision takes one or two values.')
1546
# By this point, the revision numbers are converted to the +ve
1547
# form if they were supplied in the -ve form, so we can do
1548
# this comparison in relative safety
1550
(rev2, rev1) = (rev1, rev2)
1552
if log_format is None:
1553
log_format = log.log_formatter_registry.get_default(b)
1555
lf = log_format(show_ids=show_ids, to_file=self.outf,
1556
show_timezone=timezone)
1562
direction=direction,
1563
start_revision=rev1,
1586
'bzr log --revision takes one or two values.')
1588
# By this point, the revision numbers are converted to the +ve
1589
# form if they were supplied in the -ve form, so we can do
1590
# this comparison in relative safety
1592
(rev2, rev1) = (rev1, rev2)
1594
if log_format is None:
1595
log_format = log.log_formatter_registry.get_default(b)
1597
lf = log_format(show_ids=show_ids, to_file=self.outf,
1598
show_timezone=timezone)
1604
direction=direction,
1605
start_revision=rev1,
1568
1612
def get_log_format(long=False, short=False, line=False, default='long'):
2335
2385
default, use --remember. The value will only be saved if the remote
2336
2386
location can be accessed.
2388
The results of the merge are placed into the destination working
2389
directory, where they can be reviewed (with bzr diff), tested, and then
2390
committed to record the result of the merge.
2340
2394
To merge the latest revision from bzr.dev
2354
2408
takes_args = ['branch?']
2355
2409
takes_options = ['revision', 'force', 'merge-type', 'reprocess', 'remember',
2356
Option('show-base', help="Show base revision text in "
2358
Option('uncommitted', help='Apply uncommitted changes'
2359
' from a working copy, instead of branch changes'),
2360
Option('pull', help='If the destination is already'
2361
' completely merged into the source, pull from the'
2362
' source rather than merging. When this happens,'
2363
' you do not need to commit the result.'),
2410
Option('show-base', help="Show base revision text in "
2412
Option('uncommitted', help='Apply uncommitted changes'
2413
' from a working copy, instead of branch changes'),
2414
Option('pull', help='If the destination is already'
2415
' completely merged into the source, pull from the'
2416
' source rather than merging. When this happens,'
2417
' you do not need to commit the result.'),
2419
help='branch to merge into, '
2420
'rather than the one containing the working directory',
2366
2426
def run(self, branch=None, revision=None, force=False, merge_type=None,
2367
show_base=False, reprocess=False, remember=False,
2368
uncommitted=False, pull=False):
2427
show_base=False, reprocess=False, remember=False,
2428
uncommitted=False, pull=False,
2369
2431
if merge_type is None:
2370
2432
merge_type = _mod_merge.Merge3Merger
2372
tree = WorkingTree.open_containing(u'.')[0]
2434
if directory is None: directory = u'.'
2435
tree = WorkingTree.open_containing(directory)[0]
2436
change_reporter = delta.ChangeReporter(tree.inventory)
2374
2438
if branch is not None:
2885
2951
class cmd_bind(Command):
2886
"""Bind the current branch to a master branch.
2888
After binding, commits must succeed on the master branch
2889
before they are executed on the local one.
2952
"""Convert the current branch into a checkout of the supplied branch.
2954
Once converted into a checkout, commits must succeed on the master branch
2955
before they will be applied to the local branch.
2957
See "help checkouts" for more information on checkouts.
2892
takes_args = ['location']
2960
takes_args = ['location?']
2893
2961
takes_options = []
2895
2963
def run(self, location=None):
2896
2964
b, relpath = Branch.open_containing(u'.')
2965
if location is None:
2967
location = b.get_old_bound_location()
2968
except errors.UpgradeRequired:
2969
raise errors.BzrCommandError('No location supplied. '
2970
'This format does not remember old locations.')
2972
if location is None:
2973
raise errors.BzrCommandError('No location supplied and no '
2974
'previous location known')
2897
2975
b_other = Branch.open(location)
2899
2977
b.bind(b_other)
2905
2983
class cmd_unbind(Command):
2906
"""Unbind the current branch from its master branch.
2908
After unbinding, the local branch is considered independent.
2909
All subsequent commits will be local.
2984
"""Convert the current checkout into a regular branch.
2986
After unbinding, the local branch is considered independent and subsequent
2987
commits will be local only.
2989
See "help checkouts" for more information on checkouts.
2912
2992
takes_args = []
3180
3261
raise errors.BzrCommandError("Cannot do conflict reduction and show base.")
3182
3263
merger = _mod_merge.Merger(this_tree.branch, this_tree=this_tree,
3264
pb=pb, change_reporter=change_reporter)
3184
3265
merger.pp = ProgressPhase("Merge phase", 5, pb)
3185
3266
merger.pp.next_phase()
3186
3267
merger.check_basis(check_clean)