/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.8.1 by John Arbash Meinel
Creating a plugin to ease generating version information from a tree.
1
# Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
17
"""\
18
Tests for version_info
19
"""
20
21
import os
22
23
from bzrlib.tests import TestCase, TestCaseInTempDir
24
from bzrlib.branch import Branch
25
26
# TODO: jam 20051228 When part of bzrlib, this should become
27
#       from bzrlib.generate_version_info import foo
28
29
from generate_version_info import is_clean
30
from errors import UncleanError
31
32
33
class TestIsClean(TestCaseInTempDir):
34
35
    # TODO: jam 20051228 Test that a branch without a working tree
36
    #       is clean. This would be something like an SFTP test
37
38
    def test_is_clean(self):
39
        b = Branch.initialize('.')
40
        wt = b.working_tree()
41
42
        def not_clean(b):
0.8.3 by John Arbash Meinel
Playing around with some formats
43
            clean, message = is_clean(b)
44
            if clean:
45
                self.fail('Tree should not be clean')
46
47
        def check_clean(b):
48
            clean, message = is_clean(b)
49
            if not clean:
50
                self.fail(message)
0.8.1 by John Arbash Meinel
Creating a plugin to ease generating version information from a tree.
51
52
        # Nothing happened yet
0.8.3 by John Arbash Meinel
Playing around with some formats
53
        check_clean(b)
0.8.1 by John Arbash Meinel
Creating a plugin to ease generating version information from a tree.
54
55
        # Unknown file
56
        open('a', 'wb').write('a file\n')
57
        not_clean(b)
58
        
59
        # Newly added file
60
        wt.add('a')
61
        not_clean(b)
62
63
        # We committed, things are clean
64
        wt.commit('added a')
0.8.3 by John Arbash Meinel
Playing around with some formats
65
        check_clean(b)
0.8.1 by John Arbash Meinel
Creating a plugin to ease generating version information from a tree.
66
67
        # Unknown
68
        open('b', 'wb').write('b file\n')
69
        not_clean(b)
70
71
        wt.add('b')
72
        not_clean(b)
73
74
        wt.commit('added b')
0.8.3 by John Arbash Meinel
Playing around with some formats
75
        check_clean(b)
0.8.1 by John Arbash Meinel
Creating a plugin to ease generating version information from a tree.
76
77
        open('a', 'wb').write('different\n')
78
        not_clean(b)
79
80
        wt.commit('mod a')
0.8.3 by John Arbash Meinel
Playing around with some formats
81
        check_clean(b)
0.8.1 by John Arbash Meinel
Creating a plugin to ease generating version information from a tree.
82
83
        os.remove('a')
84
        not_clean(b)
85
86
        wt.commit('del a')
0.8.3 by John Arbash Meinel
Playing around with some formats
87
        check_clean(b)
0.8.1 by John Arbash Meinel
Creating a plugin to ease generating version information from a tree.
88
89
        wt.rename_one('b', 'a')
90
        not_clean(b)
91
92
        wt.commit('rename b => a')
0.8.3 by John Arbash Meinel
Playing around with some formats
93
        check_clean(b)
0.8.1 by John Arbash Meinel
Creating a plugin to ease generating version information from a tree.
94
95
96
class TestVersionInfo(TestCaseInTempDir):
97
    pass
98