1
1
# Loom, a plugin for bzr to assist in developing focused patches.
2
# Copyright (C) 2006 Canonical Limited.
2
# Copyright (C) 2006, 2008 Canonical Limited.
4
4
# This program is free software; you can redistribute it and/or modify
5
5
# it under the terms of the GNU General Public License version 2 as published
525
526
self.assertEqual('', out)
526
527
self.assertEqual('bzr: ERROR: Cannot combine threads on the bottom thread.\n', err)
528
def test_combine_last_two_threads(self):
529
"""Doing a combine on two threads gives you just the bottom one."""
529
def get_two_thread_loom(self):
530
530
tree = self.get_vendor_loom()
531
531
tree.branch.new_thread('above-vendor')
532
LoomTreeDecorator(tree).up_thread()
532
loom_tree = LoomTreeDecorator(tree)
533
loom_tree.up_thread()
533
534
self.build_tree(['file-a'])
534
535
tree.add('file-a')
535
tree.commit('change the tree')
536
tree.commit('change the tree', rev_id='above-vendor-1')
537
loom_tree.down_thread()
538
return tree, loom_tree
540
def test_combine_last_two_threads(self):
541
"""Doing a combine on two threads gives you just the bottom one."""
542
tree, loom_tree = self.get_two_thread_loom()
536
543
# now we have a change between the threads, so merge this into the lower
537
544
# thread to simulate real-world - different rev ids, and the lower
538
545
# thread has merged the upper.
539
LoomTreeDecorator(tree).down_thread()
540
546
# ugh, should make merge easier to use.
541
547
self.run_bzr(['merge', '-r', 'thread:above-vendor', '.'])
542
548
vendor_revid = tree.commit('merge in the above-vendor work.')
543
LoomTreeDecorator(tree).up_thread()
549
loom_tree.up_thread()
544
550
out, err = self.run_bzr(['combine-thread'])
545
551
self.assertEqual('', out)
546
552
self.assertEqual(
551
557
self.assertEqual(vendor_revid, tree.last_revision())
552
558
self.assertEqual('vendor', tree.branch.nick)
560
def test_combine_lowest_thread(self):
561
"""Doing a combine on two threads gives you just the bottom one."""
562
tree, loom_tree = self.get_two_thread_loom()
563
self.run_bzr('combine-thread')
564
tree = workingtree.WorkingTree.open('.')
565
self.assertEqual('above-vendor', tree.branch.nick)
566
self.assertEqual('above-vendor-1', tree.last_revision())
554
568
def test_combine_thread_on_non_loomed_branch(self):
555
569
"""We should raise a user-friendly exception if the branch isn't loomed yet."""
556
570
self.assert_exception_raised_on_non_loom_branch(['combine-thread'])