[MERGE REVIEW] Added option --remember to merge command
Olaf Conradi
olaf at conradi.org
Sun Mar 19 23:12:14 GMT 2006
Hello,
I redid my patch a bit after Michael's comments.
Please have a look.
If it's OK then I'll do a commit to my branch so it's mergable to
bzr.dev mainline.
On 19/03/06, Michael Ellerman <michael at ellerman.id.au> wrote:
> On 3/18/06, Olaf Conradi <oohlaf at gmail.com> wrote:
> > I just copied this from cmd_pull, which mentions this as first paragraph.
>
> Ok, in that case we should fix cmd_pull also. That's not the first
> thing a user needs to know about pull when they read the help.
I will do this in a separate commit when remember option patch has two
+1 reviews.
This is the new patch:
I changed the name of argument branch to location for consistency with
pull and push.
=== modified file 'a/bzrlib/builtins.py'
--- a/bzrlib/builtins.py
+++ b/bzrlib/builtins.py
@@ -1780,7 +1780,7 @@
class cmd_merge(Command):
"""Perform a three-way merge.
- The branch is the branch you will merge from. By default, it will
+ The location is the branch you will merge from. By default, it will
merge the latest revision. If you specify a revision, that
revision will be merged. If you specify two revisions, the first
will be used as a BASE, and the second one as OTHER. Revision
@@ -1797,6 +1797,10 @@
Use bzr resolve when you have fixed a problem. See also bzr conflicts.
+ If there is no default location set, the first merge will set it. After
+ that, you can omit the location to use the default. To change the
+ default, use --remember.
+
Examples:
To merge the latest revision from bzr.dev
@@ -1811,39 +1815,44 @@
merge refuses to run if there are any uncommitted changes, unless
--force is given.
"""
- takes_args = ['branch?']
- takes_options = ['revision', 'force', 'merge-type', 'reprocess',
+ takes_args = ['location?']
+ takes_options = ['revision', 'force', 'merge-type', 'reprocess',
'remember',
Option('show-base', help="Show base revision text in "
"conflicts")]
- def run(self, branch=None, revision=None, force=False, merge_type=None,
- show_base=False, reprocess=False):
+ def run(self, location=None, revision=None, force=False, merge_type=None,
+ show_base=False, reprocess=False, remember=False):
if merge_type is None:
merge_type = Merge3Merger
- if branch is None:
- branch = WorkingTree.open_containing(u'.')[0].branch.get_parent()
- if branch is None:
+
+ tree = WorkingTree.open_containing(u'.')[0]
+ stored_loc = tree.branch.get_parent()
+ if location is None:
+ if stored_loc is None:
raise BzrCommandError("No merge location known or specified.")
else:
- print "Using saved location: %s" % branch
+ print "Using saved location: %s" % stored_loc
+ location = stored_loc
+
if revision is None or len(revision) < 1:
base = [None, None]
- other = [branch, -1]
+ other = [location, -1]
else:
if len(revision) == 1:
base = [None, None]
- other_branch = Branch.open_containing(branch)[0]
+ other_branch = Branch.open_containing(location)[0]
revno = revision[0].in_history(other_branch).revno
- other = [branch, revno]
+ other = [location, revno]
else:
assert len(revision) == 2
if None in revision:
raise BzrCommandError(
"Merge doesn't permit that revision specifier.")
- b = Branch.open_containing(branch)[0]
-
- base = [branch, revision[0].in_history(b).revno]
- other = [branch, revision[1].in_history(b).revno]
+ other_branch = Branch.open_containing(location)[0]
+
+ base = [location, revision[0].in_history(other_branch).revno]
+ other = [location, revision[1].in_history(other_branch).revno]
+
pb = bzrlib.ui.ui_factory.nested_progress_bar()
try:
try:
@@ -1854,6 +1863,10 @@
pb=pb)
finally:
pb.finished()
+
+ if tree.branch.get_parent() is None or remember:
+ tree.branch.set_parent(location)
+
if conflict_count != 0:
return 1
else:
Cheers
-Olaf
More information about the bazaar
mailing list