/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_uncommit.py

  • Committer: Jelmer Vernooij
  • Date: 2020-04-05 19:11:34 UTC
  • mto: (7490.7.16 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200405191134-0aebh8ikiwygxma5
Populate the .gitignore file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008 Canonical Ltd
 
1
# Copyright (C) 2008, 2009, 2011, 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
17
17
"""Test uncommit."""
18
18
 
19
19
 
20
 
from bzrlib import (
 
20
from .. import (
21
21
    errors,
22
22
    tests,
23
23
    uncommit,
49
49
        self.assertEqual((1, history[0]), tree.branch.last_revision_info())
50
50
 
51
51
        # The file should not be removed
52
 
        self.failUnlessExists('tree/two')
 
52
        self.assertPathExists('tree/two')
53
53
        # And it should still be listed as added
54
 
        self.assertIsNot(None, tree.path2id('two'))
 
54
        self.assertTrue(tree.is_versioned('two'))
55
55
 
56
56
    def test_uncommit_bound(self):
57
57
        tree, history = self.make_linear_tree()
58
 
        child = tree.bzrdir.sprout('child').open_workingtree()
 
58
        child = tree.controldir.sprout('child').open_workingtree()
59
59
        child.branch.bind(tree.branch)
60
60
 
61
61
        self.assertEqual(history[1], tree.last_revision())
74
74
 
75
75
    def test_uncommit_bound_local(self):
76
76
        tree, history = self.make_linear_tree()
77
 
        child = tree.bzrdir.sprout('child').open_workingtree()
 
77
        child = tree.controldir.sprout('child').open_workingtree()
78
78
        child.branch.bind(tree.branch)
79
79
 
80
80
        self.assertEqual(history[1], tree.last_revision())
95
95
 
96
96
        # If this tree isn't bound, local=True raises an exception
97
97
        self.assertRaises(errors.LocalRequiresBoundBranch,
98
 
            uncommit.uncommit, tree.branch, tree=tree, local=True)
 
98
                          uncommit.uncommit, tree.branch, tree=tree,
 
99
                          local=True)
 
100
 
 
101
    def test_uncommit_remove_tags(self):
 
102
        tree, history = self.make_linear_tree()
 
103
        self.assertEqual(history[1], tree.last_revision())
 
104
        self.assertEqual((2, history[1]), tree.branch.last_revision_info())
 
105
        tree.branch.tags.set_tag(u"pointsatexisting", history[0])
 
106
        tree.branch.tags.set_tag(u"pointsatremoved", history[1])
 
107
        uncommit.uncommit(tree.branch, tree=tree)
 
108
        self.assertEqual(history[0], tree.last_revision())
 
109
        self.assertEqual((1, history[0]), tree.branch.last_revision_info())
 
110
        self.assertEqual({
 
111
            "pointsatexisting": history[0]
 
112
            }, tree.branch.tags.get_tag_dict())
 
113
 
 
114
    def test_uncommit_remove_tags_keeps_pending_merges(self):
 
115
        tree, history = self.make_linear_tree()
 
116
        copy = tree.controldir.sprout('copyoftree').open_workingtree()
 
117
        copy.commit(message='merged', rev_id=b'merged')
 
118
        tree.merge_from_branch(copy.branch)
 
119
        tree.branch.tags.set_tag('pointsatmerged', b'merged')
 
120
        history.append(tree.commit('merge'))
 
121
        self.assertEqual(
 
122
            b'merged', tree.branch.tags.lookup_tag('pointsatmerged'))
 
123
        self.assertEqual(history[2], tree.last_revision())
 
124
        self.assertEqual((3, history[2]), tree.branch.last_revision_info())
 
125
        tree.branch.tags.set_tag(u"pointsatexisting", history[1])
 
126
        tree.branch.tags.set_tag(u"pointsatremoved", history[2])
 
127
        uncommit.uncommit(tree.branch, tree=tree)
 
128
        self.assertEqual(history[1], tree.last_revision())
 
129
        self.assertEqual((2, history[1]), tree.branch.last_revision_info())
 
130
        self.assertEqual([history[1], b'merged'], tree.get_parent_ids())
 
131
        self.assertEqual({
 
132
            "pointsatexisting": history[1],
 
133
            "pointsatmerged": b'merged',
 
134
            }, tree.branch.tags.get_tag_dict())
 
135
 
 
136
    def test_uncommit_keep_tags(self):
 
137
        tree, history = self.make_linear_tree()
 
138
        self.assertEqual(history[1], tree.last_revision())
 
139
        self.assertEqual((2, history[1]), tree.branch.last_revision_info())
 
140
        tree.branch.tags.set_tag(u"pointsatexisting", history[0])
 
141
        tree.branch.tags.set_tag(u"pointsatremoved", history[1])
 
142
        uncommit.uncommit(tree.branch, tree=tree, keep_tags=True)
 
143
        self.assertEqual(history[0], tree.last_revision())
 
144
        self.assertEqual((1, history[0]), tree.branch.last_revision_info())
 
145
        self.assertEqual({
 
146
            "pointsatexisting": history[0],
 
147
            "pointsatremoved": history[1],
 
148
            }, tree.branch.tags.get_tag_dict())