~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_tag.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-01 08:02:42 UTC
  • mfrom: (5390.3.3 faster-revert-593560)
  • Revision ID: pqm@pqm.ubuntu.com-20100901080242-esg62ody4frwmy66
(spiv) Avoid repeatedly calling self.target.all_file_ids() in
 InterTree.iter_changes. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

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