Rev 99: Support switch -b in http://bazaar.launchpad.net/~bzr-loom-devs/bzr-loom/trunk/

Robert Collins robertc at robertcollins.net
Tue Sep 22 04:40:58 BST 2009


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

------------------------------------------------------------
revno: 99
revision-id: robertc at robertcollins.net-20090922034053-zck3a0r9vufh552p
parent: robertc at robertcollins.net-20090921055406-rhd5dex5wlzfapef
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Tue 2009-09-22 13:40:53 +1000
message:
  Support switch -b
=== modified file 'NEWS'
--- a/NEWS	2009-06-18 06:28:18 +0000
+++ b/NEWS	2009-09-22 03:40:53 +0000
@@ -21,6 +21,8 @@
     * ``bzr switch`` now accepts ``top:`` and ``bottom:`` to jump to the top
       and bottom thread respectively. (Jonathan Lange)
 
+    * ``bzr switch -b newthread`` now works. (Robert Collins, #433811)
+
     * ``bzr push`` now pushes the last-loom rather than creating an empty loom.
       (Robert Collins, #201613)
 

=== modified file 'branch.py'
--- a/branch.py	2009-09-21 05:54:06 +0000
+++ b/branch.py	2009-09-22 03:40:53 +0000
@@ -45,6 +45,17 @@
 EMPTY_REVISION = 'empty:'
 
 
+def create_thread(loom, thread_name):
+    """Create a thread in the branch loom called thread."""
+    require_loom_branch(loom)
+    loom.lock_write()
+    try:
+        loom.new_thread(thread_name, loom.nick)
+        loom.nick = thread_name
+    finally:
+        loom.unlock()
+
+
 def loomify(branch):
     """Convert branch to a loom.
 

=== modified file 'commands.py'
--- a/commands.py	2009-01-15 16:56:26 +0000
+++ b/commands.py	2009-09-22 03:40:53 +0000
@@ -112,13 +112,7 @@
 
     def run(self, thread):
         (loom, path) = bzrlib.branch.Branch.open_containing('.')
-        branch.require_loom_branch(loom)
-        loom.lock_write()
-        try:
-            loom.new_thread(thread, loom.nick)
-            loom.nick = thread
-        finally:
-            loom.unlock()
+        branch.create_thread(loom, thread)
 
 
 class cmd_show_loom(bzrlib.commands.Command):
@@ -208,8 +202,10 @@
             return thread[0]
         return to_location
 
-    def run(self, to_location, force=False):
+    def run(self, to_location, force=False, create_branch=False):
         (tree, path) = workingtree.WorkingTree.open_containing('.')
+        if create_branch:
+            return branch.create_thread(tree.branch, to_location)
         tree = LoomTreeDecorator(tree)
         try:
             thread_name = self._get_thread_name(tree.branch, to_location)

=== modified file 'tests/blackbox.py'
--- a/tests/blackbox.py	2009-06-18 06:28:18 +0000
+++ b/tests/blackbox.py	2009-09-22 03:40:53 +0000
@@ -266,6 +266,17 @@
             "All changes applied successfully.\nMoved to thread 'thread2'.\n",
             err)
 
+    def test_switch_dash_b(self):
+        # 'bzr switch -b new-thread' makes and switches to a new thread.
+        tree = self.get_vendor_loom()
+        self._add_patch(tree, 'thread2')
+        LoomTreeDecorator(tree).down_thread('vendor')
+        self.assertEqual(tree.branch.nick, 'vendor')
+        out, err = self.run_bzr(['switch', '-b', 'thread1'], retcode=0)
+        self.assertEqual(tree.branch.nick, 'thread1')
+        self.assertEqual('', out)
+        self.assertEqual('', err)
+
 
 class TestRecord(TestsWithLooms):
 

=== modified file 'tests/test_branch.py'
--- a/tests/test_branch.py	2008-10-16 16:24:41 +0000
+++ b/tests/test_branch.py	2009-09-22 03:40:53 +0000
@@ -132,6 +132,7 @@
             bzrlib.plugins.loom.branch.LoomBranch7,
             bzrlib.plugins.loom.branch.BzrBranchLoomFormat7)
 
+
 class TestLoom(TestCaseWithLoom):
 
     def make_loom(self, path):




More information about the bazaar-commits mailing list