[MERGE REVIEW] merge takes --uncommitted

John Arbash Meinel john at arbash-meinel.com
Wed Aug 9 17:48:11 BST 2006


Aaron Bentley wrote:
> Martin Pool wrote:
>>> I think it'd be good to bring in, though perhaps we can unify it with
>>> something else.  Perhaps 'merge --uncommitted'?  Obviously it doesn't
>>> generate a merge record but in other ways it might be similar?
> 
> That's easy as pie.  Bundle attached.
> 
> Aaron


=== modified file bzrlib/branch.py //
last-changed:aaron.bentley at utoronto.ca-20
... 060807182308-040b514b9af55e13
--- bzrlib/branch.py
+++ bzrlib/branch.py
@@ -43,6 +43,7 @@
                                       zero_eight, zero_nine,
                                       )
 from bzrlib.trace import mutter, note
+from bzrlib import transport

^- this should be put next to the other 'from bzrlib import foo', along
with a cleanup so the final version is:

from bzrlib import (
    bzrdir,
    errors,
    lockdir,
    osutils,
    revision,
    transport,
    tree,
    ui,
    urlutils,
    )


v-- Why is this part of your patch. Did you just forget it hadn't been
merged yet?

+    def create_checkout_convenience(self, to_location,
...


v-- I assume this is where the real changes are
@@ -2123,7 +2113,9 @@
     takes_args = ['branch?']
     takes_options = ['revision', 'force', 'merge-type', 'reprocess',
'remember',
                      Option('show-base', help="Show base revision text in "
-                            "conflicts")]
+                            "conflicts"),
+                     Option('uncommitted', help='Apply uncommitted changes'
+                            ' from a working copy, instead of branch
changes')]

     def help(self):
         from merge import merge_type_help
@@ -2131,7 +2123,8 @@
         return getdoc(self) + '\n' + merge_type_help()

     def run(self, branch=None, revision=None, force=False, merge_type=None,
-            show_base=False, reprocess=False, remember=False):
+            show_base=False, reprocess=False, remember=False,
+            uncommitted=False):
         if merge_type is None:
             merge_type = Merge3Merger

@@ -2153,10 +2146,17 @@
         branch = self._get_remembered_parent(tree, branch, 'Merging from')

         if revision is None or len(revision) < 1:
-            base = [None, None]
-            other = [branch, -1]
+            if uncommitted:
+                base = [branch, -1]
+                other = [branch, None]
+            else:
+                base = [None, None]
+                other = [branch, -1]
             other_branch, path = Branch.open_containing(branch)
         else:
+            if uncommitted:
+                raise BzrCommandError('Cannot use --uncommitted and
--revision'
+                                      ' at the same time.')
             if len(revision) == 1:
                 base = [None, None]
                 other_branch, path = Branch.open_containing(branch)

=== modified file bzrlib/merge.py
--- bzrlib/merge.py
+++ bzrlib/merge.py
@@ -50,11 +50,13 @@
 # TODO: Report back as changes are merged in

 def _get_tree(treespec, local_branch=None):
+    from bzrlib import workingtree
     location, revno = treespec
+    if revno is None:
+        tree = workingtree.WorkingTree.open_containing(location)[0]
+        return tree.branch, tree
     branch = Branch.open_containing(location)[0]
-    if revno is None:
-        revision = None
-    elif revno == -1:
+    if revno == -1:
         revision = branch.last_revision()
     else:
         revision = branch.get_rev_id(revno)

...

So ignoring the 'create_checkout_convenience' stuff, it looks okay.

I'm curious though, whether 'bzr merge --uncommitted ../foo' should do a
regular merge, and just pick the tip as the working tree.
Or whether it should just cherrypick the uncommitted changes. I probably
agree with your decision to just cherrypick, because otherwise you end
up mixing what was in history with what was uncommitted.

So the --uncommitted stuff has my +1. The 'create_checkout_convenience'
is a separate discussion.

John
=:->

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060809/90ef461e/attachment.pgp 


More information about the bazaar mailing list