/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 bzrlib/tests/test_revprops.py

  • Committer: Michael Ellerman
  • Date: 2006-05-31 08:44:29 UTC
  • mto: (1711.2.63 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1792.
  • Revision ID: michael@ellerman.id.au-20060531084429-35e5429abda9f560
Add optional location to ancestry and fix behaviour for checkouts.

This adds an optional location parameter to the ancestry command. It also
changes the behaviour of ancestry on checkouts such that if they have
been created with a subset of the branch history, only the subset is
shown by 'bzr ancestry'. Tests for all of that as well.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
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
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
1
# (C) 2005 Canonical
16
2
 
17
3
"""Tests for revision properties."""
18
4
 
19
 
from bzrlib.tests.per_repository import (
20
 
    TestCaseWithRepository,
21
 
    )
 
5
from bzrlib.tests import TestCaseWithTransport
22
6
 
23
 
class TestRevProps(TestCaseWithRepository):
 
7
class TestRevProps(TestCaseWithTransport):
24
8
 
25
9
    def test_simple_revprops(self):
26
10
        """Simple revision properties"""
27
11
        wt = self.make_branch_and_tree('.')
28
12
        b = wt.branch
29
13
        b.nick = 'Nicholas'
30
 
        props = dict(flavor='choc-mint',
31
 
                     condiment='orange\n  mint\n\tcandy',
32
 
                     empty='',
33
 
                     non_ascii=u'\xb5')
34
 
        wt.commit(message='initial null commit',
 
14
        props = dict(flavor='choc-mint', 
 
15
                     condiment='orange\n  mint\n\tcandy')
 
16
        wt.commit(message='initial null commit', 
35
17
                 revprops=props,
36
18
                 allow_pointless=True,
37
19
                 rev_id='test@user-1')
38
20
        rev = b.repository.get_revision('test@user-1')
39
21
        self.assertTrue('flavor' in rev.properties)
40
22
        self.assertEquals(rev.properties['flavor'], 'choc-mint')
41
 
        self.assertEquals([('branch-nick', 'Nicholas'),
 
23
        self.assertEquals(sorted(rev.properties.items()),
 
24
                          [('branch-nick', 'Nicholas'), 
42
25
                           ('condiment', 'orange\n  mint\n\tcandy'),
43
 
                           ('empty', ''),
44
 
                           ('flavor', 'choc-mint'),
45
 
                           ('non_ascii', u'\xb5'),
46
 
                          ], sorted(rev.properties.items()))
 
26
                           ('flavor', 'choc-mint')])
47
27
 
48
28
    def test_invalid_revprops(self):
49
29
        """Invalid revision properties"""
50
30
        wt = self.make_branch_and_tree('.')
51
31
        b = wt.branch
52
32
        self.assertRaises(ValueError,
53
 
                          wt.commit,
 
33
                          wt.commit, 
54
34
                          message='invalid',
55
35
                          revprops={'what a silly property': 'fine'})
56
36
        self.assertRaises(ValueError,
57
 
                          wt.commit,
 
37
                          wt.commit, 
58
38
                          message='invalid',
59
39
                          revprops=dict(number=13))
60
 
 
61
 
 
62
 
class TestRevisionAttributes(TestCaseWithRepository):
63
 
    """Test that revision attributes are correct."""
64
 
 
65
 
    def test_revision_accessors(self):
66
 
        """Make sure the values that come out of a revision are the
67
 
        same as the ones that go in.
68
 
        """
69
 
        tree1 = self.make_branch_and_tree("br1")
70
 
 
71
 
        # create a revision
72
 
        tree1.commit(message="quux", allow_pointless=True, committer="jaq",
73
 
                     revprops={'empty':'',
74
 
                               'value':'one',
75
 
                               'unicode':u'\xb5',
76
 
                               'multiline':'foo\nbar\n\n'
77
 
                              })
78
 
        self.assertTrue(len(tree1.branch.revision_history()) > 0)
79
 
        rev_a = tree1.branch.repository.get_revision(
80
 
                            tree1.branch.last_revision())
81
 
 
82
 
        tree2 = self.make_branch_and_tree("br2")
83
 
        tree2.commit(message=rev_a.message,
84
 
                     timestamp=rev_a.timestamp,
85
 
                     timezone=rev_a.timezone,
86
 
                     committer=rev_a.committer,
87
 
                     rev_id=rev_a.revision_id,
88
 
                     revprops=rev_a.properties,
89
 
                     allow_pointless=True, # there's nothing in this commit
90
 
                     strict=True,
91
 
                     verbose=True)
92
 
        rev_b = tree2.branch.repository.get_revision(
93
 
                            tree2.branch.last_revision())
94
 
 
95
 
        self.assertEqual(rev_a.message, rev_b.message)
96
 
        self.assertEqual(rev_a.timestamp, rev_b.timestamp)
97
 
        self.assertEqual(rev_a.timezone, rev_b.timezone)
98
 
        self.assertEqual(rev_a.committer, rev_b.committer)
99
 
        self.assertEqual(rev_a.revision_id, rev_b.revision_id)
100
 
        self.assertEqual(rev_a.properties, rev_b.properties)
101
 
 
102
 
    def test_zero_timezone(self):
103
 
        tree1 = self.make_branch_and_tree("br1")
104
 
 
105
 
        # create a revision
106
 
        tree1.commit(message="quux", timezone=0, rev_id='r1')
107
 
        rev_a = tree1.branch.repository.get_revision('r1')
108
 
        self.assertEqual(0, rev_a.timezone)