Rev 85: ``bzr switch`` now accepts ``top:`` and ``bottom:`` to jump to the top and bottom thread respectively. (Jonathan Lange) in http://bazaar.launchpad.net/~bzr-loom-devs/bzr-loom/trunk/
Robert Collins
robertc at robertcollins.net
Thu Jul 17 10:36:55 BST 2008
At http://bazaar.launchpad.net/~bzr-loom-devs/bzr-loom/trunk/
------------------------------------------------------------
revno: 85
revision-id: robertc at robertcollins.net-20080717093654-1askxojb6kvuz4zy
parent: robertc at robertcollins.net-20080612023213-aaomermgz6krq61q
parent: jml at canonical.com-20080716085627-8oli2dyinw0y9yd1
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Thu 2008-07-17 19:36:54 +1000
message:
``bzr switch`` now accepts ``top:`` and ``bottom:`` to jump to the top and bottom thread respectively. (Jonathan Lange)
modified:
NEWS news-20080228111444-miryhm4hma987q57-1
commands.py commands.py-20060620084702-jnrwijq76kg45klj-6
tests/blackbox.py blackbox.py-20060620084702-jnrwijq76kg45klj-7
------------------------------------------------------------
revno: 83.1.1
revision-id: jml at canonical.com-20080716085627-8oli2dyinw0y9yd1
parent: jml at canonical.com-20080603234217-gwrcskcx8tue2kqj
committer: Jonathan Lange <jml at canonical.com>
branch nick: switch-aliases
timestamp: Wed 2008-07-16 18:56:27 +1000
message:
Make 'switch top:' and 'switch bottom:' switch to the top and bottom
threads respectively.
modified:
commands.py commands.py-20060620084702-jnrwijq76kg45klj-6
tests/blackbox.py blackbox.py-20060620084702-jnrwijq76kg45klj-7
=== modified file 'NEWS'
--- a/NEWS 2008-04-10 00:38:37 +0000
+++ b/NEWS 2008-07-17 09:36:54 +0000
@@ -15,6 +15,9 @@
IMPROVEMENTS:
+ * ``bzr switch`` now accepts ``top:`` and ``bottom:`` to jump to the top
+ and bottom thread respectively. (Jonathan Lange)
+
* ``bzr push`` now pushes the last-loom rather than creating an empty loom.
(Robert Collins, #201613)
=== modified file 'commands.py'
--- a/commands.py 2008-06-12 02:32:13 +0000
+++ b/commands.py 2008-07-17 09:36:54 +0000
@@ -194,11 +194,26 @@
_original_command = None
+ def _get_thread_name(self, loom, to_location):
+ """Return the name of the thread pointed to by 'to_location'.
+
+ Most of the time this will be the name of the thread, but if
+ 'to_location' is 'bottom:' it will be the name of the bottom thread.
+ If 'to_location' is 'top:', then it'll be the name of the top thread.
+ """
+ aliases = {'bottom:': 0, 'top:': -1}
+ if to_location in aliases:
+ threads = loom.get_loom_state().get_threads()
+ thread = threads[aliases[to_location]]
+ return thread[0]
+ return to_location
+
def run(self, to_location, force=False):
(tree, path) = workingtree.WorkingTree.open_containing('.')
tree = LoomTreeDecorator(tree)
try:
- return tree.down_thread(to_location)
+ thread_name = self._get_thread_name(tree.branch, to_location)
+ return tree.down_thread(thread_name)
except (AttributeError, branch.NoSuchThread):
# When there is no thread its probably an external branch
# that we have been given.
=== modified file 'tests/blackbox.py'
--- a/tests/blackbox.py 2008-06-12 02:32:13 +0000
+++ b/tests/blackbox.py 2008-07-17 09:36:54 +0000
@@ -240,6 +240,31 @@
err)
self.assertEqual([rev_id], tree.get_parent_ids())
+ def test_switch_bottom(self):
+ # 'bzr switch bottom:' switches to the bottom thread.
+ tree = self.get_vendor_loom()
+ self._add_patch(tree, 'thread1')
+ self._add_patch(tree, 'thread2')
+ self.assertEqual(tree.branch.nick, 'thread2')
+ out, err = self.run_bzr(['switch', 'bottom:'], retcode=0)
+ self.assertEqual('', out)
+ self.assertEqual(
+ "All changes applied successfully.\nMoved to thread 'vendor'.\n",
+ err)
+
+ def test_switch_top(self):
+ # 'bzr switch top:' switches to the top thread.
+ tree = self.get_vendor_loom()
+ self._add_patch(tree, 'thread1')
+ self._add_patch(tree, 'thread2')
+ LoomTreeDecorator(tree).down_thread('vendor')
+ self.assertEqual(tree.branch.nick, 'vendor')
+ out, err = self.run_bzr(['switch', 'top:'], retcode=0)
+ self.assertEqual('', out)
+ self.assertEqual(
+ "All changes applied successfully.\nMoved to thread 'thread2'.\n",
+ err)
+
class TestRecord(TestsWithLooms):
More information about the bazaar-commits
mailing list