~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_fetch.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-10-31 17:30:33 UTC
  • mfrom: (1551.8.43 Aaron's mergeable stuff)
  • Revision ID: pqm@pqm.ubuntu.com-20061031173033-95e11019fbb103f3
Additional fetch test case

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import os
18
18
import sys
19
19
 
 
20
from bzrlib import bzrdir, repository
20
21
from bzrlib.branch import Branch
21
22
from bzrlib.bzrdir import BzrDir
22
23
from bzrlib.builtins import merge
25
26
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
26
27
from bzrlib.tests.test_revision import make_branches
27
28
from bzrlib.trace import mutter
 
29
from bzrlib.upgrade import Convert
28
30
from bzrlib.workingtree import WorkingTree
29
31
 
30
32
 
113
115
        wt = self.make_branch_and_tree('br')
114
116
        self.assertEqual(wt.branch.fetch(wt.branch), (0, []))
115
117
 
 
118
    def test_fetch_root_knit(self):
 
119
        """Ensure that knit2.fetch() updates the root knit
 
120
        
 
121
        This tests the case where the root has a new revision, but there are no
 
122
        corresponding filename, parent, contents or other changes.
 
123
        """
 
124
        knit1_format = bzrdir.BzrDirMetaFormat1()
 
125
        knit1_format.repository_format = repository.RepositoryFormatKnit1()
 
126
        knit2_format = bzrdir.BzrDirMetaFormat1()
 
127
        knit2_format.repository_format = repository.RepositoryFormatKnit2()
 
128
        # we start with a knit1 repository because that causes the
 
129
        # root revision to change for each commit, even though the content,
 
130
        # parent, name, and other attributes are unchanged.
 
131
        tree = self.make_branch_and_tree('tree', knit1_format)
 
132
        tree.set_root_id('tree-root')
 
133
        tree.commit('rev1', rev_id='rev1')
 
134
        tree.commit('rev2', rev_id='rev2')
 
135
 
 
136
        # Now we convert it to a knit2 repository so that it has a root knit
 
137
        Convert(tree.basedir, knit2_format)
 
138
        tree = WorkingTree.open(tree.basedir)
 
139
        branch = self.make_branch('branch', format=knit2_format)
 
140
        branch.pull(tree.branch, stop_revision='rev1')
 
141
        repo = branch.repository
 
142
        root_knit = repo.weave_store.get_weave('tree-root',
 
143
                                                repo.get_transaction())
 
144
        # Make sure fetch retrieved only what we requested
 
145
        self.assertTrue('rev1' in root_knit)
 
146
        self.assertTrue('rev2' not in root_knit)
 
147
        branch.pull(tree.branch)
 
148
        root_knit = repo.weave_store.get_weave('tree-root',
 
149
                                                repo.get_transaction())
 
150
        # Make sure that the next revision in the root knit was retrieved,
 
151
        # even though the text, name, parent_id, etc., were unchanged.
 
152
        self.assertTrue('rev2' in root_knit)
 
153
 
116
154
 
117
155
class TestMergeFetch(TestCaseWithTransport):
118
156