/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 breezy/tests/per_repository/test_fetch.py

  • Committer: Jelmer Vernooij
  • Date: 2017-08-10 00:51:26 UTC
  • mfrom: (6747.3.1 avoid-set-revid-2)
  • Revision ID: jelmer@jelmer.uk-20170810005126-pmeq8y51dax20svq
Merge lp:~jelmer/brz/avoid-set-revid-2

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
        tree_a = self.make_branch_and_tree('a')
43
43
        self.build_tree(['a/foo'])
44
44
        tree_a.add('foo')
45
 
        tree_a.commit('rev1', rev_id='rev1')
 
45
        rev1 = tree_a.commit('rev1')
46
46
        # fetch with a default limit (grab everything)
47
47
        repo = self.make_repository('b')
48
48
        if (tree_a.branch.repository.supports_rich_root() and not
67
67
        tree_a = self.make_branch_and_tree('a')
68
68
        self.build_tree(['a/foo'])
69
69
        tree_a.add('foo')
70
 
        tree_a.commit('rev1', rev_id='rev1')
 
70
        rev1 = tree_a.commit('rev1')
71
71
        # create a knit-3 based format to fetch into
72
72
        f = controldir.format_registry.make_controldir('development-subtree')
73
73
        try:
84
84
        # Reopen to avoid any in-memory caching - ensure its reading from
85
85
        # disk.
86
86
        knit3_repo = b_bzrdir.open_repository()
87
 
        rev1_tree = knit3_repo.revision_tree('rev1')
 
87
        rev1_tree = knit3_repo.revision_tree(rev1)
88
88
        rev1_tree.lock_read()
89
89
        try:
90
90
            lines = rev1_tree.get_file_lines(rev1_tree.get_root_id())
101
101
            except errors.NotLocalUrl:
102
102
                raise TestSkipped("cannot make working tree with transport %r"
103
103
                              % b_bzrdir.transport)
104
 
        tree_b.commit('no change', rev_id='rev2')
105
 
        rev2_tree = knit3_repo.revision_tree('rev2')
 
104
        rev2 = tree_b.commit('no change')
 
105
        rev2_tree = knit3_repo.revision_tree(rev2)
106
106
        self.assertEqual(
107
 
            'rev1',
 
107
            rev1,
108
108
            rev2_tree.get_file_revision(rev2_tree.get_root_id()))
109
109
 
110
110
    def do_test_fetch_to_rich_root_sets_parents_correctly(self, result,
271
271
 
272
272
    def makeARepoWithSignatures(self):
273
273
        wt = self.make_branch_and_tree('a-repo-with-sigs')
274
 
        wt.commit('rev1', allow_pointless=True, rev_id='rev1')
 
274
        rev1 = wt.commit('rev1', allow_pointless=True)
275
275
        repo = wt.branch.repository
276
276
        repo.lock_write()
277
277
        repo.start_write_group()
278
278
        try:
279
 
            repo.sign_revision('rev1', gpg.LoopbackGPGStrategy(None))
 
279
            repo.sign_revision(rev1, gpg.LoopbackGPGStrategy(None))
280
280
        except errors.UnsupportedOperation:
281
281
            self.assertFalse(repo._format.supports_revision_signatures)
282
282
            raise TestNotApplicable("repository format does not support signatures")
283
283
        repo.commit_write_group()
284
284
        repo.unlock()
285
 
        return repo
 
285
        return repo, rev1
286
286
 
287
287
    def test_fetch_copies_signatures(self):
288
 
        source_repo = self.makeARepoWithSignatures()
 
288
        source_repo, rev1 = self.makeARepoWithSignatures()
289
289
        target_repo = self.make_repository('target')
290
290
        target_repo.fetch(source_repo, revision_id=None)
291
291
        self.assertEqual(
292
 
            source_repo.get_signature_text('rev1'),
293
 
            target_repo.get_signature_text('rev1'))
 
292
            source_repo.get_signature_text(rev1),
 
293
            target_repo.get_signature_text(rev1))
294
294
 
295
295
    def make_repository_with_one_revision(self):
296
296
        wt = self.make_branch_and_tree('source')
297
 
        wt.commit('rev1', allow_pointless=True, rev_id='rev1')
298
 
        return wt.branch.repository
 
297
        rev1 = wt.commit('rev1', allow_pointless=True)
 
298
        return wt.branch.repository, rev1
299
299
 
300
300
    def test_fetch_revision_already_exists(self):
301
301
        # Make a repository with one revision.
302
 
        source_repo = self.make_repository_with_one_revision()
 
302
        source_repo, rev1 = self.make_repository_with_one_revision()
303
303
        # Fetch that revision into a second repository.
304
304
        target_repo = self.make_repository('target')
305
 
        target_repo.fetch(source_repo, revision_id='rev1')
 
305
        target_repo.fetch(source_repo, revision_id=rev1)
306
306
        # Now fetch again; there will be nothing to do.  This should work
307
307
        # without causing any errors.
308
 
        target_repo.fetch(source_repo, revision_id='rev1')
 
308
        target_repo.fetch(source_repo, revision_id=rev1)
309
309
 
310
310
    def test_fetch_all_same_revisions_twice(self):
311
311
        # Blind-fetching all the same revisions twice should succeed and be a