~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testbranch.py

  • Committer: Robert Collins
  • Date: 2005-10-18 06:42:17 UTC
  • mfrom: (0.2.1)
  • mto: This revision was merged to the branch mainline in revision 1463.
  • Revision ID: robertc@robertcollins.net-20051018064217-e810bd94c74a9ad1
Factor out the guts of 'pull' from the command into WorkingTree.pull().
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
        tree = b2.revision_tree('revision-1')
63
63
        eq(tree.get_file_text('foo-id'), 'hello')
64
64
 
65
 
    def test_push_stores(self):
66
 
        """Copy the stores from one branch to another"""
 
65
    def get_unbalanced_branch_pair(self):
 
66
        """Return two branches, a and b, with one file in a."""
67
67
        os.mkdir('a')
68
68
        br_a = Branch.initialize("a")
69
69
        file('a/b', 'wb').write('b')
70
70
        br_a.add('b')
71
 
        commit(br_a, "silly commit")
72
 
 
 
71
        commit(br_a, "silly commit", rev_id='A')
73
72
        os.mkdir('b')
74
73
        br_b = Branch.initialize("b")
 
74
        return br_a, br_b
 
75
 
 
76
    def get_balanced_branch_pair(self):
 
77
        """Returns br_a, br_b as with one commit in a, and b has a's stores."""
 
78
        br_a, br_b = self.get_unbalanced_branch_pair()
 
79
        br_a.push_stores(br_b)
 
80
        return br_a, br_b
 
81
 
 
82
    def test_push_stores(self):
 
83
        """Copy the stores from one branch to another"""
 
84
        br_a, br_b = self.get_unbalanced_branch_pair()
 
85
        # ensure the revision is missing.
75
86
        self.assertRaises(NoSuchRevision, br_b.get_revision, 
76
87
                          br_a.revision_history()[0])
77
88
        br_a.push_stores(br_b)
 
89
        # check that b now has all the data from a's first commit.
78
90
        rev = br_b.get_revision(br_a.revision_history()[0])
79
91
        tree = br_b.revision_tree(br_a.revision_history()[0])
80
92
        for file_id in tree:
84
96
 
85
97
    def test_copy_branch(self):
86
98
        """Copy the stores from one branch to another"""
87
 
        br_a, br_b = self.test_push_stores()
 
99
        br_a, br_b = self.get_balanced_branch_pair()
88
100
        commit(br_b, "silly commit")
89
101
        os.mkdir('c')
90
102
        br_c = copy_branch(br_a, 'c', basis_branch=br_b)