~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_interbranch/test_fetch.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-05-20 13:28:35 UTC
  • mfrom: (5852.1.11 fetch-limit)
  • Revision ID: pqm@pqm.ubuntu.com-20110520132835-3rf01eu5mbkz3zos
(jelmer) Add limit argument to Branch.fetch(). (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
        self.addCleanup(tree.unlock)
45
45
        self.assertEqual(tree.get_file_text('foo-id'), 'hello')
46
46
 
47
 
 
 
47
    def test_fetch_revisions_limit(self):
 
48
        """Test fetch-revision operation."""
 
49
        builder = self.make_branch_builder('b1',
 
50
            format=self.branch_format_from._matchingbzrdir)
 
51
        builder.start_series()
 
52
        builder.build_commit(rev_id='revision-1')
 
53
        builder.build_commit(rev_id='revision-2')
 
54
        builder.build_commit(rev_id='revision-3')
 
55
        builder.finish_series()
 
56
        b1 = builder.get_branch()
 
57
        b2 = self.make_to_branch('b2')
 
58
        b2.fetch(b1, limit=1)
 
59
 
 
60
        # fetch does not update the last revision
 
61
        self.assertEquals(NULL_REVISION, b2.last_revision())
 
62
 
 
63
        self.assertEquals(
 
64
            set(['revision-1']),
 
65
            b2.repository.has_revisions(
 
66
                ['revision-1', 'revision-2', 'revision-3']))
 
67
 
 
68
    def test_fetch_revisions_limit_incremental(self):
 
69
        """Test incremental fetch-revision operation with limit."""
 
70
        wt = self.make_from_branch_and_tree('b1')
 
71
        b1 = wt.branch
 
72
        self.build_tree_contents([('b1/foo', 'hello')])
 
73
        wt.add(['foo'], ['foo-id'])
 
74
        wt.commit('lala!', rev_id='revision-1', allow_pointless=False)
 
75
 
 
76
        b2 = self.make_to_branch('b2')
 
77
        b2.fetch(b1, limit=1)
 
78
 
 
79
        self.assertEquals(
 
80
            set(['revision-1']),
 
81
            b2.repository.has_revisions(
 
82
                ['revision-1', 'revision-2', 'revision-3']))
 
83
 
 
84
        wt.commit('hmm', rev_id='revision-2')
 
85
        wt.commit('hmmm', rev_id='revision-3')
 
86
 
 
87
        b2.fetch(b1, limit=1)
 
88
 
 
89
        # fetch does not update the last revision
 
90
        self.assertEquals(NULL_REVISION, b2.last_revision())
 
91
 
 
92
        self.assertEquals(
 
93
            set(['revision-1', 'revision-2']),
 
94
            b2.repository.has_revisions(
 
95
                ['revision-1', 'revision-2', 'revision-3']))