~bzr-pqm/bzr/bzr.dev

5557.1.7 by John Arbash Meinel
Merge in the bzr.dev 5582
1
# Copyright (C) 2005-2011 Canonical Ltd
1417.1.2 by Robert Collins
add sample test
2
#
1393.1.31 by Martin Pool
- add simple test for upgrade
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.
1417.1.2 by Robert Collins
add sample test
7
#
1393.1.31 by Martin Pool
- add simple test for upgrade
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.
1417.1.2 by Robert Collins
add sample test
12
#
1393.1.31 by Martin Pool
- add simple test for upgrade
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
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1393.1.31 by Martin Pool
- add simple test for upgrade
16
17
"""Tests for upgrade of old trees.
18
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
19
This file contains canned versions of some old trees, which are instantiated
1393.1.31 by Martin Pool
- add simple test for upgrade
20
and then upgraded to the new format."""
21
1534.4.44 by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory.
22
# TODO queue for upgrade:
23
# test the error message when upgrading an unknown BzrDir format.
24
2230.3.29 by Aaron Bentley
Implement conversion to branch 6
25
from bzrlib import (
4360.10.47 by Vincent Ladeuil
Some cleanup.
26
    branch,
2230.3.29 by Aaron Bentley
Implement conversion to branch 6
27
    bzrdir,
28
    repository,
4360.10.47 by Vincent Ladeuil
Some cleanup.
29
    tests,
4360.10.48 by Vincent Ladeuil
And some more cleanup.
30
    upgrade,
2255.12.1 by Robert Collins
Implement upgrade for working trees.
31
    workingtree,
32
    workingtree_4,
2230.3.29 by Aaron Bentley
Implement conversion to branch 6
33
    )
2255.12.1 by Robert Collins
Implement upgrade for working trees.
34
35
4360.10.47 by Vincent Ladeuil
Some cleanup.
36
class TestUpgrade(tests.TestCaseWithTransport):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
37
1393.1.31 by Martin Pool
- add simple test for upgrade
38
    def test_upgrade_simple(self):
1959.3.2 by John Arbash Meinel
Update docstring
39
        """Upgrade simple v0.0.4 format to latest format"""
1393.1.33 by Martin Pool
- add test that upgrade completes successfully
40
        eq = self.assertEquals
1514 by Robert Collins
Unbreak self.build_tree_shape in tests.
41
        self.build_tree_contents(_upgrade1_template)
4360.10.48 by Vincent Ladeuil
And some more cleanup.
42
        upgrade.upgrade(u'.')
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
43
        control = bzrdir.BzrDir.open('.')
44
        b = control.open_branch()
1534.4.8 by Robert Collins
Unfuck upgrade.
45
        # tsk, peeking under the covers.
1666.1.4 by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in
46
        self.failUnless(
47
            isinstance(
48
                control._format,
49
                bzrdir.BzrDirFormat.get_default_format().__class__))
1393.1.33 by Martin Pool
- add test that upgrade completes successfully
50
        rh = b.revision_history()
51
        eq(rh,
52
           ['mbp@sourcefrog.net-20051004035611-176b16534b086b3c',
53
            'mbp@sourcefrog.net-20051004035756-235f2b7dcdddd8dd'])
1534.4.42 by Robert Collins
add working tree to the BzrDir facilities.
54
        rt = b.repository.revision_tree(rh[0])
1393.1.33 by Martin Pool
- add test that upgrade completes successfully
55
        foo_id = 'foo-20051004035605-91e788d1875603ae'
3015.2.18 by Robert Collins
Lock correctness for test_upgrade.py.
56
        rt.lock_read()
57
        try:
58
            eq(rt.get_file_text(foo_id), 'initial contents\n')
59
        finally:
60
            rt.unlock()
1534.4.42 by Robert Collins
add working tree to the BzrDir facilities.
61
        rt = b.repository.revision_tree(rh[1])
3015.2.18 by Robert Collins
Lock correctness for test_upgrade.py.
62
        rt.lock_read()
63
        try:
64
            eq(rt.get_file_text(foo_id), 'new contents\n')
65
        finally:
66
            rt.unlock()
1534.4.14 by Robert Collins
Replace copy_tree with transport logic in upgreade.
67
        # check a backup was made:
5035.4.3 by Parth Malwankar
updated existing upgrade tests to work.
68
        backup_dir = 'backup.bzr.~1~'
4360.10.47 by Vincent Ladeuil
Some cleanup.
69
        t = self.get_transport('.')
5273.1.7 by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through
70
        t.stat(backup_dir)
71
        t.stat(backup_dir + '/README')
72
        t.stat(backup_dir + '/branch-format')
73
        t.stat(backup_dir + '/revision-history')
74
        t.stat(backup_dir + '/merged-patches')
75
        t.stat(backup_dir + '/pending-merged-patches')
76
        t.stat(backup_dir + '/pending-merges')
77
        t.stat(backup_dir + '/branch-name')
78
        t.stat(backup_dir + '/branch-lock')
79
        t.stat(backup_dir + '/inventory')
80
        t.stat(backup_dir + '/stat-cache')
81
        t.stat(backup_dir + '/text-store')
82
        t.stat(backup_dir + '/text-store/foo-20051004035611-1591048e9dc7c2d4.gz')
83
        t.stat(backup_dir + '/text-store/foo-20051004035756-4081373d897c3453.gz')
84
        t.stat(backup_dir + '/inventory-store/')
85
        t.stat(backup_dir + '/inventory-store/mbp@sourcefrog.net-20051004035611-176b16534b086b3c.gz')
86
        t.stat(backup_dir + '/inventory-store/mbp@sourcefrog.net-20051004035756-235f2b7dcdddd8dd.gz')
87
        t.stat(backup_dir + '/revision-store/')
88
        t.stat(backup_dir + '/revision-store/mbp@sourcefrog.net-20051004035611-176b16534b086b3c.gz')
89
        t.stat(backup_dir + '/revision-store/mbp@sourcefrog.net-20051004035756-235f2b7dcdddd8dd.gz')
1393.1.31 by Martin Pool
- add simple test for upgrade
90
1393.1.38 by Martin Pool
- partial test for upgrade of branch with ghosts
91
    def test_upgrade_with_ghosts(self):
92
        """Upgrade v0.0.4 tree containing ghost references.
93
94
        That is, some of the parents of revisions mentioned in the branch
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
95
        aren't present in the branch's storage.
1393.1.38 by Martin Pool
- partial test for upgrade of branch with ghosts
96
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
97
        This shouldn't normally happen in branches created entirely in
1185.67.3 by Aaron Bentley
Tweaked some text
98
        bzr, but can happen in branches imported from baz and arch, or from
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
99
        other systems, where the importer knows about a revision but not
1393.1.38 by Martin Pool
- partial test for upgrade of branch with ghosts
100
        its contents."""
101
        eq = self.assertEquals
1514 by Robert Collins
Unbreak self.build_tree_shape in tests.
102
        self.build_tree_contents(_ghost_template)
4360.10.48 by Vincent Ladeuil
And some more cleanup.
103
        upgrade.upgrade(u'.')
4360.10.47 by Vincent Ladeuil
Some cleanup.
104
        b = branch.Branch.open(u'.')
1393.1.40 by Martin Pool
- add (partially skipped) test for upgrade of uncompressed content
105
        revision_id = b.revision_history()[1]
1185.67.2 by Aaron Bentley
Renamed Branch.storage to Branch.repository
106
        rev = b.repository.get_revision(revision_id)
1393.1.44 by Martin Pool
- upgrade carries across ghost references
107
        eq(len(rev.parent_ids), 2)
108
        eq(rev.parent_ids[1], 'wibble@wobble-2')
1393.1.38 by Martin Pool
- partial test for upgrade of branch with ghosts
109
1405 by Robert Collins
remove some of the upgrade code that was duplicated with inventory_entry, and give all inventory entries a weave
110
    def test_upgrade_makes_dir_weaves(self):
1514 by Robert Collins
Unbreak self.build_tree_shape in tests.
111
        self.build_tree_contents(_upgrade_dir_template)
4360.10.47 by Vincent Ladeuil
Some cleanup.
112
        old_repodir = bzrdir.BzrDir.open_unsupported('.')
1666.1.4 by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in
113
        old_repo_format = old_repodir.open_repository()._format
4360.10.48 by Vincent Ladeuil
And some more cleanup.
114
        upgrade.upgrade('.')
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
115
        # this is the path to the literal file. As format changes
1430 by Robert Collins
touchup the prefixed-store patch
116
        # occur it needs to be updated. FIXME: ask the store for the
117
        # path.
4360.10.47 by Vincent Ladeuil
Some cleanup.
118
        repo = repository.Repository.open('.')
1666.1.4 by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in
119
        # it should have changed the format
120
        self.assertNotEqual(old_repo_format.__class__, repo._format.__class__)
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
121
        # and we should be able to read the names for the file id
1666.1.4 by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in
122
        # 'dir-20051005095101-da1441ea3fa6917a'
3015.2.18 by Robert Collins
Lock correctness for test_upgrade.py.
123
        repo.lock_read()
124
        self.addCleanup(repo.unlock)
3350.6.4 by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores.
125
        text_keys = repo.texts.keys()
126
        dir_keys = [key for key in text_keys if key[0] ==
127
                'dir-20051005095101-da1441ea3fa6917a']
128
        self.assertNotEqual([], dir_keys)
1393.1.38 by Martin Pool
- partial test for upgrade of branch with ghosts
129
1534.5.14 by Robert Collins
Bugfix upgrades to metadir to set the last-revision correctly.
130
    def test_upgrade_to_meta_sets_workingtree_last_revision(self):
131
        self.build_tree_contents(_upgrade_dir_template)
4360.10.48 by Vincent Ladeuil
And some more cleanup.
132
        upgrade.upgrade('.', bzrdir.BzrDirMetaFormat1())
1534.5.14 by Robert Collins
Bugfix upgrades to metadir to set the last-revision correctly.
133
        tree = workingtree.WorkingTree.open('.')
1908.7.6 by Robert Collins
Deprecate WorkingTree.last_revision.
134
        self.assertEqual([tree.branch.revision_history()[-1]],
135
            tree.get_parent_ids())
1534.5.14 by Robert Collins
Bugfix upgrades to metadir to set the last-revision correctly.
136
1959.3.1 by John Arbash Meinel
David Allouche: bzr upgrade should work if there is no working tree
137
    def test_upgrade_v6_to_meta_no_workingtree(self):
138
        # Some format6 branches do not have checkout files. Upgrading
139
        # such a branch to metadir must not setup a working tree.
140
        self.build_tree_contents(_upgrade1_template)
4360.10.48 by Vincent Ladeuil
And some more cleanup.
141
        upgrade.upgrade('.', bzrdir.BzrDirFormat6())
142
        t = self.get_transport('.')
5273.1.7 by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through
143
        t.delete_multi(['.bzr/pending-merges', '.bzr/inventory'])
144
        self.assertFalse(t.has('.bzr/stat-cache'))
3280.1.1 by Ian Clatworthy
(Martin Albisetti) Change backup dir from .bzr.backup to backup.bzr
145
        # XXX: upgrade fails if a backup.bzr is already present
1959.3.1 by John Arbash Meinel
David Allouche: bzr upgrade should work if there is no working tree
146
        # -- David Allouche 2006-08-11
5273.1.7 by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through
147
        t.delete_tree('backup.bzr.~1~')
1959.3.1 by John Arbash Meinel
David Allouche: bzr upgrade should work if there is no working tree
148
        # At this point, we have a format6 branch without checkout files.
4360.10.48 by Vincent Ladeuil
And some more cleanup.
149
        upgrade.upgrade('.', bzrdir.BzrDirMetaFormat1())
1959.3.1 by John Arbash Meinel
David Allouche: bzr upgrade should work if there is no working tree
150
        # The upgrade should not have set up a working tree.
151
        control = bzrdir.BzrDir.open('.')
152
        self.assertFalse(control.has_workingtree())
153
        # We have covered the scope of this test, we may as well check that
154
        # upgrade has not eaten our data, even if it's a bit redundant with
155
        # other tests.
156
        self.failUnless(isinstance(control._format, bzrdir.BzrDirMetaFormat1))
4360.10.47 by Vincent Ladeuil
Some cleanup.
157
        b = control.open_branch()
158
        self.assertEquals(b.revision_history(),
1959.3.1 by John Arbash Meinel
David Allouche: bzr upgrade should work if there is no working tree
159
           ['mbp@sourcefrog.net-20051004035611-176b16534b086b3c',
160
            'mbp@sourcefrog.net-20051004035756-235f2b7dcdddd8dd'])
161
4119.7.1 by Jelmer Vernooij
Make upgrade default to a rich-root-capable format if the source format uses rich roots.
162
    def test_upgrade_rich_root(self):
163
        tree = self.make_branch_and_tree('tree', format='rich-root')
164
        rev_id = tree.commit('first post')
4360.10.48 by Vincent Ladeuil
And some more cleanup.
165
        upgrade.upgrade('tree')
4119.7.1 by Jelmer Vernooij
Make upgrade default to a rich-root-capable format if the source format uses rich roots.
166
2230.3.29 by Aaron Bentley
Implement conversion to branch 6
167
    def test_convert_branch5_branch6(self):
4360.10.47 by Vincent Ladeuil
Some cleanup.
168
        b = self.make_branch('branch', format='knit')
169
        b.set_revision_history(['AB', 'CD'])
170
        b.set_parent('file:///EF')
171
        b.set_bound_location('file:///GH')
172
        b.set_push_location('file:///IJ')
2255.2.196 by Robert Collins
Fix test_upgrade defects related to non local or absent working trees.
173
        target = bzrdir.format_registry.make_bzrdir('dirstate-with-subtree')
4360.10.47 by Vincent Ladeuil
Some cleanup.
174
        converter = b.bzrdir._format.get_converter(target)
175
        converter.convert(b.bzrdir, None)
176
        new_branch = branch.Branch.open(self.get_url('branch'))
177
        self.assertIs(new_branch.__class__, branch.BzrBranch6)
2230.3.29 by Aaron Bentley
Implement conversion to branch 6
178
        self.assertEqual('CD', new_branch.last_revision())
179
        self.assertEqual('file:///EF', new_branch.get_parent())
180
        self.assertEqual('file:///GH', new_branch.get_bound_location())
181
        branch_config = new_branch.get_config()._get_branch_data_config()
182
        self.assertEqual('file:///IJ',
183
            branch_config.get_user_option('push_location'))
184
4360.10.47 by Vincent Ladeuil
Some cleanup.
185
        b2 = self.make_branch('branch2', format='knit')
186
        converter = b2.bzrdir._format.get_converter(target)
187
        converter.convert(b2.bzrdir, None)
188
        b2 = branch.Branch.open(self.get_url('branch'))
189
        self.assertIs(b2.__class__, branch.BzrBranch6)
2255.12.1 by Robert Collins
Implement upgrade for working trees.
190
4273.1.13 by Aaron Bentley
Implement upgrade from branch format 7 to 8.
191
    def test_convert_branch7_branch8(self):
4360.10.47 by Vincent Ladeuil
Some cleanup.
192
        b = self.make_branch('branch', format='1.9')
4273.1.13 by Aaron Bentley
Implement upgrade from branch format 7 to 8.
193
        target = bzrdir.format_registry.make_bzrdir('1.9')
4360.10.47 by Vincent Ladeuil
Some cleanup.
194
        target.set_branch_format(branch.BzrBranchFormat8())
195
        converter = b.bzrdir._format.get_converter(target)
196
        converter.convert(b.bzrdir, None)
197
        b = branch.Branch.open(self.get_url('branch'))
198
        self.assertIs(b.__class__, branch.BzrBranch8)
199
        self.assertEqual({}, b._get_all_reference_info())
4273.1.13 by Aaron Bentley
Implement upgrade from branch format 7 to 8.
200
2255.12.1 by Robert Collins
Implement upgrade for working trees.
201
    def test_convert_knit_dirstate_empty(self):
202
        # test that asking for an upgrade from knit to dirstate works.
203
        tree = self.make_branch_and_tree('tree', format='knit')
204
        target = bzrdir.format_registry.make_bzrdir('dirstate')
205
        converter = tree.bzrdir._format.get_converter(target)
4961.2.9 by Martin Pool
Rip out most remaining uses of DummyProgressBar
206
        converter.convert(tree.bzrdir, None)
2255.12.1 by Robert Collins
Implement upgrade for working trees.
207
        new_tree = workingtree.WorkingTree.open('tree')
208
        self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4)
2598.5.10 by Aaron Bentley
Return NULL_REVISION instead of None for the null revision
209
        self.assertEqual('null:', new_tree.last_revision())
2255.12.1 by Robert Collins
Implement upgrade for working trees.
210
211
    def test_convert_knit_dirstate_content(self):
212
        # smoke test for dirstate conversion: we call dirstate primitives,
213
        # and its there that the core logic is tested.
214
        tree = self.make_branch_and_tree('tree', format='knit')
215
        self.build_tree(['tree/file'])
216
        tree.add(['file'], ['file-id'])
217
        target = bzrdir.format_registry.make_bzrdir('dirstate')
218
        converter = tree.bzrdir._format.get_converter(target)
4961.2.9 by Martin Pool
Rip out most remaining uses of DummyProgressBar
219
        converter.convert(tree.bzrdir, None)
2255.12.1 by Robert Collins
Implement upgrade for working trees.
220
        new_tree = workingtree.WorkingTree.open('tree')
221
        self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4)
2598.5.10 by Aaron Bentley
Return NULL_REVISION instead of None for the null revision
222
        self.assertEqual('null:', new_tree.last_revision())
2255.12.1 by Robert Collins
Implement upgrade for working trees.
223
224
    def test_convert_knit_one_parent_dirstate(self):
225
        # test that asking for an upgrade from knit to dirstate works.
226
        tree = self.make_branch_and_tree('tree', format='knit')
227
        rev_id = tree.commit('first post')
228
        target = bzrdir.format_registry.make_bzrdir('dirstate')
229
        converter = tree.bzrdir._format.get_converter(target)
4961.2.9 by Martin Pool
Rip out most remaining uses of DummyProgressBar
230
        converter.convert(tree.bzrdir, None)
2255.12.1 by Robert Collins
Implement upgrade for working trees.
231
        new_tree = workingtree.WorkingTree.open('tree')
232
        self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4)
233
        self.assertEqual(rev_id, new_tree.last_revision())
234
        for path in ['basis-inventory-cache', 'inventory', 'last-revision',
235
            'pending-merges', 'stat-cache']:
236
            self.failIfExists('tree/.bzr/checkout/' + path)
237
238
    def test_convert_knit_merges_dirstate(self):
239
        tree = self.make_branch_and_tree('tree', format='knit')
240
        rev_id = tree.commit('first post')
241
        merge_tree = tree.bzrdir.sprout('tree2').open_workingtree()
242
        rev_id2 = tree.commit('second post')
243
        rev_id3 = merge_tree.commit('second merge post')
244
        tree.merge_from_branch(merge_tree.branch)
245
        target = bzrdir.format_registry.make_bzrdir('dirstate')
246
        converter = tree.bzrdir._format.get_converter(target)
4961.2.9 by Martin Pool
Rip out most remaining uses of DummyProgressBar
247
        converter.convert(tree.bzrdir, None)
2255.12.1 by Robert Collins
Implement upgrade for working trees.
248
        new_tree = workingtree.WorkingTree.open('tree')
249
        self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4)
250
        self.assertEqual(rev_id2, new_tree.last_revision())
251
        self.assertEqual([rev_id2, rev_id3], new_tree.get_parent_ids())
252
        for path in ['basis-inventory-cache', 'inventory', 'last-revision',
253
            'pending-merges', 'stat-cache']:
254
            self.failIfExists('tree/.bzr/checkout/' + path)
2230.3.29 by Aaron Bentley
Implement conversion to branch 6
255
1393.1.31 by Martin Pool
- add simple test for upgrade
256
257
_upgrade1_template = \
1393.1.38 by Martin Pool
- partial test for upgrade of branch with ghosts
258
     [
259
     ('foo', 'new contents\n'),
260
     ('.bzr/',),
261
     ('.bzr/README',
3250.2.1 by Marius Kruger
update .bzr/README to not refer to Bazaar-NG, and add link to website.
262
      'This is a Bazaar control directory.\n'
263
      'Do not change any files in this directory.\n'
5560.2.1 by Vincent Ladeuil
Fix the remaining references to http://bazaar-vcs.org (except the explicitly historical ones).
264
      'See http://bazaar.canonical.com/ for more information about Bazaar.\n'),
1393.1.38 by Martin Pool
- partial test for upgrade of branch with ghosts
265
     ('.bzr/branch-format', 'Bazaar-NG branch, format 0.0.4\n'),
266
     ('.bzr/revision-history',
267
      'mbp@sourcefrog.net-20051004035611-176b16534b086b3c\n'
268
      'mbp@sourcefrog.net-20051004035756-235f2b7dcdddd8dd\n'),
269
     ('.bzr/merged-patches', ''),
270
     ('.bzr/pending-merged-patches', ''),
271
     ('.bzr/branch-name', ''),
272
     ('.bzr/branch-lock', ''),
273
     ('.bzr/pending-merges', ''),
274
     ('.bzr/inventory',
275
      '<inventory>\n'
276
      '<entry file_id="foo-20051004035605-91e788d1875603ae" kind="file" name="foo" />\n'
277
      '</inventory>\n'),
278
     ('.bzr/stat-cache',
279
      '### bzr hashcache v5\n'
280
      'foo// be9f309239729f69a6309e970ef24941d31e042c 13 1128398176 1128398176 303464 770\n'),
281
     ('.bzr/text-store/',),
282
     ('.bzr/text-store/foo-20051004035611-1591048e9dc7c2d4.gz',
283
      '\x1f\x8b\x08\x00[\xfdAC\x02\xff\xcb\xcc\xcb,\xc9L\xccQH\xce\xcf+I\xcd+)\xe6\x02\x00\xdd\xcc\xf90\x11\x00\x00\x00'),
284
     ('.bzr/text-store/foo-20051004035756-4081373d897c3453.gz',
285
      '\x1f\x8b\x08\x00\xc4\xfdAC\x02\xff\xcbK-WH\xce\xcf+I\xcd+)\xe6\x02\x00g\xc3\xdf\xc9\r\x00\x00\x00'),
286
     ('.bzr/inventory-store/',),
287
     ('.bzr/inventory-store/mbp@sourcefrog.net-20051004035611-176b16534b086b3c.gz',
288
      '\x1f\x8b\x08\x00[\xfdAC\x02\xffm\x8f\xcd\n\xc20\x10\x84\xef>E\xc8\xbdt7?M\x02\xad\xaf"\xa1\x99`P[\xa8E\xacOo\x14\x05\x0f\xdef\xe1\xfbv\x98\xbeL7L\xeb\xbcl\xfb]_\xc3\xb2\x89\\\xce8\x944\xc8<\xcf\x8d"\xb2LdH\xdb\x8el\x13\x18\xce\xfb\xc4\xde\xd5SGHq*\xd3\x0b\xad\x8e\x14S\xbc\xe0\xadI\xb1\xe2\xbe\xfe}\xc2\xdc\xb0\rL\xc6#\xa4\xd1\x8d*\x99\x0f}=F\x1e$8G\x9d\xa0\x02\xa1rP9\x01c`FV\xda1qg\x98"\x02}\xa5\xf2\xa8\x95\xec\xa4h\xeb\x80\xf6g\xcd\x13\xb3\x01\xcc\x98\xda\x00\x00\x00'),
289
     ('.bzr/inventory-store/mbp@sourcefrog.net-20051004035756-235f2b7dcdddd8dd.gz',
290
      '\x1f\x8b\x08\x00\xc4\xfdAC\x02\xffm\x8f\xc1\n\xc20\x10D\xef~E\xc8\xbd\xb8\x9bM\x9a,\xb4\xfe\x8a\xc4f\x83Am\xa1\x16\xb1~\xbdQ\x14<x\x9b\x81y3LW\xc6\x9b\x8c\xcb4\xaf\xbbMW\xc5\xbc\xaa\\\xce\xb2/\xa9\xd7y\x9a\x1a\x03\xe0\x10\xc0\x02\xb9\x16\\\xc3(>\x84\x84\xc1WKQ\xb4:\x95\xf1\x15\xad\x8cVc\xbc\xc8\x1b\xd3j\x91\xfb\xf2\xaf\xa4r\x8d\x85\x80\xe4)\x05\xf6\x03YG\x9f\xf4\xf5\x18\xb1\xd7\x07\xe1L\xc0\x86\xd8\x1b\xce-\xc7\xb6:a\x0f\x92\x8de\x8b\x89P\xc0\x9a\xe1\x0b\x95G\x9d\xc4\xda\xb1\xad\x07\xb6?o\x9e\xb5\xff\xf0\xf9\xda\x00\x00\x00'),
291
     ('.bzr/revision-store/',),
292
     ('.bzr/revision-store/mbp@sourcefrog.net-20051004035611-176b16534b086b3c.gz',
293
      '\x1f\x8b\x08\x00[\xfdAC\x02\xff\x9d\x8eKj\xc30\x14E\xe7^\x85\xd0 \xb3$\xefI\xd1\x8f\xd8\xa6\x1b(t\x07E?\xbb\x82H\n\xb2\x1ahW\xdfB1\x14:\xeb\xf4r\xee\xbdgl\xf1\x91\xb6T\x0b\xf15\xe7\xd4{l\x13}\xb6\xad\xa7B^j\xbd\x91\xc3\xad_\xb3\xbb?m\xf5\xbd\xf9\xb8\xb4\xba\x9eJ\xec\x87\xb5_)I\xe5\x11K\xaf\xed\xe35\x85\x89\xfe\xa5\x8e\x0c@ \xc0\x05\xb8\x90\x88GT\xd2\xa1\x14\xfc\xe2@K\xc7\xfd\xef\x85\xed\xcd\xe2D\x95\x8d\x1a\xa47<\x02c2\xb0 \xbc\xd0\x8ay\xa3\xbcp\x8a\x83\x12A3\xb7XJv\xef\x7f_\xf7\x94\xe3\xd6m\xbeO\x14\x91in4*<\x812\x88\xc60\xfc\x01>k\x89\x13\xe5\x12\x00\xe8<\x8c\xdf\x8d\xcd\xaeq\xb6!\x90\xa5\xd6\xf1\xbc\x07\xc3x\xde\x85\xe6\xe1\x0b\xc8\x8a\x98\x03T\x01\x00\x00'),
294
     ('.bzr/revision-store/mbp@sourcefrog.net-20051004035756-235f2b7dcdddd8dd.gz',
295
      '\x1f\x8b\x08\x00\xc4\xfdAC\x02\xff\x9d\x90Kj\x031\x0c\x86\xf79\xc5\xe0Ev\xe9\xc8o\x9b\xcc\x84^\xa0\xd0\x1b\x14\xbf&5d\xec`\xbb\x81\xf6\xf45\x84\xa4\x81\xaeZ\xa1\x85\x84^\xdf\xaf\xa9\x84K\xac1\xa7\xc1\xe5u\x8d\xad\x852\xa3\x17SZL\xc3k\xce\xa7a{j\xfb\xd5\x9e\x9fk\xfe(.,%\x1f\x9fRh\xdbc\xdb\xa3!\xa6KH-\x97\xcf\xb7\xe8g\xf4\xbbkG\x008\x06`@\xb9\xe4bG(_\x88\x95\xde\xf9n\xca\xfb\xc7\r\xf5\xdd\xe0\x19\xa9\x85)\x81\xf5"\xbd\x04j\xb8\x02b\xa8W\\\x0b\xc9\x14\xf4\xbc\xbb\xd7\xd6H4\xdc\xb8\xff}\xba\xc55\xd4f\xd6\xf3\x8c0&\x8ajE\xa4x\xe2@\xa5\xa6\x9a\xf3k\xc3WNaFT\x00\x00:l\xa6>Q\xcd1\x1cjp9\xf9;\xc34\xde\n\x9b\xe9lJWT{t\',a\xf9\x0b\xae\xc0x\x87\xa5\xb0Xp\xca,(a\xa9{\xd0{}\xd4\x12\x04(\xc5\xbb$\xc5$V\xceaI\x19\x01\xa2\x1dh\xed\x82d\x8c.\xccr@\xc3\xd8Q\xc6\x1f\xaa\xf1\xb6\xe8\xb0\xf9\x06QR\r\xf9\xfc\x01\x00\x00')]
296
297
298
_ghost_template = [
1393.1.40 by Martin Pool
- add (partially skipped) test for upgrade of uncompressed content
299
    ( './foo',
300
        'hello\n'
301
    ),
302
    ( './.bzr/', ),
303
    ( './.bzr/README',
3250.2.1 by Marius Kruger
update .bzr/README to not refer to Bazaar-NG, and add link to website.
304
      'This is a Bazaar control directory.\n'
305
      'Do not change any files in this directory.\n'
5560.2.1 by Vincent Ladeuil
Fix the remaining references to http://bazaar-vcs.org (except the explicitly historical ones).
306
      'See http://bazaar.canonical.com/ for more information about Bazaar.\n'
1393.1.40 by Martin Pool
- add (partially skipped) test for upgrade of uncompressed content
307
    ),
308
    ( './.bzr/branch-format',
309
        'Bazaar-NG branch, format 0.0.4\n'
310
    ),
311
    ( './.bzr/branch-lock',
312
        ''
313
    ),
314
    ( './.bzr/branch-name',
315
        ''
316
    ),
317
    ( './.bzr/inventory',
318
        '<inventory>\n'
319
        '<entry file_id="foo-20051004104918-0379cb7c76354cde" kind="file" name="foo" />\n'
320
        '</inventory>\n'
321
    ),
322
    ( './.bzr/merged-patches',
323
        ''
324
    ),
325
    ( './.bzr/pending-merged-patches',
326
        ''
327
    ),
328
    ( './.bzr/pending-merges',
329
        ''
330
    ),
331
    ( './.bzr/revision-history',
332
        'mbp@sourcefrog.net-20051004104921-a98be2278dd30b7b\n'
333
        'mbp@sourcefrog.net-20051004104937-c9b7a7bfcc0bb22d\n'
334
    ),
335
    ( './.bzr/stat-cache',
336
        '### bzr hashcache v5\n'
337
        'foo// f572d396fae9206628714fb2ce00f72e94f2258f 6 1128422956 1128422956 306900 770\n'
338
    ),
339
    ( './.bzr/text-store/', ),
1393.1.42 by Martin Pool
- branch upgrade currently requires input stores to be compressed
340
    ( './.bzr/text-store/foo-20051004104921-8de8118a71be45ba.gz',
341
        '\x1f\x8b\x08\x081^BC\x00\x03foo-20051004104921-8de8118a71be45ba\x00\xcbH\xcd\xc9\xc9\xe7\x02\x00 0:6\x06\x00\x00\x00'
1393.1.40 by Martin Pool
- add (partially skipped) test for upgrade of uncompressed content
342
    ),
343
    ( './.bzr/inventory-store/', ),
1393.1.42 by Martin Pool
- branch upgrade currently requires input stores to be compressed
344
    ( './.bzr/inventory-store/mbp@sourcefrog.net-20051004104921-a98be2278dd30b7b.gz',
345
        '\x1f\x8b\x08\x081^BC\x00\x03mbp@sourcefrog.net-20051004104921-a98be2278dd30b7b\x00m\x8f\xcb\n'
346
        '\xc20\x10E\xf7~E\xc8\xbe83\xcd\x13\xaa\xbf"yL0\xa8-\xd4"\xd6\xaf7\x8a\x82\x0bw\xb38\xe7\xde;C\x1do<.\xd3\xbc\xee7C;\xe6U\x94z\xe6C\xcd;Y\xa6\xa9#\x00\x8d\x00\n'
347
        'Ayt\x1d\xf4\xd6\xa7h\x935\xbdV)\xb3\x14\xa7:\xbe\xd0\xe6H1\x86\x0b\xbf5)\x16\xbe/\x7fC\x08;\x97\xd9!\xba`1\xb2\xd21|\xe8\xeb1`\xe3\xb5\xa5\xdc{S\x02{\x02c\xc8YT%Rb\x80b\x89\xbd*D\xda\x95\xafT\x1f\xad\xd2H\xb1m\xfb\xb7?\xcf<\x01W}\xb5\x8b\xd9\x00\x00\x00'
1393.1.40 by Martin Pool
- add (partially skipped) test for upgrade of uncompressed content
348
    ),
1393.1.42 by Martin Pool
- branch upgrade currently requires input stores to be compressed
349
    ( './.bzr/inventory-store/mbp@sourcefrog.net-20051004104937-c9b7a7bfcc0bb22d.gz',
350
        '\x1f\x8b\x08\x08A^BC\x00\x03mbp@sourcefrog.net-20051004104937-c9b7a7bfcc0bb22d\x00m\x8f\xcb\n'
351
        '\xc20\x10E\xf7~E\xc8\xbe83\xcd\x13\xaa\xbf"yL0\xa8-\xd4"\xd6\xaf7\x8a\x82\x0bw\xb38\xe7\xde;C\x1do<.\xd3\xbc\xee7C;\xe6U\x94z\xe6C\xcd;Y\xa6\xa9#\x00\x8d\x00\n'
352
        'Ayt\x1d\xf4\xd6\xa7h\x935\xbdV)\xb3\x14\xa7:\xbe\xd0\xe6H1\x86\x0b\xbf5)\x16\xbe/\x7fC\x08;\x97\xd9!\xba`1\xb2\xd21|\xe8\xeb1`\xe3\xb5\xa5\xdc{S\x02{\x02c\xc8YT%Rb\x80b\x89\xbd*D\xda\x95\xafT\x1f\xad\xd2H\xb1m\xfb\xb7?\xcf<\x01W}\xb5\x8b\xd9\x00\x00\x00'
1393.1.40 by Martin Pool
- add (partially skipped) test for upgrade of uncompressed content
353
    ),
354
    ( './.bzr/revision-store/', ),
1393.1.42 by Martin Pool
- branch upgrade currently requires input stores to be compressed
355
    ( './.bzr/revision-store/mbp@sourcefrog.net-20051004104921-a98be2278dd30b7b.gz',
356
        '\x1f\x8b\x08\x081^BC\x00\x03mbp@sourcefrog.net-20051004104921-a98be2278dd30b7b\x00\x9d\x8eMj\xc30\x14\x84\xf7>\x85\xd0"\xbb$\xef\xc9\xb6,\x11\xdb\xf4\x02\x85\xde\xa0\xe8\xe7\xd9\x11\xc4R\x90\xd4@{\xfa\x06\x8a\xa1\xd0]\x97\x03\xdf\xcc|c\xa6G(!E\xe6\xd2\xb6\x85Z)O\xfc\xd5\xe4\x1a"{K\xe9\xc6\x0e\xb7z\xd9\xec\xfd\xa5\xa4\x8f\xech\xc9i=E\xaa\x87\xb5^8\x0b\xf1A\xb1\xa6\xfc\xf9\x1e\xfc\xc4\xffRG\x01\xd0#@\x87\xd0i\x81G\xa3\x95%!\x06\xe5}\x0bv\xb0\xbf\x17\xca\xd5\xe0\xc4-\xa0\xb1\x8b\xb6`\xc0I\xa4\xc5\xf4\x9el\xef\x95v [\x94\xcf\x8e\xd5\xcay\xe4l\xf7\xfe\xf7u\r'
357
        '\x1b\x95j\xb6\xfb\xc4\x11\x85\xea\x84\xd0\x12O\x03t\x83D\xad\xc4\x0f\xf0\x95"M\xbc\x95\x00\xc0\xe7f|6\x8aYi^B.u<\xef\xb1\x19\xcf\xbb\xce\xdc|\x038=\xc7\xe6R\x01\x00\x00'
1393.1.40 by Martin Pool
- add (partially skipped) test for upgrade of uncompressed content
358
    ),
1393.1.42 by Martin Pool
- branch upgrade currently requires input stores to be compressed
359
    ( './.bzr/revision-store/mbp@sourcefrog.net-20051004104937-c9b7a7bfcc0bb22d.gz',
360
        '\x1f\x8b\x08\x08A^BC\x00\x03mbp@sourcefrog.net-20051004104937-c9b7a7bfcc0bb22d\x00\x9d\x90\xc1j\xc30\x0c\x86\xef}\n'
361
        "\xe3Coie'\xb1c\x9a\x94\xbe\xc0`o0,[N\x03M\\\x1c\xafe{\xfae\x94n\x85\xc1`;Y\x88O\xd2\xff\xb9Mt\x19\xe6!N\xcc\xc5q\x1cr\xa6\xd4\xf1'\x9b\xf20\xb1\xe7\x18Ol}\xca\xbb\x11\xcf\x879\xbe&G!\xc5~3Q^\xf7y\xc7\xd90]h\xca1\xbd\xbd\x0c\xbe\xe3?\xa9B\x02\xd4\x02\xa0\x12P\x99R\x17\xce\xa0\xb6\x1a\x83s\x80(\xa5\x7f\xdc0\x1f\xad\xe88\x82\xb0\x18\x0c\x82\x05\xa7\x04\x05[{\xc2\xda7\xc6\x81*\x85B\x8dh\x1a\xe7\x05g\xf7\xdc\xff>\x9d\x87\x91\xe6l\xc7s\xc7\x85\x90M%\xa5\xd1z#\x85\xa8\x9b\x1a\xaa\xfa\x06\xbc\xc7\x89:^*\x00\xe0\xfbU\xbbL\xcc\xb6\xa7\xfdH\xa9'\x16\x03\xeb\x8fq\xce\xed\xf6\xde_\xb5g\x9b\x16\xa1y\xa9\xbe\x02&\n"
362
        '\x7fJ+EaM\x83$\xa5n\xbc/a\x91~\xd0\xbd\xfd\x135\n'
363
        '\xd0\x9a`\x0c*W\x1aR\xc1\x94du\x08(\t\xb0\x91\xdeZ\xa3\x9cU\x9cm\x7f\x8dr\x1d\x10Ot\xb8\xc6\xcf\xa7\x907|\xfb-\xb1\xbd\xd3\xfb\xd5\x07\xeeD\xee\x08*\x02\x00\x00'
1393.1.40 by Martin Pool
- add (partially skipped) test for upgrade of uncompressed content
364
    ),
1393.1.38 by Martin Pool
- partial test for upgrade of branch with ghosts
365
]
1405 by Robert Collins
remove some of the upgrade code that was duplicated with inventory_entry, and give all inventory entries a weave
366
367
_upgrade_dir_template = [
368
    ( './.bzr/', ),
369
    ( './.bzr/README',
3250.2.1 by Marius Kruger
update .bzr/README to not refer to Bazaar-NG, and add link to website.
370
      'This is a Bazaar control directory.\n'
371
      'Do not change any files in this directory.\n'
5560.2.1 by Vincent Ladeuil
Fix the remaining references to http://bazaar-vcs.org (except the explicitly historical ones).
372
      'See http://bazaar.canonical.com/ for more information about Bazaar.\n'
1405 by Robert Collins
remove some of the upgrade code that was duplicated with inventory_entry, and give all inventory entries a weave
373
    ),
374
    ( './.bzr/branch-format',
375
        'Bazaar-NG branch, format 0.0.4\n'
376
    ),
377
    ( './.bzr/branch-lock',
378
        ''
379
    ),
380
    ( './.bzr/branch-name',
381
        ''
382
    ),
383
    ( './.bzr/inventory',
384
        '<inventory>\n'
385
        '<entry file_id="dir-20051005095101-da1441ea3fa6917a" kind="directory" name="dir" />\n'
386
        '</inventory>\n'
387
    ),
388
    ( './.bzr/merged-patches',
389
        ''
390
    ),
391
    ( './.bzr/pending-merged-patches',
392
        ''
393
    ),
394
    ( './.bzr/pending-merges',
395
        ''
396
    ),
397
    ( './.bzr/revision-history',
398
        'robertc@robertcollins.net-20051005095108-6065fbd8e7d8617e\n'
399
    ),
400
    ( './.bzr/stat-cache',
401
        '### bzr hashcache v5\n'
402
    ),
403
    ( './.bzr/text-store/', ),
404
    ( './.bzr/inventory-store/', ),
405
    ( './.bzr/inventory-store/robertc@robertcollins.net-20051005095108-6065fbd8e7d8617e.gz',
406
        '\x1f\x8b\x08\x00\x0c\xa2CC\x02\xff\xb3\xc9\xcc+K\xcd+\xc9/\xaa\xb4\xe3\xb2\x012\x8a*\x15\xd22sR\xe33Sl\x95R2\x8bt\x8d\x0c\x0cL\r'
407
        "\x81\xd8\xc0\x12H\x19\xea\xa6$\x1a\x9a\x98\x18\xa6&\x1a\xa7%\x9aY\x1a\x9a'*)dg\xe6A\x94\xa6&\x83LQR\xc8K\xccM\x05\x0b()\xe8\x03\xcd\xd4G\xb2\x00\x00\xc2<\x94\xb1m\x00\x00\x00"
408
    ),
409
    ( './.bzr/revision-store/', ),
410
    ( './.bzr/revision-store/robertc@robertcollins.net-20051005095108-6065fbd8e7d8617e.gz',
411
        '\x1f\x8b\x08\x00\x0c\xa2CC\x02\xff\xa5OKj\xc30\x14\xdc\xfb\x14B\x8b\xec\x92<I\xd6\xc7\xc42\x85\xde\xa0\x17(\xb6\xf4\x9c\n'
412
        'l\xa9H"\x90\x9c\xbe\xa6\xa9\xa1\x9b\xae\xbax\x0c\xcc\xe71\xd3g\xbc\x85\x12R$.\xadk\xa8\x15\xb3\xa5oi\xc2\\\xc9kZ\x96\x10\x0b9,\xf5\x92\xbf)\xf7\xf2\x83O\xe5\x14\xb1\x1e\xae\xf5BI\x887\x8c5\xe5\xfb{\xf0\x96\xfei>r\x00\xc9\xb6\x83n\x03sT\xa0\xe4<y\x83\xda\x1b\xc54\xfe~T>Ff\xe9\xcc:\xdd\x8e\xa6E\xc7@\xa2\x82I\xaaNL\xbas\\313)\x00\xb9\xe6\xe0(\xd9\x87\xfc\xb7A\r'
413
        "+\x96:\xae\x9f\x962\xc6\x8d\x04i\x949\x01\x97R\xb7\x1d\x17O\xc3#E\xb4T(\x00\xa0C\xd3o\x892^q\x18\xbd'>\xe4\xfe\xbc\x13M\x7f\xde{\r"
414
        '\xcd\x17\x85\xea\xba\x03l\x01\x00\x00'
415
    ),
416
    ( './dir/', ),
417
]
4360.10.1 by Ian Clatworthy
initial cut at smarter upgrades
418
419
4360.10.47 by Vincent Ladeuil
Some cleanup.
420
class TestSmartUpgrade(tests.TestCaseWithTransport):
4360.10.1 by Ian Clatworthy
initial cut at smarter upgrades
421
4360.10.20 by Ian Clatworthy
fix tests to truly use a shared repository, not standalone branches inside one
422
    from_format = bzrdir.format_registry.make_bzrdir("pack-0.92")
4360.10.14 by Ian Clatworthy
use the most common format converison in tests
423
    to_format = bzrdir.format_registry.make_bzrdir("2a")
4360.10.1 by Ian Clatworthy
initial cut at smarter upgrades
424
425
    def make_standalone_branch(self):
426
        wt = self.make_branch_and_tree("branch1", format=self.from_format)
427
        return wt.bzrdir
428
429
    def test_upgrade_standalone_branch(self):
430
        control = self.make_standalone_branch()
4360.10.48 by Vincent Ladeuil
And some more cleanup.
431
        tried, worked, issues = upgrade.smart_upgrade(
432
            [control], format=self.to_format)
4360.10.39 by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests.
433
        self.assertLength(1, tried)
4360.10.33 by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and
434
        self.assertEqual(tried[0], control)
4360.10.39 by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests.
435
        self.assertLength(1, worked)
4360.10.33 by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and
436
        self.assertEqual(worked[0], control)
4360.10.39 by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests.
437
        self.assertLength(0, issues)
4360.10.23 by Matthew Fuller
Update new upgrade tests to match the new backup bzrdir names.
438
        self.failUnlessExists('branch1/backup.bzr.~1~')
4360.10.32 by Matthew Fuller
Add some additional assertions into the TestSmartUpgrade tests to
439
        self.assertEqual(control.open_repository()._format,
440
                         self.to_format._repository_format)
4360.10.1 by Ian Clatworthy
initial cut at smarter upgrades
441
442
    def test_upgrade_standalone_branch_cleanup(self):
443
        control = self.make_standalone_branch()
4360.10.48 by Vincent Ladeuil
And some more cleanup.
444
        tried, worked, issues = upgrade.smart_upgrade(
445
            [control], format=self.to_format, clean_up=True)
4360.10.39 by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests.
446
        self.assertLength(1, tried)
4360.10.33 by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and
447
        self.assertEqual(tried[0], control)
4360.10.39 by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests.
448
        self.assertLength(1, worked)
4360.10.33 by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and
449
        self.assertEqual(worked[0], control)
4360.10.39 by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests.
450
        self.assertLength(0, issues)
4360.10.12 by Ian Clatworthy
use transport.delete_tree() instead of osutils.rmtree() for clean-up
451
        self.failUnlessExists('branch1')
452
        self.failUnlessExists('branch1/.bzr')
4360.10.23 by Matthew Fuller
Update new upgrade tests to match the new backup bzrdir names.
453
        self.failIfExists('branch1/backup.bzr.~1~')
4360.10.32 by Matthew Fuller
Add some additional assertions into the TestSmartUpgrade tests to
454
        self.assertEqual(control.open_repository()._format,
455
                         self.to_format._repository_format)
4360.10.1 by Ian Clatworthy
initial cut at smarter upgrades
456
4360.10.2 by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs
457
    def make_repo_with_branches(self):
4360.10.1 by Ian Clatworthy
initial cut at smarter upgrades
458
        repo = self.make_repository('repo', shared=True,
459
            format=self.from_format)
4360.10.20 by Ian Clatworthy
fix tests to truly use a shared repository, not standalone branches inside one
460
        # Note: self.make_branch() always creates a new repo at the location
461
        # so we need to avoid using that here ...
462
        b1 = bzrdir.BzrDir.create_branch_convenience("repo/branch1",
463
            format=self.from_format)
464
        b2 = bzrdir.BzrDir.create_branch_convenience("repo/branch2",
465
            format=self.from_format)
4360.10.1 by Ian Clatworthy
initial cut at smarter upgrades
466
        return repo.bzrdir
467
468
    def test_upgrade_repo_with_branches(self):
469
        control = self.make_repo_with_branches()
4360.10.48 by Vincent Ladeuil
And some more cleanup.
470
        tried, worked, issues = upgrade.smart_upgrade(
471
            [control], format=self.to_format)
4360.10.39 by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests.
472
        self.assertLength(3, tried)
4360.10.33 by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and
473
        self.assertEqual(tried[0], control)
4360.10.39 by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests.
474
        self.assertLength(3, worked)
4360.10.33 by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and
475
        self.assertEqual(worked[0], control)
4360.10.39 by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests.
476
        self.assertLength(0, issues)
4360.10.23 by Matthew Fuller
Update new upgrade tests to match the new backup bzrdir names.
477
        self.failUnlessExists('repo/backup.bzr.~1~')
478
        self.failUnlessExists('repo/branch1/backup.bzr.~1~')
479
        self.failUnlessExists('repo/branch2/backup.bzr.~1~')
4360.10.32 by Matthew Fuller
Add some additional assertions into the TestSmartUpgrade tests to
480
        self.assertEqual(control.open_repository()._format,
481
                         self.to_format._repository_format)
4360.10.47 by Vincent Ladeuil
Some cleanup.
482
        b1 = branch.Branch.open('repo/branch1')
4360.10.32 by Matthew Fuller
Add some additional assertions into the TestSmartUpgrade tests to
483
        self.assertEqual(b1._format, self.to_format._branch_format)
4360.10.1 by Ian Clatworthy
initial cut at smarter upgrades
484
4360.10.2 by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs
485
    def test_upgrade_repo_with_branches_cleanup(self):
486
        control = self.make_repo_with_branches()
4360.10.48 by Vincent Ladeuil
And some more cleanup.
487
        tried, worked, issues = upgrade.smart_upgrade(
488
            [control], format=self.to_format, clean_up=True)
4360.10.39 by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests.
489
        self.assertLength(3, tried)
4360.10.33 by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and
490
        self.assertEqual(tried[0], control)
4360.10.39 by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests.
491
        self.assertLength(3, worked)
4360.10.33 by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and
492
        self.assertEqual(worked[0], control)
4360.10.39 by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests.
493
        self.assertLength(0, issues)
4360.10.12 by Ian Clatworthy
use transport.delete_tree() instead of osutils.rmtree() for clean-up
494
        self.failUnlessExists('repo')
495
        self.failUnlessExists('repo/.bzr')
4360.10.23 by Matthew Fuller
Update new upgrade tests to match the new backup bzrdir names.
496
        self.failIfExists('repo/backup.bzr.~1~')
497
        self.failIfExists('repo/branch1/backup.bzr.~1~')
498
        self.failIfExists('repo/branch2/backup.bzr.~1~')
4360.10.32 by Matthew Fuller
Add some additional assertions into the TestSmartUpgrade tests to
499
        self.assertEqual(control.open_repository()._format,
500
                         self.to_format._repository_format)
4360.10.47 by Vincent Ladeuil
Some cleanup.
501
        b1 = branch.Branch.open('repo/branch1')
4360.10.32 by Matthew Fuller
Add some additional assertions into the TestSmartUpgrade tests to
502
        self.assertEqual(b1._format, self.to_format._branch_format)