/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_fetch.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-11-16 18:33:33 UTC
  • mfrom: (2138.1.1 robuster.external.diff)
  • Revision ID: pqm@pqm.ubuntu.com-20061116183333-5f56523d7b44e564
(Dmitry Vasiliev) Robuster external diff output handling.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 by Canonical Ltd
2
 
 
 
1
# Copyright (C) 2005 Canonical Ltd
 
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
 
 
7
#
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
 
 
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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
 
226
264
        self.log("web server logs are:")
227
265
        http_logs = self.get_readonly_server().logs
228
266
        self.log('\n'.join(http_logs))
229
 
        self.assertEqual(1, self._count_log_matches('weaves/ce/id.weave', http_logs))
230
 
        self.assertEqual(1, self._count_log_matches('inventory.weave', http_logs))
 
267
        # unfortunately this log entry is branch format specific. We could 
 
268
        # factor out the 'what files does this format use' to a method on the 
 
269
        # repository, which would let us to this generically. RBC 20060419
 
270
        self.assertEqual(1, self._count_log_matches('/ce/id.kndx', http_logs))
 
271
        self.assertEqual(1, self._count_log_matches('/ce/id.knit', http_logs))
 
272
        self.assertEqual(1, self._count_log_matches('inventory.kndx', http_logs))
231
273
        # this r-h check test will prevent regressions, but it currently already 
232
274
        # passes, before the patch to cache-rh is applied :[
233
275
        self.assertEqual(1, self._count_log_matches('revision-history', http_logs))
240
282
        http_logs = self.get_readonly_server().logs
241
283
        self.log("web server logs are:")
242
284
        self.log('\n'.join(http_logs))
243
 
        self.assertEqual(1, self._count_log_matches('branch-format', http_logs[0:1]))
244
 
        self.assertEqual(1, self._count_log_matches('revision-history', http_logs[1:2]))
245
 
        self.assertEqual(2, len(http_logs))
 
285
        self.assertEqual(1, self._count_log_matches('branch-format', http_logs))
 
286
        self.assertEqual(1, self._count_log_matches('branch/format', http_logs))
 
287
        self.assertEqual(1, self._count_log_matches('repository/format', http_logs))
 
288
        self.assertEqual(1, self._count_log_matches('revision-history', http_logs))
 
289
        self.assertEqual(4, len(http_logs))