~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_tag.py

  • Committer: Tarmac
  • Author(s): Vincent Ladeuil, Patch Queue Manager, Jelmer Vernooij
  • Date: 2017-01-17 16:20:41 UTC
  • mfrom: (6619.1.2 trunk)
  • Revision ID: tarmac-20170117162041-oo62uk1qsmgc9j31
Merge 2.7 into trunk including fixes for bugs #1622039, #1644003, #1579093 and #1645017. [r=vila]

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2007, 2009-2012, 2016 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
18
18
 
19
19
 
20
20
from bzrlib import (
21
 
    bzrdir,
 
21
    controldir,
22
22
    errors,
23
23
    )
24
24
from bzrlib.tag import (
26
26
    DisabledTags,
27
27
    )
28
28
from bzrlib.tests import (
29
 
    KnownFailure,
30
29
    TestCase,
31
30
    TestCaseWithTransport,
32
31
    )
58
57
        store = self.make_branch_supporting_tags('a').tags
59
58
        store.set_tag("foo", "myoldrevid")
60
59
        store.rename_revisions({"myoldrevid": "mynewrevid"})
61
 
        self.assertEquals({"foo": "mynewrevid"}, store.get_tag_dict())
 
60
        self.assertEqual({"foo": "mynewrevid"}, store.get_tag_dict())
62
61
 
63
62
    def test_unknown_ignored(self):
64
63
        store = self.make_branch_supporting_tags('a').tags
65
64
        store.set_tag("foo", "myoldrevid")
66
65
        store.rename_revisions({"anotherrevid": "mynewrevid"})
67
 
        self.assertEquals({"foo": "myoldrevid"}, store.get_tag_dict())
 
66
        self.assertEqual({"foo": "myoldrevid"}, store.get_tag_dict())
68
67
 
69
68
 
70
69
class TestTagMerging(TestCaseWithTransport):
71
70
 
72
71
    def make_knit_branch(self, relpath):
73
 
        old_bdf = bzrdir.format_registry.make_bzrdir('knit')
74
 
        return bzrdir.BzrDir.create_branch_convenience(relpath, format=old_bdf)
 
72
        old_bdf = controldir.format_registry.make_bzrdir('knit')
 
73
        return controldir.ControlDir.create_branch_convenience(relpath, format=old_bdf)
75
74
 
76
75
    def make_branch_supporting_tags(self, relpath):
77
76
        return self.make_branch(relpath, format='dirstate-tags')
110
109
        self.assertRaises(errors.NoSuchTag, a.tags.lookup_tag, 'tag-2')
111
110
        # conflicting merge
112
111
        a.tags.set_tag('tag-2', 'z')
113
 
        conflicts = a.tags.merge_to(b.tags)
114
 
        self.assertEqual(conflicts, [('tag-2', 'z', 'y')])
 
112
        updates, conflicts = a.tags.merge_to(b.tags)
 
113
        self.assertEqual({}, updates)
 
114
        self.assertEqual(list(conflicts), [('tag-2', 'z', 'y')])
115
115
        self.assertEqual('y', b.tags.lookup_tag('tag-2'))
116
116
        # overwrite conflicts
117
 
        conflicts = a.tags.merge_to(b.tags, overwrite=True)
118
 
        self.assertEqual(conflicts, [])
 
117
        updates, conflicts = a.tags.merge_to(b.tags, overwrite=True)
 
118
        self.assertEqual(list(conflicts), [])
 
119
        self.assertEqual({u'tag-2': 'z'}, updates)
119
120
        self.assertEqual('z', b.tags.lookup_tag('tag-2'))
120
121
 
121
122
 
122
123
class TestTagsInCheckouts(TestCaseWithTransport):
 
124
    """Tests for how tags are synchronised between the master and child branch
 
125
    of a checkout.
 
126
    """
123
127
 
124
128
    def test_update_tag_into_checkout(self):
125
129
        # checkouts are directly connected to the tags of their master branch:
129
133
        child = self.make_branch('child')
130
134
        child.bind(master)
131
135
        child.tags.set_tag('foo', 'rev-1')
132
 
        self.assertEquals('rev-1', master.tags.lookup_tag('foo'))
 
136
        self.assertEqual('rev-1', master.tags.lookup_tag('foo'))
133
137
        # deleting a tag updates the master too
134
138
        child.tags.delete_tag('foo')
135
139
        self.assertRaises(errors.NoSuchTag,
140
144
        master = self.make_branch('master')
141
145
        master.tags.set_tag('foo', 'rev-1')
142
146
        co_tree = master.create_checkout('checkout')
143
 
        self.assertEquals('rev-1',
 
147
        self.assertEqual('rev-1',
144
148
            co_tree.branch.tags.lookup_tag('foo'))
145
149
 
146
150
    def test_update_updates_tags(self):
151
155
        child.bind(master)
152
156
        child.update()
153
157
        # after an update, the child has all the master's tags
154
 
        self.assertEquals('rev-1', child.tags.lookup_tag('foo'))
 
158
        self.assertEqual('rev-1', child.tags.lookup_tag('foo'))
155
159
        # add another tag and update again
156
160
        master.tags.set_tag('tag2', 'target2')
157
161
        child.update()
158
 
        self.assertEquals('target2', child.tags.lookup_tag('tag2'))
 
162
        self.assertEqual('target2', child.tags.lookup_tag('tag2'))
159
163
 
160
164
    def test_tag_deletion_from_master_to_bound(self):
161
165
        master = self.make_branch('master')
165
169
        child.update()
166
170
        # and deletion of tags should also propagate
167
171
        master.tags.delete_tag('foo')
168
 
        raise KnownFailure("tag deletion does not propagate: "
 
172
        self.knownFailure("tag deletion does not propagate: "
169
173
            "https://bugs.launchpad.net/bzr/+bug/138802")
170
174
        self.assertRaises(errors.NoSuchTag,
171
175
            child.tags.lookup_tag, 'foo')