552
552
def run(self, location=None, remember=False, overwrite=False,
553
553
revision=None, verbose=False,
555
from bzrlib.tag import _merge_tags_if_possible
555
556
# FIXME: too much stuff is in the command class
556
557
if directory is None:
601
602
old_rh = branch_to.revision_history()
602
603
if tree_to is not None:
603
count = tree_to.pull(branch_from, overwrite, rev_id,
604
result = tree_to.pull(branch_from, overwrite, rev_id,
604
605
delta.ChangeReporter(tree_to.inventory))
606
count = branch_to.pull(branch_from, overwrite, rev_id)
607
note('%d revision(s) pulled.' % (count,))
607
result = branch_to.pull(branch_from, overwrite, rev_id)
609
result.report(self.outf)
611
from bzrlib.log import show_changed_revisions
610
612
new_rh = branch_to.revision_history()
613
from bzrlib.log import show_changed_revisions
614
show_changed_revisions(branch_to, old_rh, new_rh,
613
show_changed_revisions(branch_to, old_rh, new_rh, to_file=self.outf)
618
616
class cmd_push(Command):
753
749
dir_to = br_from.bzrdir.clone(location_url,
754
750
revision_id=br_from.last_revision())
755
751
br_to = dir_to.open_branch()
756
count = br_to.last_revision_info()[0]
752
# TODO: Some more useful message about what was copied
753
note('Created new branch.')
757
754
# We successfully created the target, remember it
758
755
if br_from.get_push_location() is None or remember:
759
756
br_from.set_push_location(br_to.base)
772
769
repository_to.fetch(br_from.repository,
773
770
revision_id=last_revision_id)
774
771
br_to = br_from.clone(dir_to, revision_id=last_revision_id)
775
count = len(br_to.revision_history())
772
note('Created new branch.')
776
773
if br_from.get_push_location() is None or remember:
777
774
br_from.set_push_location(br_to.base)
778
775
else: # We have a valid to branch
787
784
except errors.NotLocalUrl:
788
785
warning('This transport does not update the working '
789
786
'tree of: %s' % (br_to.base,))
790
count = br_from.push(br_to, overwrite)
787
push_result = br_from.push(br_to, overwrite)
791
788
except errors.NoWorkingTree:
792
count = br_from.push(br_to, overwrite)
789
push_result = br_from.push(br_to, overwrite)
794
791
tree_to.lock_write()
796
count = br_from.push(tree_to.branch, overwrite)
793
push_result = br_from.push(tree_to.branch, overwrite)
800
797
except errors.DivergedBranches:
801
798
raise errors.BzrCommandError('These branches have diverged.'
802
799
' Try using "merge" and then "push".')
803
note('%d revision(s) pushed.' % (count,))
800
if push_result is not None:
801
push_result.report(self.outf)
806
803
new_rh = br_to.revision_history()
807
804
if old_rh != new_rh:
808
805
# Something changed
809
806
from bzrlib.log import show_changed_revisions
810
807
show_changed_revisions(br_to, old_rh, new_rh,
811
808
to_file=self.outf)
810
# we probably did a clone rather than a push, so a message was
814
815
class cmd_branch(Command):
829
830
aliases = ['get', 'clone']
831
832
def run(self, from_location, to_location=None, revision=None, basis=None):
833
from bzrlib.tag import _merge_tags_if_possible
832
834
if revision is None:
833
835
revision = [None]
834
836
elif len(revision) > 1:
879
881
raise errors.BzrCommandError(msg)
881
883
branch.control_files.put_utf8('branch-name', name)
884
_merge_tags_if_possible(br_from, branch)
882
885
note('Branched %d revision(s).' % branch.revno())
1236
1239
existing_bzrdir = bzrdir.BzrDir.open(location)
1237
1240
except errors.NotBranchError:
1238
1241
# really a NotBzrDir error...
1239
branch = bzrdir.BzrDir.create_branch_convenience(location,
1242
branch = bzrdir.BzrDir.create_branch_convenience(to_transport.base,
1242
1245
from bzrlib.transport.local import LocalTransport
1931
tree, relpath = WorkingTree.open_containing(filename)
1933
except (errors.NotBranchError, errors.NotLocalUrl):
1934
tree, b, relpath = \
1935
bzrdir.BzrDir.open_containing_tree_or_branch(filename)
1936
except errors.NotBranchError:
1936
1939
if revision is not None and revision[0].get_branch() is not None:
1937
1940
b = Branch.open(revision[0].get_branch())
1938
1941
if tree is None:
1939
b, relpath = Branch.open_containing(filename)
1940
1942
tree = b.basis_tree()
1941
1943
if revision is None:
1942
1944
revision_id = b.last_revision()
2419
2421
' source rather than merging. When this happens,'
2420
2422
' you do not need to commit the result.'),
2421
2423
Option('directory',
2422
help='branch to merge into, '
2424
help='Branch to merge into, '
2423
2425
'rather than the one containing the working directory',
2424
2426
short_name='d',
2491
2494
if tree.branch.get_parent() is None or remember:
2492
2495
tree.branch.set_parent(other_branch.base)
2497
# pull tags now... it's a bit inconsistent to do it ahead of copying
2498
# the history but that's done inside the merge code
2499
_merge_tags_if_possible(other_branch, tree.branch)
2495
2502
interesting_files = [path]
3132
3139
help='listen for connections on nominated port of the form '
3133
3140
'[hostname:]portnumber. Passing 0 as the port number will '
3134
'result in a dynamically allocated port.',
3141
'result in a dynamically allocated port. Default port is '
3136
3144
Option('directory',
3137
3145
help='serve contents of directory',
3154
3162
t = get_transport(url)
3156
3164
server = smart.SmartServerPipeStreamMedium(sys.stdin, sys.stdout, t)
3157
elif port is not None:
3159
host, port = port.split(':')
3167
port = smart.BZR_DEFAULT_PORT
3161
3168
host = '127.0.0.1'
3162
server = smart.SmartTCPServer(t, host=host, port=int(port))
3171
host, port = port.split(':')
3175
server = smart.SmartTCPServer(t, host=host, port=port)
3163
3176
print 'listening on port: ', server.port
3164
3177
sys.stdout.flush()
3166
raise errors.BzrCommandError("bzr serve requires one of --inet or --port")
3229
3240
self.outf.writelines(directive.to_lines())
3243
class cmd_tag(Command):
3244
"""Create a tag naming a revision.
3246
Tags give human-meaningful names to revisions. Commands that take a -r
3247
(--revision) option can be given -rtag:X, where X is any previously
3250
Tags are stored in the branch. Tags are copied from one branch to another
3251
along when you branch, push, pull or merge.
3253
It is an error to give a tag name that already exists unless you pass
3254
--force, in which case the tag is moved to point to the new revision.
3257
takes_args = ['tag_name']
3260
help='Delete this tag rather than placing it.',
3263
help='Branch in which to place the tag.',
3268
help='Replace existing tags',
3273
def run(self, tag_name,
3279
branch, relpath = Branch.open_containing(directory)
3283
branch.tags.delete_tag(tag_name)
3284
self.outf.write('Deleted tag %s.\n' % tag_name)
3287
if len(revision) != 1:
3288
raise errors.BzrCommandError(
3289
"Tags can only be placed on a single revision, "
3291
revision_id = revision[0].in_history(branch).rev_id
3293
revision_id = branch.last_revision()
3294
if (not force) and branch.tags.has_tag(tag_name):
3295
raise errors.TagAlreadyExists(tag_name)
3296
branch.tags.set_tag(tag_name, revision_id)
3297
self.outf.write('Created tag %s.\n' % tag_name)
3302
class cmd_tags(Command):
3305
This tag shows a table of tag names and the revisions they reference.
3310
help='Branch whose tags should be displayed',
3320
branch, relpath = Branch.open_containing(directory)
3321
for tag_name, target in sorted(branch.tags.get_tag_dict().items()):
3322
self.outf.write('%-20s %s\n' % (tag_name, target))
3232
3325
# command-line interpretation helper for merge-related commands
3233
3326
def _merge_helper(other_revision, base_revision,
3234
3327
check_clean=True, ignore_zero=False,
3294
3387
if file_list is None:
3295
3388
if pull and merger.base_rev_id == merger.this_rev_id:
3296
count = merger.this_tree.pull(merger.this_branch,
3389
# FIXME: deduplicate with pull
3390
result = merger.this_tree.pull(merger.this_branch,
3297
3391
False, merger.other_rev_id)
3298
note('%d revision(s) pulled.' % (count,))
3392
if result.old_revid == result.new_revid:
3393
note('No revisions to pull.')
3395
note('Now on revision %d.' % result.new_revno)
3300
3397
merger.backup_files = backup_files
3301
3398
merger.merge_type = merge_type