~jml/bzr-loom/switch-aliases

« back to all changes in this revision

Viewing changes to tests/test_branch.py

  • Committer: Aaron Bentley
  • Date: 2008-03-20 06:18:03 UTC
  • mfrom: (76.1.10 loom)
  • Revision ID: aaron@aaronbentley.com-20080320061803-j5h98tmjefhivkpk
Add export-loom command

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
 
22
22
import bzrlib
 
23
from bzrlib.branch import Branch
23
24
import bzrlib.errors as errors
24
25
from bzrlib.plugins.loom.branch import (
25
26
    EMPTY_REVISION,
517
518
        tree.branch.nick = 'foo'
518
519
        tree.branch.record_loom('foo')
519
520
        self.assertEqual([], tree.branch.get_threads(NULL_REVISION))
 
521
 
 
522
    def get_multi_threaded(self):
 
523
        tree = self.get_tree_with_loom()
 
524
        tree.branch.new_thread('thread1')
 
525
        tree.branch.nick = 'thread1'
 
526
        tree.commit('thread1', rev_id='thread1-id')
 
527
        tree.branch.new_thread('thread2', 'thread1')
 
528
        tree.branch.nick = 'thread2'
 
529
        tree.commit('thread2', rev_id='thread2-id')
 
530
        return tree
 
531
 
 
532
    def test_export_loom_initial(self):
 
533
        tree = self.get_multi_threaded()
 
534
        root_transport = tree.branch.bzrdir.root_transport
 
535
        tree.branch.export_threads(root_transport)
 
536
        thread1 = Branch.open_from_transport(root_transport.clone('thread1'))
 
537
        self.assertEqual('thread1-id', thread1.last_revision())
 
538
        thread2 = Branch.open_from_transport(root_transport.clone('thread2'))
 
539
        self.assertEqual('thread2-id', thread2.last_revision())
 
540
 
 
541
    def test_export_loom_update(self):
 
542
        tree = self.get_multi_threaded()
 
543
        root_transport = tree.branch.bzrdir.root_transport
 
544
        tree.branch.export_threads(root_transport)
 
545
        tree.commit('thread2-2', rev_id='thread2-2-id')
 
546
        tree.branch.export_threads(root_transport)
 
547
        thread1 = Branch.open_from_transport(root_transport.clone('thread1'))
 
548
        self.assertEqual('thread1-id', thread1.last_revision())
 
549
        thread2 = Branch.open_from_transport(root_transport.clone('thread2'))
 
550
        self.assertEqual('thread2-2-id', thread2.last_revision())
 
551
 
 
552
    def test_export_loom_root_transport(self):
 
553
        tree = self.get_multi_threaded()
 
554
        tree.branch.bzrdir.root_transport.mkdir('root')
 
555
        root_transport = tree.branch.bzrdir.root_transport.clone('root')
 
556
        tree.branch.export_threads(root_transport)
 
557
        thread1 = Branch.open_from_transport(root_transport.clone('thread1'))
 
558
        thread1 = Branch.open_from_transport(root_transport.clone('thread1'))
 
559
        self.assertEqual('thread1-id', thread1.last_revision())
 
560
        thread2 = Branch.open_from_transport(root_transport.clone('thread2'))
 
561
        self.assertEqual('thread2-id', thread2.last_revision())