608
609
old_rh = branch_to.revision_history()
609
610
if tree_to is not None:
610
count = tree_to.pull(branch_from, overwrite, rev_id,
611
delta.ChangeReporter())
611
result = tree_to.pull(branch_from, overwrite, rev_id,
612
delta.ChangeReporter(unversioned_filter=tree_to.is_ignored))
613
count = branch_to.pull(branch_from, overwrite, rev_id)
614
note('%d revision(s) pulled.' % (count,))
614
result = branch_to.pull(branch_from, overwrite, rev_id)
616
result.report(self.outf)
618
from bzrlib.log import show_changed_revisions
617
619
new_rh = branch_to.revision_history()
620
from bzrlib.log import show_changed_revisions
621
show_changed_revisions(branch_to, old_rh, new_rh,
620
show_changed_revisions(branch_to, old_rh, new_rh, to_file=self.outf)
625
623
class cmd_push(Command):
760
756
dir_to = br_from.bzrdir.clone(location_url,
761
757
revision_id=br_from.last_revision())
762
758
br_to = dir_to.open_branch()
763
count = br_to.last_revision_info()[0]
759
# TODO: Some more useful message about what was copied
760
note('Created new branch.')
764
761
# We successfully created the target, remember it
765
762
if br_from.get_push_location() is None or remember:
766
763
br_from.set_push_location(br_to.base)
779
776
repository_to.fetch(br_from.repository,
780
777
revision_id=last_revision_id)
781
778
br_to = br_from.clone(dir_to, revision_id=last_revision_id)
782
count = len(br_to.revision_history())
779
note('Created new branch.')
783
780
if br_from.get_push_location() is None or remember:
784
781
br_from.set_push_location(br_to.base)
785
782
else: # We have a valid to branch
794
791
except errors.NotLocalUrl:
795
792
warning('This transport does not update the working '
796
793
'tree of: %s' % (br_to.base,))
797
count = br_from.push(br_to, overwrite)
794
push_result = br_from.push(br_to, overwrite)
798
795
except errors.NoWorkingTree:
799
count = br_from.push(br_to, overwrite)
796
push_result = br_from.push(br_to, overwrite)
801
798
tree_to.lock_write()
803
count = br_from.push(tree_to.branch, overwrite)
800
push_result = br_from.push(tree_to.branch, overwrite)
807
804
except errors.DivergedBranches:
808
805
raise errors.BzrCommandError('These branches have diverged.'
809
806
' Try using "merge" and then "push".')
810
note('%d revision(s) pushed.' % (count,))
807
if push_result is not None:
808
push_result.report(self.outf)
813
810
new_rh = br_to.revision_history()
814
811
if old_rh != new_rh:
815
812
# Something changed
816
813
from bzrlib.log import show_changed_revisions
817
814
show_changed_revisions(br_to, old_rh, new_rh,
818
815
to_file=self.outf)
817
# we probably did a clone rather than a push, so a message was
821
822
class cmd_branch(Command):
1253
1256
existing_bzrdir = bzrdir.BzrDir.open(location)
1254
1257
except errors.NotBranchError:
1255
1258
# really a NotBzrDir error...
1256
branch = bzrdir.BzrDir.create_branch_convenience(location,
1259
branch = bzrdir.BzrDir.create_branch_convenience(to_transport.base,
1259
1262
from bzrlib.transport.local import LocalTransport
1967
tree, relpath = WorkingTree.open_containing(filename)
1969
except (errors.NotBranchError, errors.NotLocalUrl):
1970
tree, b, relpath = \
1971
bzrdir.BzrDir.open_containing_tree_or_branch(filename)
1972
except errors.NotBranchError:
1972
1975
if revision is not None and revision[0].get_branch() is not None:
1973
1976
b = Branch.open(revision[0].get_branch())
1974
1977
if tree is None:
1975
b, relpath = Branch.open_containing(filename)
1976
1978
tree = b.basis_tree()
1977
1979
if revision is None:
1978
1980
revision_id = b.last_revision()
2455
2457
' source rather than merging. When this happens,'
2456
2458
' you do not need to commit the result.'),
2457
2459
Option('directory',
2458
help='branch to merge into, '
2460
help='Branch to merge into, '
2459
2461
'rather than the one containing the working directory',
2460
2462
short_name='d',
3197
3206
t = get_transport(url)
3199
3208
server = smart.SmartServerPipeStreamMedium(sys.stdin, sys.stdout, t)
3200
elif port is not None:
3202
host, port = port.split(':')
3211
port = smart.BZR_DEFAULT_PORT
3204
3212
host = '127.0.0.1'
3205
server = smart.SmartTCPServer(t, host=host, port=int(port))
3215
host, port = port.split(':')
3219
server = smart.SmartTCPServer(t, host=host, port=port)
3206
3220
print 'listening on port: ', server.port
3207
3221
sys.stdout.flush()
3209
raise errors.BzrCommandError("bzr serve requires one of --inet or --port")
3225
class cmd_tag(Command):
3226
"""Create a tag naming a revision.
3228
Tags give human-meaningful names to revisions. Commands that take a -r
3229
(--revision) option can be given -rtag:X, where X is any previously
3232
Tags are stored in the branch. Tags are copied from one branch to another
3233
along when you branch, push, pull or merge.
3235
It is an error to give a tag name that already exists unless you pass
3236
--force, in which case the tag is moved to point to the new revision.
3239
takes_args = ['tag_name']
3242
help='Delete this tag rather than placing it.',
3245
help='Branch in which to place the tag.',
3250
help='Replace existing tags',
3255
def run(self, tag_name,
3261
branch, relpath = Branch.open_containing(directory)
3265
branch.tags.delete_tag(tag_name)
3266
self.outf.write('Deleted tag %s.\n' % tag_name)
3269
if len(revision) != 1:
3270
raise errors.BzrCommandError(
3271
"Tags can only be placed on a single revision, "
3273
revision_id = revision[0].in_history(branch).rev_id
3275
revision_id = branch.last_revision()
3276
if (not force) and branch.tags.has_tag(tag_name):
3277
raise errors.TagAlreadyExists(tag_name)
3278
branch.tags.set_tag(tag_name, revision_id)
3279
self.outf.write('Created tag %s.\n' % tag_name)
3284
class cmd_tags(Command):
3287
This tag shows a table of tag names and the revisions they reference.
3292
help='Branch whose tags should be displayed',
3302
branch, relpath = Branch.open_containing(directory)
3303
for tag_name, target in sorted(branch.tags.get_tag_dict().items()):
3304
self.outf.write('%-20s %s\n' % (tag_name, target))
3213
3307
# command-line interpretation helper for merge-related commands
3214
3308
def _merge_helper(other_revision, base_revision,
3215
3309
check_clean=True, ignore_zero=False,
3283
3377
if file_list is None:
3284
3378
if pull and merger.base_rev_id == merger.this_rev_id:
3285
count = merger.this_tree.pull(merger.this_branch,
3379
# FIXME: deduplicate with pull
3380
result = merger.this_tree.pull(merger.this_branch,
3286
3381
False, merger.other_rev_id)
3287
note('%d revision(s) pulled.' % (count,))
3382
if result.old_revid == result.new_revid:
3383
note('No revisions to pull.')
3385
note('Now on revision %d.' % result.new_revno)
3289
3387
merger.backup_files = backup_files
3290
3388
merger.merge_type = merge_type