946
946
if branch_to.get_parent() is None or remember:
947
947
branch_to.set_parent(branch_from.base)
949
if revision is not None:
950
revision_id = revision.as_revision_id(branch_from)
952
branch_to.lock_write()
949
if branch_from is not branch_to:
950
branch_from.lock_read()
954
if tree_to is not None:
955
view_info = _get_view_info_for_change_reporter(tree_to)
956
change_reporter = delta._ChangeReporter(
957
unversioned_filter=tree_to.is_ignored, view_info=view_info)
958
result = tree_to.pull(branch_from, overwrite, revision_id,
960
possible_transports=possible_transports,
963
result = branch_to.pull(branch_from, overwrite, revision_id,
966
result.report(self.outf)
967
if verbose and result.old_revid != result.new_revid:
968
log.show_branch_change(branch_to, self.outf, result.old_revno,
952
if revision is not None:
953
revision_id = revision.as_revision_id(branch_from)
955
branch_to.lock_write()
957
if tree_to is not None:
958
view_info = _get_view_info_for_change_reporter(tree_to)
959
change_reporter = delta._ChangeReporter(
960
unversioned_filter=tree_to.is_ignored,
962
result = tree_to.pull(
963
branch_from, overwrite, revision_id, change_reporter,
964
possible_transports=possible_transports, local=local)
966
result = branch_to.pull(
967
branch_from, overwrite, revision_id, local=local)
969
result.report(self.outf)
970
if verbose and result.old_revid != result.new_revid:
971
log.show_branch_change(
972
branch_to, self.outf, result.old_revno,
977
if branch_from is not branch_to:
974
981
class cmd_push(Command):
1021
1028
'for the commit history. Only the work not present in the '
1022
1029
'referenced branch is included in the branch created.',
1032
help='Refuse to push if there are uncommitted changes in'
1033
' the working tree.'),
1025
1035
takes_args = ['location?']
1026
1036
encoding_type = 'replace'
1028
1038
def run(self, location=None, remember=False, overwrite=False,
1029
1039
create_prefix=False, verbose=False, revision=None,
1030
1040
use_existing_dir=False, directory=None, stacked_on=None,
1041
stacked=False, strict=None):
1032
1042
from bzrlib.push import _show_push_branch
1034
# Get the source branch and revision_id
1035
1044
if directory is None:
1036
1045
directory = '.'
1037
br_from = Branch.open_containing(directory)[0]
1046
# Get the source branch
1047
tree, br_from = bzrdir.BzrDir.open_tree_or_branch(directory)
1049
strict = br_from.get_config().get_user_option('push_strict')
1050
if strict is not None:
1051
# FIXME: This should be better supported by config
1053
bools = dict(yes=True, no=False, on=True, off=False,
1054
true=True, false=False)
1056
strict = bools[strict.lower()]
1060
changes = tree.changes_from(tree.basis_tree())
1061
if changes.has_changed():
1062
raise errors.UncommittedChanges(tree)
1063
# Get the tip's revision_id
1038
1064
revision = _get_one_revision('push', revision)
1039
1065
if revision is not None:
1040
1066
revision_id = revision.in_history(br_from).rev_id
1080
1106
class cmd_branch(Command):
1081
"""Create a new copy of a branch.
1107
"""Create a new branch that is a copy of an existing branch.
1083
1109
If the TO_LOCATION is omitted, the last component of the FROM_LOCATION will
1084
1110
be used. In other words, "branch ../foo/bar" will attempt to create ./bar.
1621
1650
branch.set_append_revisions_only(True)
1622
1651
except errors.UpgradeRequired:
1623
1652
raise errors.BzrCommandError('This branch format cannot be set'
1624
' to append-revisions-only. Try --experimental-branch6')
1653
' to append-revisions-only. Try --default.')
1625
1654
if not is_quiet():
1626
1655
from bzrlib.info import describe_layout, describe_format
2367
2396
if path is None:
2372
2400
raise errors.BzrCommandError('cannot specify both --from-root'
2376
2403
tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
2406
# Calculate the prefix to use
2410
prefix = relpath + '/'
2411
elif fs_path != '.':
2412
prefix = fs_path + '/'
2382
2414
if revision is not None or tree is None:
2383
2415
tree = _get_one_revision_tree('ls', revision, branch=branch)
2393
2425
tree.lock_read()
2395
for fp, fc, fkind, fid, entry in tree.list_files(include_root=False):
2396
if fp.startswith(relpath):
2397
rp = fp[len(relpath):]
2398
fp = osutils.pathjoin(prefix, rp)
2399
if not recursive and '/' in rp:
2401
if not all and not selection[fc]:
2403
if kind is not None and fkind != kind:
2407
views.check_path_in_view(tree, fp)
2408
except errors.FileOutsideView:
2410
kindch = entry.kind_character()
2411
outstring = fp + kindch
2412
ui.ui_factory.clear_term()
2414
outstring = '%-8s %s' % (fc, outstring)
2415
if show_ids and fid is not None:
2416
outstring = "%-50s %s" % (outstring, fid)
2417
self.outf.write(outstring + '\n')
2419
self.outf.write(fp + '\0')
2422
self.outf.write(fid)
2423
self.outf.write('\0')
2427
for fp, fc, fkind, fid, entry in tree.list_files(include_root=False,
2428
from_dir=relpath, recursive=recursive):
2429
# Apply additional masking
2430
if not all and not selection[fc]:
2432
if kind is not None and fkind != kind:
2437
fullpath = osutils.pathjoin(relpath, fp)
2440
views.check_path_in_view(tree, fullpath)
2441
except errors.FileOutsideView:
2446
fp = osutils.pathjoin(prefix, fp)
2447
kindch = entry.kind_character()
2448
outstring = fp + kindch
2449
ui.ui_factory.clear_term()
2451
outstring = '%-8s %s' % (fc, outstring)
2452
if show_ids and fid is not None:
2453
outstring = "%-50s %s" % (outstring, fid)
2454
self.outf.write(outstring + '\n')
2456
self.outf.write(fp + '\0')
2459
self.outf.write(fid)
2460
self.outf.write('\0')
2426
2464
if fid is not None:
2431
self.outf.write('%-50s %s\n' % (outstring, my_id))
2433
self.outf.write(outstring + '\n')
2468
self.outf.write('%-50s %s\n' % (outstring, my_id))
2470
self.outf.write(outstring + '\n')