~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testbranch.py

  • Committer: Robert Collins
  • Date: 2005-09-30 02:54:51 UTC
  • mfrom: (1395)
  • mto: This revision was merged to the branch mainline in revision 1397.
  • Revision ID: robertc@robertcollins.net-20050930025451-47b9e412202be44b
symlink and weaves, whaddya know

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
import os
18
 
from bzrlib.selftest import TestCaseInTempDir
19
 
from bzrlib.branch import Branch, copy_stores, copy_branch
 
18
from bzrlib.branch import Branch, copy_branch
20
19
from bzrlib.commit import commit
21
20
from bzrlib.errors import NoSuchRevision, UnlistableBranch
 
21
from bzrlib.selftest import TestCaseInTempDir
 
22
from bzrlib.trace import mutter
22
23
 
23
24
class TestBranch(TestCaseInTempDir):
24
25
 
30
31
        br.append_revision("rev2", "rev3")
31
32
        self.assertEquals(br.revision_history(), ["rev1", "rev2", "rev3"])
32
33
 
33
 
    def test_copy_stores(self):
 
34
 
 
35
class TestFetch(TestCaseInTempDir):
 
36
 
 
37
    def test_fetch_revisions(self):
 
38
        """Test fetch-revision operation."""
 
39
        from bzrlib.fetch import Fetcher
 
40
        os.mkdir('b1')
 
41
        os.mkdir('b2')
 
42
        b1 = Branch.initialize('b1')
 
43
        b2 = Branch.initialize('b2')
 
44
        file(os.sep.join(['b1', 'foo']), 'w').write('hello')
 
45
        b1.add(['foo'], ['foo-id'])
 
46
        b1.commit('lala!', rev_id='revision-1', allow_pointless=False)
 
47
 
 
48
        mutter('start fetch')
 
49
        f = Fetcher(from_branch=b1, to_branch=b2)
 
50
        eq = self.assertEquals
 
51
        eq(f.count_copied, 1)
 
52
        eq(f.last_revision, 'revision-1')
 
53
 
 
54
        rev = b2.get_revision('revision-1')
 
55
        tree = b2.revision_tree('revision-1')
 
56
        eq(tree.get_file_text('foo-id'), 'hello')
 
57
 
 
58
    def test_push_stores(self):
34
59
        """Copy the stores from one branch to another"""
35
60
        os.mkdir('a')
36
61
        br_a = Branch.initialize("a")
42
67
        br_b = Branch.initialize("b")
43
68
        self.assertRaises(NoSuchRevision, br_b.get_revision, 
44
69
                          br_a.revision_history()[0])
45
 
        copy_stores(br_a, br_b)
 
70
        br_a.push_stores(br_b)
46
71
        rev = br_b.get_revision(br_a.revision_history()[0])
47
72
        tree = br_b.revision_tree(br_a.revision_history()[0])
48
73
        for file_id in tree:
52
77
 
53
78
    def test_copy_branch(self):
54
79
        """Copy the stores from one branch to another"""
55
 
        br_a, br_b = self.test_copy_stores()
 
80
        br_a, br_b = self.test_push_stores()
56
81
        commit(br_b, "silly commit")
57
82
        os.mkdir('c')
58
83
        br_c = copy_branch(br_a, 'c', basis_branch=br_b)
59
84
        self.assertEqual(br_a.revision_history(), br_c.revision_history())
60
 
        assert br_b.last_patch() not in br_c.revision_history()
61
 
        br_c.get_revision(br_b.last_patch())
 
85
        assert br_b.last_revision() not in br_c.revision_history()
 
86
        br_c.get_revision(br_b.last_revision())
62
87
# TODO: rewrite this as a regular unittest, without relying on the displayed output        
63
88
#         >>> from bzrlib.commit import commit
64
89
#         >>> bzrlib.trace.silent = True