Rev 117: ``bzr combine-thread`` now accepts a ``--force`` option. in http://bazaar.launchpad.net/~bzr-loom-devs/bzr-loom/trunk/

Robert Collins robertc at robertcollins.net
Tue Jun 29 07:06:28 BST 2010


At http://bazaar.launchpad.net/~bzr-loom-devs/bzr-loom/trunk/

------------------------------------------------------------
revno: 117
revision-id: robertc at robertcollins.net-20100629060616-ysrhik7k0ejk6kk0
parent: robertc at robertcollins.net-20100623084254-fcd8yagffxhdz8z4
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Tue 2010-06-29 16:06:16 +1000
message:
  ``bzr combine-thread`` now accepts a ``--force`` option.
=== modified file 'NEWS'
--- a/NEWS	2010-06-18 04:44:52 +0000
+++ b/NEWS	2010-06-29 06:06:16 +0000
@@ -21,6 +21,8 @@
 * --auto is now the default on up-thread. You can supply a thread name to stop
   at a given thread, or --manual to go up a single thread. (Aaron Bentley)
 
+* ``bzr combine-thread`` now accepts a ``--force`` option.
+
 FEATURES
 --------
 

=== modified file 'commands.py'
--- a/commands.py	2010-06-18 04:44:52 +0000
+++ b/commands.py	2010-06-29 06:06:16 +0000
@@ -72,7 +72,7 @@
 
 
 class cmd_combine_thread(bzrlib.commands.Command):
-    """Combine the current thread with the thread below it.
+    __doc__ = """Combine the current thread with the thread below it.
     
     This will currently refuse to operate on the last thread, but in the future
     will just turn the loom into a normal branch again.
@@ -84,14 +84,20 @@
      * Change threads to the thread below.
     """
 
-    def run(self):
+    takes_options = [
+        Option('force', help='Combine even if work in the thread is not '
+            'integrated up or down the loom.'),
+        ]
+
+    def run(self, force=False):
         (tree, path) = workingtree.WorkingTree.open_containing('.')
         branch.require_loom_branch(tree.branch)
         tree.lock_write()
         try:
             current_thread = tree.branch.nick
             state = tree.branch.get_loom_state()
-            threads = state.get_threads()
+            # XXX: Layering issue whom should be caring for the check, not the
+            # command thats for sure.
             new_thread = state.get_new_thread_after_deleting(current_thread)
             if new_thread is None:
                 raise branch.CannotCombineOnLastThread

=== modified file 'tests/blackbox.py'
--- a/tests/blackbox.py	2010-06-16 03:37:23 +0000
+++ b/tests/blackbox.py	2010-06-29 06:06:16 +0000
@@ -710,6 +710,43 @@
         loom_tree.down_thread()
         return tree, loom_tree
 
+    def get_loom_with_unique_thread(self):
+        """Return a loom with a unique thread.
+
+        That is:
+        vendor:[]
+        unique-thread:[vendor]
+        above-vendor:[vendor]
+
+        - unique-thread has work not in vendor and not in above-vendor.
+
+        The returned loom is on the vendor thread.
+        """
+        tree, _ = self.get_two_thread_loom()
+        tree.branch.new_thread('unique-thread', 'vendor')
+        loom_tree = LoomTreeDecorator(tree)
+        loom_tree.up_thread()
+        self.build_tree(['file-b'])
+        tree.add('file-b')
+        tree.commit('a unique change', rev_id='uniquely-yrs-1')
+        loom_tree.down_thread()
+        return tree, loom_tree
+
+    def test_combine_unmerged_thread_force(self):
+        """Combining a thread with unique work works with --force."""
+        tree, loom_tree = self.get_loom_with_unique_thread()
+        vendor_revid = tree.last_revision()
+        loom_tree.up_thread()
+        out, err = self.run_bzr(['combine-thread', '--force'])
+        self.assertEqual('', out)
+        self.assertEqual(
+            "Combining thread 'unique-thread' into 'vendor'\n"
+            'All changes applied successfully.\n'
+            "Moved to thread 'vendor'.\n",
+            err)
+        self.assertEqual(vendor_revid, tree.last_revision())
+        self.assertEqual('vendor', tree.branch.nick)
+
     def test_combine_last_two_threads(self):
         """Doing a combine on two threads gives you just the bottom one."""
         tree, loom_tree = self.get_two_thread_loom()




More information about the bazaar-commits mailing list