Example #1
0
 def test_get_revision_base_single(self):
     map_ = RevisionMap(lambda: [
         Revision('a', ()),
         Revision('b', ('a', )),
         Revision('c', ('b', )),
     ])
     eq_(map_.get_revision('base'), None)
Example #2
0
    def setUp(self):
        """
        Structure::

            base1 -----> a1a  -> b1a
                  +----> a1b  -> b1b
                                  |
                      +-----------+
                      |
                      v
            base3 -> a3 -> b3
                      ^
                      |
                      +-----------+
                                  |
            base2 -> a2 -> b2 -> c2 -> d2

        """
        self.map = RevisionMap(lambda: [
            Revision("base1", (), branch_labels="b_1"),
            Revision("a1a", ("base1", )),
            Revision("a1b", ("base1", )),
            Revision("b1a", ("a1a", )),
            Revision("b1b", ("a1b", ), dependencies="a3"),
            Revision("base2", (), branch_labels="b_2"),
            Revision("a2", ("base2", )),
            Revision("b2", ("a2", )),
            Revision("c2", ("b2", ), dependencies="a3"),
            Revision("d2", ("c2", )),
            Revision("base3", (), branch_labels="b_3"),
            Revision("a3", ("base3", )),
            Revision("b3", ("a3", )),
        ])
Example #3
0
 def test_get_revision_base_single(self):
     map_ = RevisionMap(lambda: [
         Revision("a", ()),
         Revision("b", ("a", )),
         Revision("c", ("b", )),
     ])
     eq_(map_.get_revision("base"), None)
Example #4
0
 def test_get_revision_head_single(self):
     map_ = RevisionMap(lambda: [
         Revision("a", ()),
         Revision("b", ("a", )),
         Revision("c", ("b", )),
     ])
     eq_(map_.get_revision("head"), map_._revision_map["c"])
Example #5
0
 def test_get_revision_head_single(self):
     map_ = RevisionMap(lambda: [
         Revision('a', ()),
         Revision('b', ('a', )),
         Revision('c', ('b', )),
     ])
     eq_(map_.get_revision('head'), map_._revision_map['c'])
Example #6
0
    def test_invalid_datatype(self):
        map_ = RevisionMap(
            lambda: [
                Revision("a", ()),
                Revision("b", ("a",)),
                Revision("c", ("b",)),
            ]
        )
        assert_raises_message(
            RevisionError,
            "revision identifier b'12345' is not a string; "
            "ensure database driver settings are correct",
            map_.get_revisions, b'12345'
        )

        assert_raises_message(
            RevisionError,
            "revision identifier b'12345' is not a string; "
            "ensure database driver settings are correct",
            map_.get_revision, b'12345'
        )

        assert_raises_message(
            RevisionError,
            r"revision identifier \(b'12345',\) is not a string; "
            "ensure database driver settings are correct",
            map_.get_revision, (b'12345', )
        )

        map_.get_revision(("a", ))
        map_.get_revision("a")
Example #7
0
    def test_revision_map_no_loop_w_overlapping_substrings_dependencies(self):
        r1 = Revision("user_foo", None)
        r2 = Revision("user", None, dependencies="user_foo")

        self.map = RevisionMap(lambda: [r1, r2])

        self._assert_iteration("heads", None, ["user", "user_foo"])
Example #8
0
 def test_get_revision_head_single(self):
     map_ = RevisionMap(
         lambda: [
             Revision('a', ()),
             Revision('b', ('a',)),
             Revision('c', ('b',)),
         ]
     )
     eq_(map_.get_revision('head'), map_._revision_map['c'])
Example #9
0
 def test_get_revision_head_single(self):
     map_ = RevisionMap(
         lambda: [
             Revision("a", ()),
             Revision("b", ("a",)),
             Revision("c", ("b",)),
         ]
     )
     eq_(map_.get_revision("head"), map_._revision_map["c"])
Example #10
0
 def test_get_revision_base_single(self):
     map_ = RevisionMap(
         lambda: [
             Revision('a', ()),
             Revision('b', ('a',)),
             Revision('c', ('b',)),
         ]
     )
     eq_(map_.get_revision('base'), None)
Example #11
0
    def test_iterate_tolerates_dupe_targets(self):
        map_ = RevisionMap(lambda: [
            Revision('a', ()),
            Revision('b', ('a', )),
            Revision('c', ('b', )),
        ])

        eq_([r.revision for r in map_._iterate_revisions(('c', 'c'), 'a')],
            ['c', 'b', 'a'])
Example #12
0
 def test_get_revision_base_single(self):
     map_ = RevisionMap(
         lambda: [
             Revision("a", ()),
             Revision("b", ("a",)),
             Revision("c", ("b",)),
         ]
     )
     eq_(map_.get_revision("base"), None)
Example #13
0
    def test_revision_dupe_head(self):
        r1 = Revision("user_foo", None)
        r2 = Revision("user", "user_foo", dependencies="user_foo")

        self.map = RevisionMap(lambda: [r1, r2])

        self._assert_iteration("heads", None, ["user", "user_foo"])

        eq_(self.map._topological_sort([r1, r2], [r2]), ["user", "user_foo"])
Example #14
0
    def test_add_revision_one_head(self):
        map_ = RevisionMap(lambda: [
            Revision('a', ()),
            Revision('b', ('a', )),
            Revision('c', ('b', )),
        ])
        eq_(map_.heads, ('c', ))

        map_.add_revision(Revision('d', ('c', )))
        eq_(map_.heads, ('d', ))
Example #15
0
    def test_add_revision_one_head(self):
        map_ = RevisionMap(lambda: [
            Revision("a", ()),
            Revision("b", ("a", )),
            Revision("c", ("b", )),
        ])
        eq_(map_.heads, ("c", ))

        map_.add_revision(Revision("d", ("c", )))
        eq_(map_.heads, ("d", ))
Example #16
0
 def setUp(self):
     self.map = RevisionMap(lambda: [
         Revision("a1", ()),
         Revision("a2", "a1"),
         Revision("a3", "a2"),
         Revision("b1", ()),
         Revision("b2", "b1", dependencies="a3"),
         Revision("b3", "b2"),
         Revision("b4", "b3", dependencies="a3"),
         Revision("b5", "b4"),
     ])
Example #17
0
 def setUp(self):
     self.map = RevisionMap(lambda: [
         Revision('a', (), branch_labels='abranch'),
         Revision('b', ('a',)),
         Revision('somelongername', ('b',)),
         Revision('c', ('somelongername',)),
         Revision('d', ()),
         Revision('e', ('d',), branch_labels=['ebranch']),
         Revision('someothername', ('e',)),
         Revision('f', ('someothername',)),
     ])
Example #18
0
 def setUp(self):
     self.map = RevisionMap(lambda: [
         Revision("a", (), branch_labels="abranch"),
         Revision("b", ("a", )),
         Revision("somelongername", ("b", )),
         Revision("c", ("somelongername", )),
         Revision("d", ()),
         Revision("e", ("d", ), branch_labels=["ebranch"]),
         Revision("someothername", ("e", )),
         Revision("f", ("someothername", )),
     ])
Example #19
0
    def test_add_revision_two_head(self):
        map_ = RevisionMap(lambda: [
            Revision('a', ()),
            Revision('b', ('a', )),
            Revision('c1', ('b', )),
            Revision('c2', ('b', )),
        ])
        eq_(map_.heads, ('c1', 'c2'))

        map_.add_revision(Revision('d1', ('c1', )))
        eq_(map_.heads, ('c2', 'd1'))
Example #20
0
    def test_iterate_tolerates_dupe_targets(self):
        map_ = RevisionMap(lambda: [
            Revision("a", ()),
            Revision("b", ("a", )),
            Revision("c", ("b", )),
        ])

        eq_(
            [r.revision for r in map_._iterate_revisions(("c", "c"), "a")],
            ["c", "b", "a"],
        )
Example #21
0
    def test_add_revision_two_head(self):
        map_ = RevisionMap(lambda: [
            Revision("a", ()),
            Revision("b", ("a", )),
            Revision("c1", ("b", )),
            Revision("c2", ("b", )),
        ])
        eq_(map_.heads, ("c1", "c2"))

        map_.add_revision(Revision("d1", ("c1", )))
        eq_(map_.heads, ("c2", "d1"))
Example #22
0
    def test_add_revision_one_head(self):
        map_ = RevisionMap(
            lambda: [
                Revision('a', ()),
                Revision('b', ('a',)),
                Revision('c', ('b',)),
            ]
        )
        eq_(map_.heads, ('c', ))

        map_.add_revision(Revision('d', ('c', )))
        eq_(map_.heads, ('d', ))
Example #23
0
    def test_add_revision_one_head(self):
        map_ = RevisionMap(
            lambda: [
                Revision("a", ()),
                Revision("b", ("a",)),
                Revision("c", ("b",)),
            ]
        )
        eq_(map_.heads, ("c",))

        map_.add_revision(Revision("d", ("c",)))
        eq_(map_.heads, ("d",))
Example #24
0
 def setUp(self):
     self.map = RevisionMap(lambda: [
         Revision('base1', ()),
         Revision('a1', 'base1'),
         Revision('a2', 'base1'),
         Revision('b1', 'a1'),
         Revision('c1', 'b1'),
     ])
     # intentionally make a broken map
     self.map._revision_map['fake'] = self.map._revision_map['a2']
     self.map._revision_map['b1'].dependencies = 'fake'
     self.map._revision_map['b1']._resolved_dependencies = ('fake', )
Example #25
0
 def setUp(self):
     self.map = RevisionMap(lambda: [
         Revision("base1", ()),
         Revision("a1", "base1"),
         Revision("a2", "base1"),
         Revision("b1", "a1"),
         Revision("c1", "b1"),
     ])
     # intentionally make a broken map
     self.map._revision_map["fake"] = self.map._revision_map["a2"]
     self.map._revision_map["b1"].dependencies = "fake"
     self.map._revision_map["b1"]._resolved_dependencies = ("fake", )
Example #26
0
    def test_iterate_tolerates_dupe_targets(self):
        map_ = RevisionMap(
            lambda: [
                Revision("a", ()),
                Revision("b", ("a",)),
                Revision("c", ("b",)),
            ]
        )

        eq_(
            [r.revision for r in map_._iterate_revisions(("c", "c"), "a")],
            ["c", "b", "a"],
        )
Example #27
0
    def test_add_revision_two_head(self):
        map_ = RevisionMap(
            lambda: [
                Revision('a', ()),
                Revision('b', ('a',)),
                Revision('c1', ('b',)),
                Revision('c2', ('b',)),
            ]
        )
        eq_(map_.heads, ('c1', 'c2'))

        map_.add_revision(Revision('d1', ('c1', )))
        eq_(map_.heads, ('c2', 'd1'))
Example #28
0
    def test_add_revision_two_head(self):
        map_ = RevisionMap(
            lambda: [
                Revision("a", ()),
                Revision("b", ("a",)),
                Revision("c1", ("b",)),
                Revision("c2", ("b",)),
            ]
        )
        eq_(map_.heads, ("c1", "c2"))

        map_.add_revision(Revision("d1", ("c1",)))
        eq_(map_.heads, ("c2", "d1"))
Example #29
0
 def test_filter_for_lineage_labeled_head_across_merge(self):
     fn = lambda: [
         Revision('a', ()),
         Revision('b', ('a', )),
         Revision('c1', ('b', ), branch_labels='c1branch'),
         Revision('c2', ('b', )),
         Revision('d', ('c1', 'c2')),
     ]
     map_ = RevisionMap(fn)
     c1 = map_.get_revision('c1')
     c2 = map_.get_revision('c2')
     d = map_.get_revision('d')
     eq_(map_.filter_for_lineage([c1, c2, d], "c1branch@head"), [c1, c2, d])
Example #30
0
 def test_get_revisions_heads_multiple(self):
     map_ = RevisionMap(lambda: [
         Revision("a", ()),
         Revision("b", ("a", )),
         Revision("c1", ("b", )),
         Revision("c2", ("b", )),
     ])
     eq_(
         map_.get_revisions("heads"),
         (
             map_._revision_map["c1"],
             map_._revision_map["c2"],
         ),
     )
Example #31
0
 def setUp(self):
     self.map = RevisionMap(lambda: [
         Revision("a", ()),
         Revision("b1", ("a", )),
         Revision("b2", ("a", )),
         Revision("cb1", ("b1", )),
         Revision("cb2", ("b2", )),
         Revision("d1cb1", ("cb1", )),  # head
         Revision("d2cb1", ("cb1", )),  # head
         Revision("d1cb2", ("cb2", )),
         Revision("d2cb2", ("cb2", )),
         Revision("d3cb2", ("cb2", )),  # head
         Revision("d1d2cb2", ("d1cb2", "d2cb2")),  # head + merge point
     ])
Example #32
0
 def setUp(self):
     self.map = RevisionMap(lambda: [
         Revision('a', ()),
         Revision('b1', ('a', )),
         Revision('b2', ('a', )),
         Revision('cb1', ('b1', )),
         Revision('cb2', ('b2', )),
         Revision('d1cb1', ('cb1', )),  # head
         Revision('d2cb1', ('cb1', )),  # head
         Revision('d1cb2', ('cb2', )),
         Revision('d2cb2', ('cb2', )),
         Revision('d3cb2', ('cb2', )),  # head
         Revision('d1d2cb2', ('d1cb2', 'd2cb2'))  # head + merge point
     ])
Example #33
0
    def test_filter_for_lineage_labeled_head_across_merge(self):
        def fn():
            return [
                Revision("a", ()),
                Revision("b", ("a",)),
                Revision("c1", ("b",), branch_labels="c1branch"),
                Revision("c2", ("b",)),
                Revision("d", ("c1", "c2")),
            ]

        map_ = RevisionMap(fn)
        c1 = map_.get_revision("c1")
        c2 = map_.get_revision("c2")
        d = map_.get_revision("d")
        eq_(map_.filter_for_lineage([c1, c2, d], "c1branch@head"), [c1, c2, d])
Example #34
0
    def test_filter_for_lineage_labeled_head_across_merge(self):
        def fn():
            return [
                Revision("a", ()),
                Revision("b", ("a", )),
                Revision("c1", ("b", ), branch_labels="c1branch"),
                Revision("c2", ("b", )),
                Revision("d", ("c1", "c2")),
            ]

        map_ = RevisionMap(fn)
        c1 = map_.get_revision("c1")
        c2 = map_.get_revision("c2")
        d = map_.get_revision("d")
        eq_(map_.filter_for_lineage([c1, c2, d], "c1branch@head"), [c1, c2, d])
Example #35
0
    def test_iterate_tolerates_dupe_targets(self):
        map_ = RevisionMap(lambda: [
            Revision("a", ()),
            Revision("b", ("a", )),
            Revision("c", ("b", )),
        ])

        eq_(
            [
                r.revision for r in map_.iterate_revisions(
                    ("c", "c"), "a", inclusive=False)
            ],
            # Not inclusive so should not traverse a
            ["c", "b"],
        )
Example #36
0
    def setUp(self):
        """
        Structure::

            base1 -----> a1a  -> b1a
                  +----> a1b  -> b1b
                                  |
                      +-----------+
                      |
                      v
            base3 -> a3 -> b3
                      ^
                      |
                      +-----------+
                                  |
            base2 -> a2 -> b2 -> c2 -> d2

        """
        self.map = RevisionMap(
            lambda: [
                Revision("base1", (), branch_labels="b_1"),
                Revision("a1a", ("base1",)),
                Revision("a1b", ("base1",)),
                Revision("b1a", ("a1a",)),
                Revision("b1b", ("a1b",), dependencies="a3"),
                Revision("base2", (), branch_labels="b_2"),
                Revision("a2", ("base2",)),
                Revision("b2", ("a2",)),
                Revision("c2", ("b2",), dependencies="a3"),
                Revision("d2", ("c2",)),
                Revision("base3", (), branch_labels="b_3"),
                Revision("a3", ("base3",)),
                Revision("b3", ("a3",)),
            ]
        )
Example #37
0
 def test_revision_map_solitary_dependency_loop(self):
     map_ = RevisionMap(
         lambda: [
             Revision("a", (), dependencies="a"),
         ]
     )
     self._assert_raises_revision_map_dep_loop(map_, "a")
Example #38
0
 def test_revision_map_head_dep_loop(self):
     map_ = RevisionMap(lambda: [
         Revision("a", ()),
         Revision("b", "a"),
         Revision("c", "b", dependencies="c"),
     ])
     self._assert_raises_revision_map_dep_loop(map_, "c")
Example #39
0
 def test_revision_map_base_loop(self):
     map_ = RevisionMap(lambda: [
         Revision("a", "a"),
         Revision("b", "a"),
         Revision("c", "b"),
     ])
     self._assert_raises_revision_map_loop(map_, "a")
Example #40
0
 def test_revision_map_simple_dep_cycle(self):
     map_ = RevisionMap(lambda: [
         Revision("a", (), dependencies="c"),
         Revision("b", "a"),
         Revision("c", "b"),
     ])
     self._assert_raises_revision_map_dep_cycle(map_, ["a", "b", "c"])
Example #41
0
    def setUp(self):
        """

        base1 -----> a1a  -> b1a
              +----> a1b  -> b1b
                              |
                  +-----------+
                  |
                  v
        base3 -> a3 -> b3
                  ^
                  |
                  +-----------+
                              |
        base2 -> a2 -> b2 -> c2 -> d2


        """
        self.map = RevisionMap(lambda: [
            Revision('base1', (), branch_labels='b_1'),
            Revision('a1a', ('base1', )),
            Revision('a1b', ('base1', )),
            Revision('b1a', ('a1a', )),
            Revision('b1b', ('a1b', ), dependencies='a3'),
            Revision('base2', (), branch_labels='b_2'),
            Revision('a2', ('base2', )),
            Revision('b2', ('a2', )),
            Revision('c2', ('b2', ), dependencies='a3'),
            Revision('d2', ('c2', )),
            Revision('base3', (), branch_labels='b_3'),
            Revision('a3', ('base3', )),
            Revision('b3', ('a3', )),
        ])
Example #42
0
 def test_revision_map_solitary_loop(self):
     map_ = RevisionMap(
         lambda: [
             Revision("a", "a"),
         ]
     )
     self._assert_raises_revision_map_loop(map_, "a")
Example #43
0
    def test_iterate_tolerates_dupe_targets(self):
        map_ = RevisionMap(
            lambda: [
                Revision('a', ()),
                Revision('b', ('a',)),
                Revision('c', ('b',)),
            ]
        )

        eq_(
            [
                r.revision for r in
                map_._iterate_revisions(('c', 'c'), 'a')
            ],
            ['c', 'b', 'a']
        )
Example #44
0
    def test_filter_for_lineage_labeled_head_across_merge(self):
        fn = lambda: [
            Revision('a', ()),
            Revision('b', ('a', )),
            Revision('c1', ('b', ), branch_labels='c1branch'),
            Revision('c2', ('b', )),
            Revision('d', ('c1', 'c2')),

        ]
        map_ = RevisionMap(fn)
        c1 = map_.get_revision('c1')
        c2 = map_.get_revision('c2')
        d = map_.get_revision('d')
        eq_(
            map_.filter_for_lineage([c1, c2, d], "c1branch@head"),
            [c1, c2, d]
        )
Example #45
0
 def setUp(self):
     self.map = RevisionMap(
         lambda: [
             Revision("a", (), branch_labels="abranch"),
             Revision("b", ("a",)),
             Revision("somelongername", ("b",)),
             Revision("c", ("somelongername",)),
             Revision("d", ()),
             Revision("e", ("d",), branch_labels=["ebranch"]),
             Revision("someothername", ("e",)),
             Revision("f", ("someothername",)),
         ]
     )
Example #46
0
 def setUp(self):
     self.map = RevisionMap(
         lambda: [
             Revision("base1", ()),
             Revision("a1", "base1"),
             Revision("a2", "base1"),
             Revision("b1", "a1"),
             Revision("c1", "b1"),
         ]
     )
     # intentionally make a broken map
     self.map._revision_map["fake"] = self.map._revision_map["a2"]
     self.map._revision_map["b1"].dependencies = "fake"
     self.map._revision_map["b1"]._resolved_dependencies = ("fake",)
Example #47
0
 def setUp(self):
     self.map = RevisionMap(
         lambda: [
             Revision('base1', ()),
             Revision('a1', 'base1'),
             Revision('a2', 'base1'),
             Revision('b1', 'a1'),
             Revision('c1', 'b1'),
         ]
     )
     # intentionally make a broken map
     self.map._revision_map['fake'] = self.map._revision_map['a2']
     self.map._revision_map['b1'].dependencies = 'fake'
     self.map._revision_map['b1']._resolved_dependencies = ('fake', )
Example #48
0
 def setUp(self):
     self.map = RevisionMap(
         lambda: [
             Revision('a', ()),
             Revision('b1', ('a',)),
             Revision('b2', ('a',)),
             Revision('cb1', ('b1',)),
             Revision('cb2', ('b2',)),
             Revision('d1cb1', ('cb1',)),  # head
             Revision('d2cb1', ('cb1',)),  # head
             Revision('d1cb2', ('cb2',)),
             Revision('d2cb2', ('cb2',)),
             Revision('d3cb2', ('cb2',)),  # head
             Revision('d1d2cb2', ('d1cb2', 'd2cb2'))  # head + merge point
         ]
     )
Example #49
0
 def setUp(self):
     self.map = RevisionMap(
         lambda: [
             Revision("a", ()),
             Revision("b1", ("a",)),
             Revision("b2", ("a",)),
             Revision("cb1", ("b1",)),
             Revision("cb2", ("b2",)),
             Revision("d1cb1", ("cb1",)),  # head
             Revision("d2cb1", ("cb1",)),  # head
             Revision("d1cb2", ("cb2",)),
             Revision("d2cb2", ("cb2",)),
             Revision("d3cb2", ("cb2",)),  # head
             Revision("d1d2cb2", ("d1cb2", "d2cb2")),  # head + merge point
         ]
     )
Example #50
0
 def setUp(self):
     self.map = RevisionMap(
         lambda: [
             Revision("base1", ()),
             Revision("base2", ()),
             Revision("base3", ()),
             Revision("a1a", ("base1",)),
             Revision("a1b", ("base1",)),
             Revision("a2", ("base2",)),
             Revision("a3", ("base3",)),
             Revision("b1a", ("a1a",)),
             Revision("b1b", ("a1b",)),
             Revision("b2", ("a2",)),
             Revision("b3", ("a3",)),
             Revision("c2", ("b2",)),
             Revision("d2", ("c2",)),
             Revision("mergeb3d2", ("b3", "d2")),
         ]
     )
Example #51
0
 def setUp(self):
     self.map = RevisionMap(
         lambda: [
             Revision("a1", ()),
             Revision("a2", ("a1",)),
             Revision("a3", ("a2",)),
             Revision("b1", ("a3",)),
             Revision("b2", ("a3",)),
             Revision("cb1", ("b1",)),
             Revision("cb2", ("b2",)),
             Revision("db1", ("cb1",)),
             Revision("db2", ("cb2",)),
             Revision("e1b1", ("db1",)),
             Revision("fe1b1", ("e1b1",)),
             Revision("e2b1", ("db1",)),
             Revision("e2b2", ("db2",)),
             Revision("merge", ("e2b1", "e2b2")),
         ]
     )
Example #52
0
class DepResolutionFailedTest(DownIterateTest):
    def setUp(self):
        self.map = RevisionMap(
            lambda: [
                Revision("base1", ()),
                Revision("a1", "base1"),
                Revision("a2", "base1"),
                Revision("b1", "a1"),
                Revision("c1", "b1"),
            ]
        )
        # intentionally make a broken map
        self.map._revision_map["fake"] = self.map._revision_map["a2"]
        self.map._revision_map["b1"].dependencies = "fake"
        self.map._revision_map["b1"]._resolved_dependencies = ("fake",)

    def test_failure_message(self):
        iter_ = self.map.iterate_revisions("c1", "base1")
        assert_raises_message(
            RevisionError, "Dependency resolution failed;", list, iter_
        )
Example #53
0
    def setUp(self):
        self.map = RevisionMap(
            lambda: [
                Revision('a1', ()),
                Revision('a2', ('a1',)),
                Revision('a3', ('a2',)),
                Revision('b1', ('a3',)),
                Revision('b2', ('a3',)),
                Revision('cb1', ('b1',)),
                Revision('cb2', ('b2',)),
                Revision('db1', ('cb1',)),
                Revision('db2', ('cb2',)),

                Revision('e1b1', ('db1',)),
                Revision('fe1b1', ('e1b1',)),

                Revision('e2b1', ('db1',)),
                Revision('e2b2', ('db2',)),
                Revision("merge", ('e2b1', 'e2b2'))
            ]
        )
Example #54
0
    def setUp(self):
        self.map = RevisionMap(
            lambda: [
                Revision('base1', ()),
                Revision('base2', ()),
                Revision('base3', ()),

                Revision('a1a', ('base1',)),
                Revision('a1b', ('base1',)),
                Revision('a2', ('base2',)),
                Revision('a3', ('base3',)),

                Revision('b1a', ('a1a',)),
                Revision('b1b', ('a1b',)),
                Revision('b2', ('a2',)),
                Revision('b3', ('a3',)),

                Revision('c2', ('b2',)),
                Revision('d2', ('c2',)),

                Revision('mergeb3d2', ('b3', 'd2'))
            ]
        )
Example #55
0
class DepResolutionFailedTest(DownIterateTest):
    def setUp(self):
        self.map = RevisionMap(
            lambda: [
                Revision('base1', ()),
                Revision('a1', 'base1'),
                Revision('a2', 'base1'),
                Revision('b1', 'a1'),
                Revision('c1', 'b1'),
            ]
        )
        # intentionally make a broken map
        self.map._revision_map['fake'] = self.map._revision_map['a2']
        self.map._revision_map['b1'].dependencies = 'fake'
        self.map._revision_map['b1']._resolved_dependencies = ('fake', )

    def test_failure_message(self):
        iter_ = self.map.iterate_revisions("c1", "base1")
        assert_raises_message(
            RevisionError,
            "Dependency resolution failed;",
            list, iter_
        )
Example #56
0
    def setUp(self):
        """

        base1 -----> a1a  -> b1a
              +----> a1b  -> b1b
                              |
                  +-----------+
                  |
                  v
        base3 -> a3 -> b3
                  ^
                  |
                  +-----------+
                              |
        base2 -> a2 -> b2 -> c2 -> d2


        """
        self.map = RevisionMap(
            lambda: [
                Revision('base1', (), branch_labels='b_1'),
                Revision('a1a', ('base1',)),
                Revision('a1b', ('base1',)),
                Revision('b1a', ('a1a',)),
                Revision('b1b', ('a1b', ), dependencies='a3'),

                Revision('base2', (), branch_labels='b_2'),
                Revision('a2', ('base2',)),
                Revision('b2', ('a2',)),
                Revision('c2', ('b2', ), dependencies='a3'),
                Revision('d2', ('c2',)),

                Revision('base3', (), branch_labels='b_3'),
                Revision('a3', ('base3',)),
                Revision('b3', ('a3',)),
            ]
        )
Example #57
0
class MultipleBaseCrossDependencyTestOne(DownIterateTest):
    def setUp(self):
        """

        base1 -----> a1a  -> b1a
              +----> a1b  -> b1b
                              |
                  +-----------+
                  |
                  v
        base3 -> a3 -> b3
                  ^
                  |
                  +-----------+
                              |
        base2 -> a2 -> b2 -> c2 -> d2


        """
        self.map = RevisionMap(
            lambda: [
                Revision('base1', (), branch_labels='b_1'),
                Revision('a1a', ('base1',)),
                Revision('a1b', ('base1',)),
                Revision('b1a', ('a1a',)),
                Revision('b1b', ('a1b', ), dependencies='a3'),

                Revision('base2', (), branch_labels='b_2'),
                Revision('a2', ('base2',)),
                Revision('b2', ('a2',)),
                Revision('c2', ('b2', ), dependencies='a3'),
                Revision('d2', ('c2',)),

                Revision('base3', (), branch_labels='b_3'),
                Revision('a3', ('base3',)),
                Revision('b3', ('a3',)),
            ]
        )

    def test_what_are_the_heads(self):
        eq_(self.map.heads, ("b1a", "b1b", "d2", "b3"))

    def test_heads_to_base(self):
        self._assert_iteration(
            "heads", "base",
            [

                'b1a', 'a1a', 'b1b', 'a1b', 'd2', 'c2', 'b2', 'a2', 'base2',
                'b3', 'a3', 'base3',
                'base1'
            ]
        )

    def test_heads_to_base_downgrade(self):
        self._assert_iteration(
            "heads", "base",
            [

                'b1a', 'a1a', 'b1b', 'a1b', 'd2', 'c2', 'b2', 'a2', 'base2',
                'b3', 'a3', 'base3',
                'base1'
            ],
            select_for_downgrade=True
        )

    def test_same_branch_wrong_direction(self):
        assert_raises_message(
            RevisionError,
            r"Revision d2 is not an ancestor of revision b2",
            list,
            self.map._iterate_revisions('b2', 'd2')
        )

    def test_different_branch_not_wrong_direction(self):
        self._assert_iteration(
            "b3", "d2",
            []
        )

    def test_we_need_head2_upgrade(self):
        # the 2 branch relies on the 3 branch
        self._assert_iteration(
            "b_2@head", "base",
            ['d2', 'c2', 'b2', 'a2', 'base2', 'a3', 'base3']
        )

    def test_we_need_head2_downgrade(self):
        # the 2 branch relies on the 3 branch, but
        # on the downgrade side, don't need to touch the 3 branch
        self._assert_iteration(
            "b_2@head", "b_2@base",
            ['d2', 'c2', 'b2', 'a2', 'base2'],
            select_for_downgrade=True
        )

    def test_we_need_head3_upgrade(self):
        # the 3 branch can be upgraded alone.
        self._assert_iteration(
            "b_3@head", "base",
            ['b3', 'a3', 'base3']
        )

    def test_we_need_head3_downgrade(self):
        # the 3 branch can be upgraded alone.
        self._assert_iteration(
            "b_3@head", "base",
            ['b3', 'a3', 'base3'],
            select_for_downgrade=True
        )

    def test_we_need_head1_upgrade(self):
        # the 1 branch relies on the 3 branch
        self._assert_iteration(
            "b1b@head", "base",
            ['b1b', 'a1b', 'base1', 'a3', 'base3']
        )

    def test_we_need_head1_downgrade(self):
        # going down we don't need a3-> base3, as long
        # as we are limiting the base target
        self._assert_iteration(
            "b1b@head", "b1b@base",
            ['b1b', 'a1b', 'base1'],
            select_for_downgrade=True
        )

    def test_we_need_base2_upgrade(self):
        # consider a downgrade to b_2@base - we
        # want to run through all the "2"s alone, and we're done.
        self._assert_iteration(
            "heads", "b_2@base",
            ['d2', 'c2', 'b2', 'a2', 'base2']
        )

    def test_we_need_base2_downgrade(self):
        # consider a downgrade to b_2@base - we
        # want to run through all the "2"s alone, and we're done.
        self._assert_iteration(
            "heads", "b_2@base",
            ['d2', 'c2', 'b2', 'a2', 'base2'],
            select_for_downgrade=True
        )

    def test_we_need_base3_upgrade(self):
        self._assert_iteration(
            "heads", "b_3@base",
            ['b1b', 'd2', 'c2', 'b3', 'a3', 'base3']
        )

    def test_we_need_base3_downgrade(self):
        # consider a downgrade to b_3@base - due to the a3 dependency, we
        # need to downgrade everything dependent on a3
        # as well, which means b1b and c2.  Then we can downgrade
        # the 3s.
        self._assert_iteration(
            "heads", "b_3@base",
            ['b1b', 'd2', 'c2', 'b3', 'a3', 'base3'],
            select_for_downgrade=True
        )
Example #58
0
class BranchTravellingTest(DownIterateTest):
    """test the order of revs when going along multiple branches.

    We want depth-first along branches, but then we want to
    terminate all branches at their branch point before continuing
    to the nodes preceding that branch.

    """

    def setUp(self):
        self.map = RevisionMap(
            lambda: [
                Revision('a1', ()),
                Revision('a2', ('a1',)),
                Revision('a3', ('a2',)),
                Revision('b1', ('a3',)),
                Revision('b2', ('a3',)),
                Revision('cb1', ('b1',)),
                Revision('cb2', ('b2',)),
                Revision('db1', ('cb1',)),
                Revision('db2', ('cb2',)),

                Revision('e1b1', ('db1',)),
                Revision('fe1b1', ('e1b1',)),

                Revision('e2b1', ('db1',)),
                Revision('e2b2', ('db2',)),
                Revision("merge", ('e2b1', 'e2b2'))
            ]
        )

    def test_iterate_one_branch_both_to_merge(self):
        # test that when we hit a merge point, implicit base will
        # ensure all branches that supply the merge point are filled in
        self._assert_iteration(
            "merge", "db1",
            ['merge',
                'e2b1', 'db1',
                'e2b2', 'db2', 'cb2', 'b2'],
            implicit_base=True
        )

    def test_three_branches_end_in_single_branch(self):

        self._assert_iteration(
            ["merge", "fe1b1"], "a3",
            ['merge', 'e2b1', 'e2b2', 'db2', 'cb2', 'b2',
             'fe1b1', 'e1b1', 'db1', 'cb1', 'b1', 'a3']
        )

    def test_two_branches_to_root(self):

        # here we want 'a3' as a "stop" branch point, but *not*
        # 'db1', as we don't have multiple traversals on db1
        self._assert_iteration(
            "merge", "a1",
            ['merge',
                'e2b1', 'db1', 'cb1', 'b1',  # e2b1 branch
                'e2b2', 'db2', 'cb2', 'b2',  # e2b2 branch
                'a3',  # both terminate at a3
                'a2', 'a1'  # finish out
            ]  # noqa
        )

    def test_two_branches_end_in_branch(self):
        self._assert_iteration(
            "merge", "b1",
            # 'b1' is local to 'e2b1'
            # branch so that is all we get
            ['merge', 'e2b1', 'db1', 'cb1', 'b1',

        ]  # noqa
        )

    def test_two_branches_end_behind_branch(self):
        self._assert_iteration(
            "merge", "a2",
            ['merge',
                'e2b1', 'db1', 'cb1', 'b1',  # e2b1 branch
                'e2b2', 'db2', 'cb2', 'b2',  # e2b2 branch
                'a3',  # both terminate at a3
                'a2'
            ]  # noqa
        )

    def test_three_branches_to_root(self):

        # in this case, both "a3" and "db1" are stop points
        self._assert_iteration(
            ["merge", "fe1b1"], "a1",
            ['merge',
                'e2b1',  # e2b1 branch
                'e2b2', 'db2', 'cb2', 'b2',  # e2b2 branch
                'fe1b1', 'e1b1',  # fe1b1 branch
                'db1',  # fe1b1 and e2b1 branches terminate at db1
                'cb1', 'b1',  # e2b1 branch continued....might be nicer
                              # if this was before the e2b2 branch...
                'a3',  # e2b1 and e2b2 branches terminate at a3
                'a2', 'a1'  # finish out
            ]  # noqa
        )

    def test_three_branches_end_multiple_bases(self):

        # in this case, both "a3" and "db1" are stop points
        self._assert_iteration(
            ["merge", "fe1b1"], ["cb1", "cb2"],
            [
                'merge',
                'e2b1',
                'e2b2', 'db2', 'cb2',
                'fe1b1', 'e1b1',
                'db1',
                'cb1'
            ]
        )

    def test_three_branches_end_multiple_bases_exclusive(self):

        self._assert_iteration(
            ["merge", "fe1b1"], ["cb1", "cb2"],
            [
                'merge',
                'e2b1',
                'e2b2', 'db2',
                'fe1b1', 'e1b1',
                'db1',
            ],
            inclusive=False
        )

    def test_detect_invalid_head_selection(self):
        # db1 is an ancestor of fe1b1
        assert_raises_message(
            RevisionError,
            "Requested revision fe1b1 overlaps "
            "with other requested revisions",
            list,
            self.map._iterate_revisions(["db1", "b2", "fe1b1"], ())
        )

    def test_three_branches_end_multiple_bases_exclusive_blank(self):
        self._assert_iteration(
            ["e2b1", "b2", "fe1b1"], (),
            [
                'e2b1',
                'b2',
                'fe1b1', 'e1b1',
                'db1', 'cb1', 'b1', 'a3', 'a2', 'a1'
            ],
            inclusive=False
        )

    def test_iterate_to_symbolic_base(self):
        self._assert_iteration(
            ["fe1b1"], "base",
            ['fe1b1', 'e1b1', 'db1', 'cb1', 'b1', 'a3', 'a2', 'a1'],
            inclusive=False
        )

    def test_ancestor_nodes(self):
        merge = self.map.get_revision("merge")
        eq_(
            set(
                rev.revision
                for rev in self.map._get_ancestor_nodes([merge], check=True)
            ),
            set(['a1', 'e2b2', 'e2b1', 'cb2', 'merge',
                'a3', 'a2', 'b1', 'b2', 'db1', 'db2', 'cb1'])
        )
Example #59
0
class MultipleBaseTest(DownIterateTest):
    def setUp(self):
        self.map = RevisionMap(
            lambda: [
                Revision('base1', ()),
                Revision('base2', ()),
                Revision('base3', ()),

                Revision('a1a', ('base1',)),
                Revision('a1b', ('base1',)),
                Revision('a2', ('base2',)),
                Revision('a3', ('base3',)),

                Revision('b1a', ('a1a',)),
                Revision('b1b', ('a1b',)),
                Revision('b2', ('a2',)),
                Revision('b3', ('a3',)),

                Revision('c2', ('b2',)),
                Revision('d2', ('c2',)),

                Revision('mergeb3d2', ('b3', 'd2'))
            ]
        )

    def test_heads_to_base(self):
        self._assert_iteration(
            "heads", "base",
            [
                'b1a', 'a1a',
                'b1b', 'a1b',
                'mergeb3d2',
                    'b3', 'a3', 'base3',
                    'd2', 'c2', 'b2', 'a2', 'base2',
                'base1'
            ]
        )

    def test_heads_to_base_exclusive(self):
        self._assert_iteration(
            "heads", "base",
            [
                'b1a', 'a1a',
                'b1b', 'a1b',
                'mergeb3d2',
                    'b3', 'a3', 'base3',
                    'd2', 'c2', 'b2', 'a2', 'base2',
                    'base1',
            ],
            inclusive=False
        )

    def test_heads_to_blank(self):
        self._assert_iteration(
            "heads", None,
            [
                'b1a', 'a1a',
                'b1b', 'a1b',
                'mergeb3d2',
                    'b3', 'a3', 'base3',
                    'd2', 'c2', 'b2', 'a2', 'base2',
                'base1'
            ]
        )

    def test_detect_invalid_base_selection(self):
        assert_raises_message(
            RevisionError,
            "Requested revision a2 overlaps with "
            "other requested revisions",
            list,
            self.map._iterate_revisions(["c2"], ["a2", "b2"])
        )

    def test_heads_to_revs_plus_implicit_base_exclusive(self):
        self._assert_iteration(
            "heads", ["c2"],
            [
                'b1a', 'a1a',
                'b1b', 'a1b',
                'mergeb3d2',
                    'b3', 'a3', 'base3',
                    'd2',
                'base1'
            ],
            inclusive=False,
            implicit_base=True
        )

    def test_heads_to_revs_base_exclusive(self):
        self._assert_iteration(
            "heads", ["c2"],
            [
                'mergeb3d2', 'd2'
            ],
            inclusive=False
        )

    def test_heads_to_revs_plus_implicit_base_inclusive(self):
        self._assert_iteration(
            "heads", ["c2"],
            [
                'b1a', 'a1a',
                'b1b', 'a1b',
                'mergeb3d2',
                    'b3', 'a3', 'base3',
                    'd2', 'c2',
                'base1'
            ],
            implicit_base=True
        )

    def test_specific_path_one(self):
        self._assert_iteration(
            "b3", "base3",
            ['b3', 'a3', 'base3']
        )

    def test_specific_path_two_implicit_base(self):
        self._assert_iteration(
            ["b3", "b2"], "base3",
            ['b3', 'a3', 'b2', 'a2', 'base2'],
            inclusive=False, implicit_base=True
        )