534
534
if len(names_list) < 2:
535
535
raise errors.BzrCommandError("missing file argument")
536
536
tree, rel_names = tree_files(names_list)
539
self._run(tree, names_list, rel_names, after)
538
dest = names_list[-1]
539
isdir = os.path.isdir(dest)
540
if (isdir and not tree.case_sensitive and len(rel_names) == 2
541
and rel_names[0].lower() == rel_names[1].lower()):
543
def _run(self, tree, names_list, rel_names, after):
544
into_existing = osutils.isdir(names_list[-1])
545
if into_existing and len(names_list) == 2:
547
# a. case-insensitive filesystem and change case of dir
548
# b. move directory after the fact (if the source used to be
549
# a directory, but now doesn't exist in the working tree
550
# and the target is an existing directory, just rename it)
551
if (not tree.case_sensitive
552
and rel_names[0].lower() == rel_names[1].lower()):
553
into_existing = False
556
from_id = tree.path2id(rel_names[0])
557
if (not osutils.lexists(names_list[0]) and
558
from_id and inv.get_file_kind(from_id) == "directory"):
559
into_existing = False
544
562
# move into existing directory
545
563
for pair in tree.move(rel_names[:-1], rel_names[-1], after=after):
546
564
self.outf.write("%s => %s\n" % pair)
571
589
that, you can omit the location to use the default. To change the
572
590
default, use --remember. The value will only be saved if the remote
573
591
location can be accessed.
593
Note: The location can be specified either in the form of a branch,
594
or in the form of a path to a file containing a merge directive generated
576
598
_see_also = ['push', 'update', 'status-flags']
605
627
possible_transports = []
606
628
if location is not None:
607
mergeable, location_transport = _get_mergeable_helper(location)
608
possible_transports.append(location_transport)
630
mergeable = bundle.read_mergeable_from_url(location,
631
possible_transports=possible_transports)
632
except errors.NotABundle:
610
635
stored_loc = branch_to.get_parent()
611
636
if location is None:
618
643
if not is_quiet():
619
644
self.outf.write("Using saved location: %s\n" % display_url)
620
645
location = stored_loc
621
location_transport = transport.get_transport(
622
location, possible_transports=possible_transports)
624
647
if mergeable is not None:
625
648
if revision is not None:
630
653
mergeable.get_merge_request(branch_to.repository)
631
654
branch_from = branch_to
633
branch_from = Branch.open_from_transport(location_transport)
656
branch_from = Branch.open(location,
657
possible_transports=possible_transports)
635
659
if branch_to.get_parent() is None or remember:
636
660
branch_to.set_parent(branch_from.base)
2648
2672
print ' %s (%s python%s)' % (
2649
2673
bzrlib.__path__[0],
2650
2674
bzrlib.version_string,
2651
'.'.join(map(str, sys.version_info)),
2675
bzrlib._format_version_tuple(sys.version_info),
2654
2678
if testspecs_list is not None:
2743
2767
class cmd_merge(Command):
2744
2768
"""Perform a three-way merge.
2746
The branch is the branch you will merge from. By default, it will merge
2747
the latest revision. If you specify a revision, that revision will be
2748
merged. If you specify two revisions, the first will be used as a BASE,
2749
and the second one as OTHER. Revision numbers are always relative to the
2770
The source of the merge can be specified either in the form of a branch,
2771
or in the form of a path to a file containing a merge directive generated
2772
with bzr send. If neither is specified, the default is the upstream branch
2773
or the branch most recently merged using --remember.
2775
When merging a branch, by default the tip will be merged. To pick a different
2776
revision, pass --revision. If you specify two values, the first will be used as
2777
BASE and the second one as OTHER. Merging individual revisions, or a subset of
2778
available revisions, like this is commonly referred to as "cherrypicking".
2780
Revision numbers are always relative to the branch being merged.
2752
2782
By default, bzr will try to merge in all new work from the other
2753
2783
branch, automatically determining an appropriate base. If this
2784
2814
To merge the changes introduced by 82, without previous changes::
2786
2816
bzr merge -r 81..82 ../bzr.dev
2818
To apply a merge directive contained in in /tmp/merge:
2820
bzr merge /tmp/merge
2789
2823
encoding_type = 'exact'
2790
2824
_see_also = ['update', 'remerge', 'status-flags']
2791
takes_args = ['branch?']
2825
takes_args = ['location?']
2792
2826
takes_options = [
2814
2848
Option('preview', help='Instead of merging, show a diff of the merge.')
2817
def run(self, branch=None, revision=None, force=False, merge_type=None,
2818
show_base=False, reprocess=False, remember=False,
2851
def run(self, location=None, revision=None, force=False,
2852
merge_type=None, show_base=False, reprocess=False, remember=False,
2819
2853
uncommitted=False, pull=False,
2820
2854
directory=None,
2823
# This is actually a branch (or merge-directive) *location*.
2827
2857
if merge_type is None:
2828
2858
merge_type = _mod_merge.Merge3Merger
2842
2872
tree.lock_write()
2843
2873
cleanups.append(tree.unlock)
2844
2874
if location is not None:
2845
mergeable, other_transport = _get_mergeable_helper(location)
2876
mergeable = bundle.read_mergeable_from_url(location,
2877
possible_transports=possible_transports)
2878
except errors.NotABundle:
2847
2881
if uncommitted:
2848
2882
raise errors.BzrCommandError('Cannot use --uncommitted'
2849
2883
' with bundles or merge directives.')
2853
2887
'Cannot use -r with merge directives or bundles')
2854
2888
merger, verified = _mod_merge.Merger.from_mergeable(tree,
2856
possible_transports.append(other_transport)
2858
2891
if merger is None and uncommitted:
2859
2892
if revision is not None and len(revision) > 0:
3639
3672
_see_also = ['commit']
3640
3673
takes_options = ['verbose', 'revision',
3641
3674
Option('dry-run', help='Don\'t actually make changes.'),
3642
Option('force', help='Say yes to all questions.')]
3675
Option('force', help='Say yes to all questions.'),
3677
help="Only remove the commits from the local branch"
3678
" when in a checkout."
3643
3681
takes_args = ['location?']
3645
3683
encoding_type = 'replace'
3647
3685
def run(self, location=None,
3648
3686
dry_run=False, verbose=False,
3649
revision=None, force=False):
3687
revision=None, force=False, local=False):
3650
3688
if location is None:
3651
3689
location = u'.'
3652
3690
control, relpath = bzrdir.BzrDir.open_containing(location)
3665
return self._run(b, tree, dry_run, verbose, revision, force)
3703
return self._run(b, tree, dry_run, verbose, revision, force,
3667
3706
if tree is not None:
3672
def _run(self, b, tree, dry_run, verbose, revision, force):
3711
def _run(self, b, tree, dry_run, verbose, revision, force, local=False):
3673
3712
from bzrlib.log import log_formatter, show_log
3674
3713
from bzrlib.uncommit import uncommit
3719
3758
uncommit(b, tree=tree, dry_run=dry_run, verbose=verbose,
3759
revno=revno, local=local)
3723
3762
class cmd_break_lock(Command):
4049
4088
older formats. It is compatible with Bazaar 0.19 and later. It is the
4050
4089
default. "0.9" uses revision bundle format 0.9 and merge directive
4051
4090
format 1. It is compatible with Bazaar 0.12 - 0.18.
4092
Merge directives are applied using the merge command or the pull command.
4054
4095
encoding_type = 'exact'
4056
_see_also = ['merge']
4097
_see_also = ['merge', 'pull']
4058
4099
takes_args = ['submit_branch?', 'public_branch?']
4496
4537
cur_transport.ensure_base()
4499
def _get_mergeable_helper(location):
4500
"""Get a merge directive or bundle if 'location' points to one.
4502
Try try to identify a bundle and returns its mergeable form. If it's not,
4503
we return the tried transport anyway so that it can reused to access the
4506
:param location: can point to a bundle or a branch.
4508
:return: mergeable, transport
4511
url = urlutils.normalize_url(location)
4512
url, filename = urlutils.split(url, exclude_trailing_slash=False)
4513
location_transport = transport.get_transport(url)
4516
# There may be redirections but we ignore the intermediate
4517
# and final transports used
4518
read = bundle.read_mergeable_from_transport
4519
mergeable, t = read(location_transport, filename)
4520
except errors.NotABundle:
4521
# Continue on considering this url a Branch but adjust the
4522
# location_transport
4523
location_transport = location_transport.clone(filename)
4524
return mergeable, location_transport
4527
4540
# these get imported and then picked up by the scan for cmd_*
4528
4541
# TODO: Some more consistent way to split command definitions across files;
4529
4542
# we do need to load at least some information about them to know of