/breezy/unstable

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/unstable

« back to all changes in this revision

Viewing changes to breezy/tests/test_vf_search.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-24 01:39:33 UTC
  • mfrom: (3815.3776.6)
  • Revision ID: jelmer@jelmer.uk-20170524013933-ir4y4tqtrsiz2ka2
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
from bzrlib import (
 
17
from .. import (
18
18
    graph as _mod_graph,
19
19
    tests,
20
20
    vf_search,
21
21
    )
22
 
from bzrlib.revision import NULL_REVISION
23
 
from bzrlib.tests.test_graph import TestGraphBase
 
22
from ..revision import NULL_REVISION
 
23
from .test_graph import TestGraphBase
24
24
 
25
25
# Ancestry 1:
26
26
#
83
83
        g = self.make_graph(
84
84
            {"tip":["mid"], "mid":["base"], "tag":["base"],
85
85
             "base":[NULL_REVISION], NULL_REVISION:[]})
86
 
        result = vf_search.SearchResult(set(['tip', 'tag']),
87
 
            set([NULL_REVISION]), 4, set(['tip', 'mid', 'tag', 'base']))
88
 
        result = result.refine(set(['tip']), set(['mid']))
 
86
        result = vf_search.SearchResult({'tip', 'tag'},
 
87
            {NULL_REVISION}, 4, {'tip', 'mid', 'tag', 'base'})
 
88
        result = result.refine({'tip'}, {'mid'})
89
89
        recipe = result.get_recipe()
90
90
        # We should be starting from tag (original head) and mid (seen ref)
91
 
        self.assertEqual(set(['mid', 'tag']), recipe[1])
 
91
        self.assertEqual({'mid', 'tag'}, recipe[1])
92
92
        # We should be stopping at NULL (original stop) and tip (seen head)
93
 
        self.assertEqual(set([NULL_REVISION, 'tip']), recipe[2])
 
93
        self.assertEqual({NULL_REVISION, 'tip'}, recipe[2])
94
94
        self.assertEqual(3, recipe[3])
95
 
        result = result.refine(set(['mid', 'tag', 'base']),
96
 
            set([NULL_REVISION]))
 
95
        result = result.refine({'mid', 'tag', 'base'},
 
96
            {NULL_REVISION})
97
97
        recipe = result.get_recipe()
98
98
        # We should be starting from nothing (NULL was known as a cut point)
99
99
        self.assertEqual(set([]), recipe[1])
101
101
        # tag (seen head) and mid(seen mid-point head). We could come back and
102
102
        # define this as not including mid, for minimal results, but it is
103
103
        # still 'correct' to include mid, and simpler/easier.
104
 
        self.assertEqual(set([NULL_REVISION, 'tip', 'tag', 'mid']), recipe[2])
 
104
        self.assertEqual({NULL_REVISION, 'tip', 'tag', 'mid'}, recipe[2])
105
105
        self.assertEqual(0, recipe[3])
106
106
        self.assertTrue(result.is_empty())
107
107
 
189
189
            {"tip":["mid"], "mid":["base"], "tag":["base"],
190
190
             "base":[NULL_REVISION], NULL_REVISION:[]})
191
191
        result = vf_search.PendingAncestryResult(['tip', 'tag'], None)
192
 
        result = result.refine(set(['tip']), set(['mid']))
193
 
        self.assertEqual(set(['mid', 'tag']), result.heads)
194
 
        result = result.refine(set(['mid', 'tag', 'base']),
195
 
            set([NULL_REVISION]))
196
 
        self.assertEqual(set([NULL_REVISION]), result.heads)
 
192
        result = result.refine({'tip'}, {'mid'})
 
193
        self.assertEqual({'mid', 'tag'}, result.heads)
 
194
        result = result.refine({'mid', 'tag', 'base'},
 
195
            {NULL_REVISION})
 
196
        self.assertEqual({NULL_REVISION}, result.heads)
197
197
        self.assertTrue(result.is_empty())
198
198
 
199
199
 
200
200
class TestPendingAncestryResultGetKeys(tests.TestCaseWithMemoryTransport):
201
 
    """Tests for bzrlib.graph.PendingAncestryResult."""
 
201
    """Tests for breezy.graph.PendingAncestryResult."""
202
202
 
203
203
    def test_get_keys(self):
204
204
        builder = self.make_branch_builder('b')
211
211
        repo.lock_read()
212
212
        self.addCleanup(repo.unlock)
213
213
        result = vf_search.PendingAncestryResult(['rev-2'], repo)
214
 
        self.assertEqual(set(['rev-1', 'rev-2']), set(result.get_keys()))
 
214
        self.assertEqual({'rev-1', 'rev-2'}, set(result.get_keys()))
215
215
 
216
216
    def test_get_keys_excludes_ghosts(self):
217
217
        builder = self.make_branch_builder('b')
236
236
        result = vf_search.PendingAncestryResult(['rev-3'], None)
237
237
        result_keys = result._get_keys(StubGraph())
238
238
        # Only the non-null keys from the ancestry appear.
239
 
        self.assertEqual(set(['foo']), set(result_keys))
 
239
        self.assertEqual({'foo'}, set(result_keys))