/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
2052.3.1 by John Arbash Meinel
Add tests to cleanup the copyright of all source files
1
# Copyright (C) 2005, 2006 Canonical Ltd
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
2
#
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
7
#
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
12
#
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
17
"""Tests for InterRepository implementastions."""
18
1711.7.18 by John Arbash Meinel
Old repository formats didn't support double locking on win32, don't raise errors
19
import sys
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
20
1534.1.31 by Robert Collins
Deprecated fetch.fetch and fetch.greedy_fetch for branch.fetch, and move the Repository.fetch internals to InterRepo and InterWeaveRepo.
21
import bzrlib
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
22
import bzrlib.bzrdir as bzrdir
23
from bzrlib.branch import Branch, needs_read_lock, needs_write_lock
24
import bzrlib.errors as errors
25
from bzrlib.errors import (FileExists,
26
                           NoSuchRevision,
27
                           NoSuchFile,
28
                           UninitializableFormat,
29
                           NotBranchError,
30
                           )
1731.1.1 by Aaron Bentley
Make root entry an InventoryDirectory, make EmptyTree really empty
31
from bzrlib.inventory import Inventory
2321.2.3 by Alexander Belchenko
fix for check_repo_format_for_funky_id_on_win32 after Martin's refactoring of repository format
32
import bzrlib.repofmt.weaverepo as weaverepo
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
33
import bzrlib.repository as repository
1694.2.6 by Martin Pool
[merge] bzr.dev
34
from bzrlib.revision import NULL_REVISION, Revision
2814.1.1 by Robert Collins
* Pushing, pulling and branching branches with subtree references was not
35
from bzrlib.tests import (
36
    TestCase,
37
    TestCaseWithTransport,
38
    TestNotApplicable,
39
    TestSkipped,
40
    )
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
41
from bzrlib.tests.bzrdir_implementations.test_bzrdir import TestCaseWithBzrDir
42
from bzrlib.transport import get_transport
43
44
45
class TestCaseWithInterRepository(TestCaseWithBzrDir):
46
47
    def setUp(self):
48
        super(TestCaseWithInterRepository, self).setUp()
49
1666.1.4 by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in
50
    def make_branch(self, relpath, format=None):
51
        repo = self.make_repository(relpath, format=format)
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
52
        return repo.bzrdir.create_branch()
53
1666.1.4 by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in
54
    def make_bzrdir(self, relpath, format=None):
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
55
        try:
56
            url = self.get_url(relpath)
57
            segments = url.split('/')
58
            if segments and segments[-1] not in ('', '.'):
59
                parent = '/'.join(segments[:-1])
60
                t = get_transport(parent)
61
                try:
62
                    t.mkdir(segments[-1])
63
                except FileExists:
64
                    pass
1666.1.4 by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in
65
            if format is None:
66
                format = self.repository_format._matchingbzrdir
67
            return format.initialize(url)
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
68
        except UninitializableFormat:
1684.1.4 by Martin Pool
(patch) better warnings when tests are skipped (Alexander)
69
            raise TestSkipped("Format %s is not initializable." % format)
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
70
1666.1.4 by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in
71
    def make_repository(self, relpath, format=None):
72
        made_control = self.make_bzrdir(relpath, format=format)
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
73
        return self.repository_format.initialize(made_control)
74
75
    def make_to_repository(self, relpath):
76
        made_control = self.make_bzrdir(relpath,
77
            self.repository_format_to._matchingbzrdir)
1534.1.30 by Robert Collins
Test that we get the right optimiser back in the InterRepository tests.
78
        return self.repository_format_to.initialize(made_control)
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
79
80
1711.7.18 by John Arbash Meinel
Old repository formats didn't support double locking on win32, don't raise errors
81
def check_old_format_lock_error(repository_format):
82
    """Potentially ignore LockError on old formats.
83
84
    On win32, with the old OS locks, we get a failure of double-lock when
85
    we open a object in 2 objects and try to lock both.
86
87
    On new formats, LockError would be invalid, but for old formats
88
    this was not supported on Win32.
89
    """
90
    if sys.platform != 'win32':
91
        raise
92
93
    description = repository_format.get_format_description()
94
    if description in ("Repository format 4",
95
                       "Weave repository format 5",
96
                       "Weave repository format 6"):
1711.7.30 by John Arbash Meinel
Switch to using TestSkipped for old win32 problems
97
        # jam 20060701
98
        # win32 OS locks are not re-entrant. So one process cannot
99
        # open the same repository twice and lock them both.
100
        raise TestSkipped('%s on win32 cannot open the same'
101
                          ' repository twice in different objects'
102
                          % description)
1711.7.18 by John Arbash Meinel
Old repository formats didn't support double locking on win32, don't raise errors
103
    raise
104
105
2240.1.3 by Alexander Belchenko
win32: skip tests that try to use funky chars in fileid in Weave-based repositories
106
def check_repo_format_for_funky_id_on_win32(repo):
2321.2.3 by Alexander Belchenko
fix for check_repo_format_for_funky_id_on_win32 after Martin's refactoring of repository format
107
    if (isinstance(repo, (weaverepo.AllInOneRepository,
108
                          weaverepo.WeaveMetaDirRepository))
109
        and sys.platform == 'win32'):
2240.1.3 by Alexander Belchenko
win32: skip tests that try to use funky chars in fileid in Weave-based repositories
110
            raise TestSkipped("funky chars does not permitted"
111
                              " on this platform in repository"
112
                              " %s" % repo.__class__.__name__)
113
114
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
115
class TestInterRepository(TestCaseWithInterRepository):
116
1534.1.30 by Robert Collins
Test that we get the right optimiser back in the InterRepository tests.
117
    def test_interrepository_get_returns_correct_optimiser(self):
118
        # we assume the optimising code paths are triggered
119
        # by the type of the repo not the transport - at this point.
120
        # we may need to update this test if this changes.
2241.1.4 by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo.
121
        #
122
        # XXX: This code tests that we get an InterRepository when we try to
123
        # convert between the two repositories that it wants to be tested with
124
        # -- but that's not necessarily correct.  So for now this is disabled.
125
        # mbp 20070206
126
        ## source_repo = self.make_repository("source")
127
        ## target_repo = self.make_to_repository("target")
128
        ## interrepo = repository.InterRepository.get(source_repo, target_repo)
129
        ## self.assertEqual(self.interrepo_class, interrepo.__class__)
130
        pass
1534.1.30 by Robert Collins
Test that we get the right optimiser back in the InterRepository tests.
131
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
132
    def test_fetch(self):
133
        tree_a = self.make_branch_and_tree('a')
134
        self.build_tree(['a/foo'])
135
        tree_a.add('foo', 'file1')
136
        tree_a.commit('rev1', rev_id='rev1')
137
        def check_push_rev1(repo):
138
            # ensure the revision is missing.
139
            self.assertRaises(NoSuchRevision, repo.get_revision, 'rev1')
1534.1.31 by Robert Collins
Deprecated fetch.fetch and fetch.greedy_fetch for branch.fetch, and move the Repository.fetch internals to InterRepo and InterWeaveRepo.
140
            # fetch with a limit of NULL_REVISION and an explicit progress bar.
141
            repo.fetch(tree_a.branch.repository,
142
                       revision_id=NULL_REVISION,
143
                       pb=bzrlib.progress.DummyProgress())
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
144
            # nothing should have been pushed
145
            self.assertFalse(repo.has_revision('rev1'))
146
            # fetch with a default limit (grab everything)
147
            repo.fetch(tree_a.branch.repository)
148
            # check that b now has all the data from a's first commit.
149
            rev = repo.get_revision('rev1')
150
            tree = repo.revision_tree('rev1')
151
            tree.get_file_text('file1')
152
            for file_id in tree:
153
                if tree.inventory[file_id].kind == "file":
154
                    tree.get_file(file_id).read()
155
1534.1.31 by Robert Collins
Deprecated fetch.fetch and fetch.greedy_fetch for branch.fetch, and move the Repository.fetch internals to InterRepo and InterWeaveRepo.
156
        # makes a target version repo 
157
        repo_b = self.make_to_repository('b')
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
158
        check_push_rev1(repo_b)
159
        
160
    def test_fetch_missing_revision_same_location_fails(self):
161
        repo_a = self.make_repository('.')
162
        repo_b = repository.Repository.open('.')
1711.7.18 by John Arbash Meinel
Old repository formats didn't support double locking on win32, don't raise errors
163
        try:
164
            self.assertRaises(errors.NoSuchRevision, repo_b.fetch, repo_a, revision_id='XXX')
165
        except errors.LockError, e:
166
            check_old_format_lock_error(self.repository_format)
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
167
168
    def test_fetch_same_location_trivial_works(self):
169
        repo_a = self.make_repository('.')
170
        repo_b = repository.Repository.open('.')
1711.7.18 by John Arbash Meinel
Old repository formats didn't support double locking on win32, don't raise errors
171
        try:
172
            repo_a.fetch(repo_b)
173
        except errors.LockError, e:
174
            check_old_format_lock_error(self.repository_format)
1534.1.34 by Robert Collins
Move missing_revision_ids from Repository to InterRepository, and eliminate the now unused Repository._compatible_formats method.
175
1694.2.6 by Martin Pool
[merge] bzr.dev
176
    def test_fetch_missing_text_other_location_fails(self):
177
        source_tree = self.make_branch_and_tree('source')
178
        source = source_tree.branch.repository
179
        target = self.make_to_repository('target')
180
    
2881.4.1 by Robert Collins
Move responsibility for detecting same-repo fetching from the
181
        # start by adding a file so the data knit for the file exists in
182
        # repositories that have specific files for each fileid.
1694.2.6 by Martin Pool
[merge] bzr.dev
183
        self.build_tree(['source/id'])
184
        source_tree.add(['id'], ['id'])
185
        source_tree.commit('a', rev_id='a')
186
        # now we manually insert a revision with an inventory referencing
187
        # 'id' at revision 'b', but we do not insert revision b.
188
        # this should ensure that the new versions of files are being checked
189
        # for during pull operations
190
        inv = source.get_inventory('a')
2617.6.2 by Robert Collins
Add abort_write_group and wire write_groups into fetch and commit.
191
        source.lock_write()
192
        source.start_write_group()
1694.2.6 by Martin Pool
[merge] bzr.dev
193
        inv['id'].revision = 'b'
1740.2.6 by Aaron Bentley
Update test for new interface
194
        inv.revision_id = 'b'
1694.2.6 by Martin Pool
[merge] bzr.dev
195
        sha1 = source.add_inventory('b', inv, ['a'])
196
        rev = Revision(timestamp=0,
197
                       timezone=None,
198
                       committer="Foo Bar <foo@example.com>",
199
                       message="Message",
200
                       inventory_sha1=sha1,
201
                       revision_id='b')
202
        rev.parent_ids = ['a']
203
        source.add_revision('b', rev)
2617.6.2 by Robert Collins
Add abort_write_group and wire write_groups into fetch and commit.
204
        source.commit_write_group()
205
        source.unlock()
1694.2.6 by Martin Pool
[merge] bzr.dev
206
        self.assertRaises(errors.RevisionNotPresent, target.fetch, source)
207
        self.assertFalse(target.has_revision('b'))
208
1843.2.1 by Aaron Bentley
Add failing tests for funky ids
209
    def test_fetch_funky_file_id(self):
210
        from_tree = self.make_branch_and_tree('tree')
2240.1.3 by Alexander Belchenko
win32: skip tests that try to use funky chars in fileid in Weave-based repositories
211
        if sys.platform == 'win32':
212
            from_repo = from_tree.branch.repository
213
            check_repo_format_for_funky_id_on_win32(from_repo)
1843.2.1 by Aaron Bentley
Add failing tests for funky ids
214
        self.build_tree(['tree/filename'])
215
        from_tree.add('filename', 'funky-chars<>%&;"\'')
216
        from_tree.commit('commit filename')
217
        to_repo = self.make_to_repository('to')
1908.7.6 by Robert Collins
Deprecate WorkingTree.last_revision.
218
        to_repo.fetch(from_tree.branch.repository, from_tree.get_parent_ids()[0])
1843.2.1 by Aaron Bentley
Add failing tests for funky ids
219
1910.8.1 by Aaron Bentley
Handle inventories with no revision_ids
220
    def test_fetch_no_inventory_revision(self):
221
        """Old inventories lack revision_ids, so simulate this"""
222
        from_tree = self.make_branch_and_tree('tree')
2240.1.3 by Alexander Belchenko
win32: skip tests that try to use funky chars in fileid in Weave-based repositories
223
        if sys.platform == 'win32':
224
            from_repo = from_tree.branch.repository
225
            check_repo_format_for_funky_id_on_win32(from_repo)
1910.8.1 by Aaron Bentley
Handle inventories with no revision_ids
226
        self.build_tree(['tree/filename'])
227
        from_tree.add('filename', 'funky-chars<>%&;"\'')
228
        from_tree.commit('commit filename')
229
        old_deserialise = from_tree.branch.repository.deserialise_inventory
230
        def deserialise(revision_id, text):
231
            inventory = old_deserialise(revision_id, text)
232
            inventory.revision_id = None
233
            return inventory
234
        from_tree.branch.repository.deserialise_inventory = deserialise
235
        to_repo = self.make_to_repository('to')
236
        to_repo.fetch(from_tree.branch.repository, from_tree.last_revision())
237
1534.1.34 by Robert Collins
Move missing_revision_ids from Repository to InterRepository, and eliminate the now unused Repository._compatible_formats method.
238
239
class TestCaseWithComplexRepository(TestCaseWithInterRepository):
240
241
    def setUp(self):
242
        super(TestCaseWithComplexRepository, self).setUp()
243
        tree_a = self.make_branch_and_tree('a')
244
        self.bzrdir = tree_a.branch.bzrdir
245
        # add a corrupt inventory 'orphan'
2818.4.1 by Robert Collins
Various test fixes and tweaks for packs.
246
        tree_a.branch.repository.lock_write()
247
        tree_a.branch.repository.start_write_group()
248
        inv_file = tree_a.branch.repository.get_inventory_weave()
1563.2.10 by Robert Collins
Change weave store to be a versioned store, using WeaveFiles which maintain integrity without needing explicit 'put' operations.
249
        inv_file.add_lines('orphan', [], [])
2818.4.1 by Robert Collins
Various test fixes and tweaks for packs.
250
        tree_a.branch.repository.commit_write_group()
251
        tree_a.branch.repository.unlock()
1534.1.34 by Robert Collins
Move missing_revision_ids from Repository to InterRepository, and eliminate the now unused Repository._compatible_formats method.
252
        # add a real revision 'rev1'
253
        tree_a.commit('rev1', rev_id='rev1', allow_pointless=True)
254
        # add a real revision 'rev2' based on rev1
255
        tree_a.commit('rev2', rev_id='rev2', allow_pointless=True)
1556.1.4 by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same.
256
        # and sign 'rev2'
2818.4.1 by Robert Collins
Various test fixes and tweaks for packs.
257
        tree_a.branch.repository.lock_write()
258
        tree_a.branch.repository.start_write_group()
259
        tree_a.branch.repository.sign_revision('rev2', bzrlib.gpg.LoopbackGPGStrategy(None))
260
        tree_a.branch.repository.commit_write_group()
261
        tree_a.branch.repository.unlock()
1534.1.34 by Robert Collins
Move missing_revision_ids from Repository to InterRepository, and eliminate the now unused Repository._compatible_formats method.
262
263
    def test_missing_revision_ids(self):
264
        # revision ids in repository A but not B are returned, fake ones
265
        # are stripped. (fake meaning no revision object, but an inventory 
2881.4.1 by Robert Collins
Move responsibility for detecting same-repo fetching from the
266
        # as some formats keyed off inventory data in the past.)
1534.1.34 by Robert Collins
Move missing_revision_ids from Repository to InterRepository, and eliminate the now unused Repository._compatible_formats method.
267
        # make a repository to compare against that claims to have rev1
268
        repo_b = self.make_to_repository('rev1_only')
269
        repo_a = self.bzrdir.open_repository()
270
        repo_b.fetch(repo_a, 'rev1')
271
        # check the test will be valid
272
        self.assertFalse(repo_b.has_revision('rev2'))
273
        self.assertEqual(['rev2'],
274
                         repo_b.missing_revision_ids(repo_a))
275
276
    def test_missing_revision_ids_revision_limited(self):
277
        # revision ids in repository A that are not referenced by the
278
        # requested revision are not returned.
279
        # make a repository to compare against that is empty
280
        repo_b = self.make_to_repository('empty')
281
        repo_a = self.bzrdir.open_repository()
282
        self.assertEqual(['rev1'],
283
                         repo_b.missing_revision_ids(repo_a, revision_id='rev1'))
1556.1.4 by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same.
284
        
2818.4.1 by Robert Collins
Various test fixes and tweaks for packs.
285
    def test_fetch_fetches_signatures_too(self):
1556.1.4 by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same.
286
        from_repo = self.bzrdir.open_repository()
1563.2.31 by Robert Collins
Convert Knit repositories to use knits.
287
        from_signature = from_repo.get_signature_text('rev2')
1556.1.4 by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same.
288
        to_repo = self.make_to_repository('target')
289
        to_repo.fetch(from_repo)
1563.2.31 by Robert Collins
Convert Knit repositories to use knits.
290
        to_signature = to_repo.get_signature_text('rev2')
1556.1.4 by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same.
291
        self.assertEqual(from_signature, to_signature)
292
1570.1.14 by Robert Collins
Enforce repository consistency during 'fetch' operations.
293
294
class TestCaseWithGhosts(TestCaseWithInterRepository):
295
296
    def setUp(self):
297
        super(TestCaseWithGhosts, self).setUp()
298
        # we want two repositories at this point
299
        # one with a revision that is a ghost in the other
300
        # repository.
301
302
        # 'ghost' is a ghost in missing_ghost and not in with_ghost_rev
303
        repo = self.make_repository('with_ghost_rev')
2814.1.2 by Robert Collins
Fixup other interrepository tests failing due to the change to test subtrees.
304
        repo.lock_write()
305
        builder = repo.get_commit_builder(None, [], None,
306
            committer="Foo Bar <foo@example.com>",
307
            revision_id='ghost')
308
        ie = bzrlib.inventory.InventoryDirectory('TREE_ROOT', '', None)
2776.4.9 by Robert Collins
Unbreak weaves.
309
        builder.record_entry_contents(ie, [], '', None,
310
            ('directory', None, None, None))
2814.1.2 by Robert Collins
Fixup other interrepository tests failing due to the change to test subtrees.
311
        builder.finish_inventory()
312
        builder.commit("Message")
313
        repo.unlock()
1570.1.14 by Robert Collins
Enforce repository consistency during 'fetch' operations.
314
         
315
        repo = self.make_to_repository('missing_ghost')
1910.2.26 by Aaron Bentley
Fix up some test cases
316
        inv = Inventory(revision_id='with_ghost')
317
        inv.root.revision = 'with_ghost'
2818.4.1 by Robert Collins
Various test fixes and tweaks for packs.
318
        repo.lock_write()
319
        repo.start_write_group()
1907.1.1 by Aaron Bentley
Unshelved all changes except those related to removing RootEntry
320
        sha1 = repo.add_inventory('with_ghost', inv, [])
1570.1.14 by Robert Collins
Enforce repository consistency during 'fetch' operations.
321
        rev = bzrlib.revision.Revision(timestamp=0,
322
                                       timezone=None,
323
                                       committer="Foo Bar <foo@example.com>",
324
                                       message="Message",
325
                                       inventory_sha1=sha1,
326
                                       revision_id='with_ghost')
327
        rev.parent_ids = ['ghost']
328
        repo.add_revision('with_ghost', rev)
2818.4.1 by Robert Collins
Various test fixes and tweaks for packs.
329
        repo.commit_write_group()
330
        repo.unlock()
1570.1.14 by Robert Collins
Enforce repository consistency during 'fetch' operations.
331
332
    def test_fetch_all_fixes_up_ghost(self):
333
        # fetching from a repo with a current ghost unghosts it in referencing
334
        # revisions.
335
        repo = repository.Repository.open('missing_ghost')
336
        rev = repo.get_revision('with_ghost')
337
        from_repo = repository.Repository.open('with_ghost_rev')
338
        repo.fetch(from_repo)
339
        # rev must not be corrupt now
340
        rev = repo.get_revision('with_ghost')
341
        self.assertEqual([None, 'ghost', 'with_ghost'], repo.get_ancestry('with_ghost'))
2814.1.1 by Robert Collins
* Pushing, pulling and branching branches with subtree references was not
342
343
344
class TestFetchDependentData(TestCaseWithInterRepository):
345
346
    def test_reference(self):
347
        from_tree = self.make_branch_and_tree('tree')
348
        to_repo = self.make_to_repository('to')
349
        if (not from_tree.supports_tree_reference() or
350
            not from_tree.branch.repository._format.supports_tree_reference or
351
            not to_repo._format.supports_tree_reference):
352
            raise TestNotApplicable("Need subtree support.")
353
        subtree = self.make_branch_and_tree('tree/subtree')
354
        subtree.commit('subrev 1')
355
        from_tree.add_reference(subtree)
356
        tree_rev = from_tree.commit('foo')
357
        # now from_tree has a last-modified of subtree of the rev id of the
358
        # commit for foo, and a reference revision of the rev id of the commit
359
        # for subrev 1
360
        to_repo.fetch(from_tree.branch.repository, tree_rev)
361
        # to_repo should have a file_graph for from_tree.path2id('subtree') and
362
        # revid tree_rev.
363
        file_vf = to_repo.weave_store.get_weave(
364
            from_tree.path2id('subtree'), to_repo.get_transaction())
365
        self.assertEqual([tree_rev], file_vf.get_ancestry([tree_rev]))