549
549
def run(self, location=None, remember=False, overwrite=False,
550
550
revision=None, verbose=False,
552
from bzrlib.tag import _merge_tags_if_possible
552
553
# FIXME: too much stuff is in the command class
553
554
if directory is None:
598
599
old_rh = branch_to.revision_history()
599
600
if tree_to is not None:
600
count = tree_to.pull(branch_from, overwrite, rev_id,
601
result = tree_to.pull(branch_from, overwrite, rev_id,
601
602
delta.ChangeReporter(tree_to.inventory))
603
count = branch_to.pull(branch_from, overwrite, rev_id)
604
note('%d revision(s) pulled.' % (count,))
604
result = branch_to.pull(branch_from, overwrite, rev_id)
606
result.report(self.outf)
608
from bzrlib.log import show_changed_revisions
607
609
new_rh = branch_to.revision_history()
610
from bzrlib.log import show_changed_revisions
611
show_changed_revisions(branch_to, old_rh, new_rh,
610
show_changed_revisions(branch_to, old_rh, new_rh, to_file=self.outf)
615
613
class cmd_push(Command):
702
697
# Found a branch, so we must have found a repository
703
698
repository_to = br_to.repository
706
701
if dir_to is None:
702
# The destination doesn't exist; create it.
707
703
# XXX: Refactor the create_prefix/no_create_prefix code into a
708
704
# common helper function
750
746
dir_to = br_from.bzrdir.clone(location_url,
751
747
revision_id=br_from.last_revision())
752
748
br_to = dir_to.open_branch()
753
count = br_to.last_revision_info()[0]
749
# TODO: Some more useful message about what was copied
750
note('Created new branch.')
754
751
# We successfully created the target, remember it
755
752
if br_from.get_push_location() is None or remember:
756
753
br_from.set_push_location(br_to.base)
769
766
repository_to.fetch(br_from.repository,
770
767
revision_id=last_revision_id)
771
768
br_to = br_from.clone(dir_to, revision_id=last_revision_id)
772
count = len(br_to.revision_history())
769
note('Created new branch.')
773
770
if br_from.get_push_location() is None or remember:
774
771
br_from.set_push_location(br_to.base)
775
772
else: # We have a valid to branch
784
781
except errors.NotLocalUrl:
785
782
warning('This transport does not update the working '
786
783
'tree of: %s' % (br_to.base,))
787
count = br_from.push(br_to, overwrite)
784
push_result = br_from.push(br_to, overwrite)
788
785
except errors.NoWorkingTree:
789
count = br_from.push(br_to, overwrite)
786
push_result = br_from.push(br_to, overwrite)
791
788
tree_to.lock_write()
793
count = br_from.push(tree_to.branch, overwrite)
790
push_result = br_from.push(tree_to.branch, overwrite)
797
794
except errors.DivergedBranches:
798
795
raise errors.BzrCommandError('These branches have diverged.'
799
796
' Try using "merge" and then "push".')
800
note('%d revision(s) pushed.' % (count,))
797
if push_result is not None:
798
push_result.report(self.outf)
803
800
new_rh = br_to.revision_history()
804
801
if old_rh != new_rh:
805
802
# Something changed
806
803
from bzrlib.log import show_changed_revisions
807
804
show_changed_revisions(br_to, old_rh, new_rh,
808
805
to_file=self.outf)
807
# we probably did a clone rather than a push, so a message was
811
812
class cmd_branch(Command):
826
827
aliases = ['get', 'clone']
828
829
def run(self, from_location, to_location=None, revision=None, basis=None):
830
from bzrlib.tag import _merge_tags_if_possible
829
831
if revision is None:
830
832
revision = [None]
831
833
elif len(revision) > 1:
876
878
raise errors.BzrCommandError(msg)
878
880
branch.control_files.put_utf8('branch-name', name)
881
_merge_tags_if_possible(br_from, branch)
879
882
note('Branched %d revision(s).' % branch.revno())
2416
2419
' source rather than merging. When this happens,'
2417
2420
' you do not need to commit the result.'),
2418
2421
Option('directory',
2419
help='branch to merge into, '
2422
help='Branch to merge into, '
2420
2423
'rather than the one containing the working directory',
2421
2424
short_name='d',
2488
2492
if tree.branch.get_parent() is None or remember:
2489
2493
tree.branch.set_parent(other_branch.base)
2495
# pull tags now... it's a bit inconsistent to do it ahead of copying
2496
# the history but that's done inside the merge code
2497
_merge_tags_if_possible(other_branch, tree.branch)
2492
2500
interesting_files = [path]
3179
class cmd_tag(Command):
3180
"""Create a tag naming a revision.
3182
Tags give human-meaningful names to revisions. Commands that take a -r
3183
(--revision) option can be given -rtag:X, where X is any previously
3186
Tags are stored in the branch. Tags are copied from one branch to another
3187
along when you branch, push, pull or merge.
3189
It is an error to give a tag name that already exists unless you pass
3190
--force, in which case the tag is moved to point to the new revision.
3193
takes_args = ['tag_name']
3196
help='Delete this tag rather than placing it.',
3199
help='Branch in which to place the tag.',
3204
help='Replace existing tags',
3209
def run(self, tag_name,
3215
branch, relpath = Branch.open_containing(directory)
3219
branch.tags.delete_tag(tag_name)
3220
self.outf.write('Deleted tag %s.\n' % tag_name)
3223
if len(revision) != 1:
3224
raise errors.BzrCommandError(
3225
"Tags can only be placed on a single revision, "
3227
revision_id = revision[0].in_history(branch).rev_id
3229
revision_id = branch.last_revision()
3230
if (not force) and branch.tags.has_tag(tag_name):
3231
raise errors.TagAlreadyExists(tag_name)
3232
branch.tags.set_tag(tag_name, revision_id)
3233
self.outf.write('Created tag %s.\n' % tag_name)
3238
class cmd_tags(Command):
3241
This tag shows a table of tag names and the revisions they reference.
3246
help='Branch whose tags should be displayed',
3256
branch, relpath = Branch.open_containing(directory)
3257
for tag_name, target in sorted(branch.tags.get_tag_dict().items()):
3258
self.outf.write('%-20s %s\n' % (tag_name, target))
3171
3261
# command-line interpretation helper for merge-related commands
3172
3262
def _merge_helper(other_revision, base_revision,
3173
3263
check_clean=True, ignore_zero=False,
3233
3323
if file_list is None:
3234
3324
if pull and merger.base_rev_id == merger.this_rev_id:
3235
count = merger.this_tree.pull(merger.this_branch,
3325
# FIXME: deduplicate with pull
3326
result = merger.this_tree.pull(merger.this_branch,
3236
3327
False, merger.other_rev_id)
3237
note('%d revision(s) pulled.' % (count,))
3328
if result.old_revid == result.new_revid:
3329
note('No revisions to pull.')
3331
note('Now on revision %d.' % result.new_revno)
3239
3333
merger.backup_files = backup_files
3240
3334
merger.merge_type = merge_type