/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
5582.5.1 by John Arbash Meinel
Fix bug 701212. Don't set the tags for a master branch during update.
1
# Copyright (C) 2006-2011 Canonical Ltd
1587.1.11 by Robert Collins
Local commits appear to be working properly.
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1587.1.11 by Robert Collins
Local commits appear to be working properly.
16
17
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
18
from breezy import (
5582.5.1 by John Arbash Meinel
Fix bug 701212. Don't set the tags for a master branch during update.
19
    branch,
2598.5.2 by Aaron Bentley
Got all tests passing with Branch returning 'null:' for null revision
20
    errors,
21
    revision as _mod_revision,
5582.5.1 by John Arbash Meinel
Fix bug 701212. Don't set the tags for a master branch during update.
22
    tests,
2598.5.2 by Aaron Bentley
Got all tests passing with Branch returning 'null:' for null revision
23
    )
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
24
from breezy.tests import per_branch
1587.1.11 by Robert Collins
Local commits appear to be working properly.
25
26
27
"""Tests for branch.update()"""
28
29
5010.2.22 by Vincent Ladeuil
Fix imports in per_branch/test_update.py.
30
class TestUpdate(per_branch.TestCaseWithBranch):
1587.1.11 by Robert Collins
Local commits appear to be working properly.
31
32
    def test_update_unbound_works(self):
33
        b = self.make_branch('.')
34
        b.update()
2598.5.4 by Aaron Bentley
Restore original Branch.last_revision behavior, fix bits that care
35
        self.assertEqual(_mod_revision.NULL_REVISION,
36
                         _mod_revision.ensure_null(b.last_revision()))
1587.1.11 by Robert Collins
Local commits appear to be working properly.
37
38
    def test_update_prefix_returns_none(self):
39
        # update in a branch when its a prefix of the master should
40
        # indicate that no local changes were present.
41
        master_tree = self.make_branch_and_tree('master')
42
        child_tree = self.make_branch_and_tree('child')
43
        try:
44
            child_tree.branch.bind(master_tree.branch)
45
        except errors.UpgradeRequired:
46
            # old branch, cant test.
47
            return
48
        # commit to the child to make the last rev not-None.
6855.4.1 by Jelmer Vernooij
Yet more bees.
49
        child_tree.commit('foo', rev_id=b'foo', allow_pointless=True)
1587.1.11 by Robert Collins
Local commits appear to be working properly.
50
        # update the master so we can commit there.
51
        master_tree.update()
52
        # commit to the master making the child tree out of date and a prefix.
6855.4.1 by Jelmer Vernooij
Yet more bees.
53
        master_tree.commit('bar', rev_id=b'bar', allow_pointless=True)
1587.1.11 by Robert Collins
Local commits appear to be working properly.
54
        self.assertEqual(None, child_tree.branch.update())
55
56
    def test_update_local_commits_returns_old_tip(self):
57
        # update in a branch when its not a prefix of the master should
58
        # return the previous tip and reset the revision history.
59
        master_tree = self.make_branch_and_tree('master')
60
        child_tree = self.make_branch_and_tree('child')
61
        try:
62
            child_tree.branch.bind(master_tree.branch)
63
        except errors.UpgradeRequired:
64
            # old branch, cant test.
65
            return
66
        # commit to the child to make the last rev not-None and skew it from master.
7143.15.2 by Jelmer Vernooij
Run autopep8.
67
        child_tree.commit('foo', rev_id=b'foo',
68
                          allow_pointless=True, local=True)
1587.1.11 by Robert Collins
Local commits appear to be working properly.
69
        # commit to the master making the child tree out of date and not a prefix.
6855.4.1 by Jelmer Vernooij
Yet more bees.
70
        master_tree.commit('bar', rev_id=b'bar', allow_pointless=True)
7045.1.1 by Jelmer Vernooij
Fix another 300 tests.
71
        self.assertEqual(b'foo', child_tree.branch.update())
72
        self.assertEqual(b'bar', child_tree.branch.last_revision())
3445.1.5 by John Arbash Meinel
allow passing a 'graph' object into Branch.update_revisions.
73
5582.5.1 by John Arbash Meinel
Fix bug 701212. Don't set the tags for a master branch during update.
74
    def test_update_in_checkout_of_readonly(self):
75
        tree1 = self.make_branch_and_tree('tree1')
76
        rev1 = tree1.commit('one')
77
        try:
78
            tree1.branch.tags.set_tag('test-tag', rev1)
79
        except errors.TagsNotSupported:
80
            # Tags not supported
81
            raise tests.TestNotApplicable("only triggered from branches with"
7143.15.2 by Jelmer Vernooij
Run autopep8.
82
                                          " tags")
5582.5.1 by John Arbash Meinel
Fix bug 701212. Don't set the tags for a master branch during update.
83
        readonly_branch1 = branch.Branch.open('readonly+' + tree1.branch.base)
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
84
        tree2 = tree1.controldir.sprout('tree2').open_workingtree()
5582.5.1 by John Arbash Meinel
Fix bug 701212. Don't set the tags for a master branch during update.
85
        try:
86
            tree2.branch.bind(readonly_branch1)
87
        except errors.UpgradeRequired:
88
            # old branch, cant test.
89
            raise tests.TestNotApplicable("only triggered in bound branches")
90
        rev2 = tree1.commit('two')
91
        tree2.update()
92
        self.assertEqual(rev2, tree2.branch.last_revision())