~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests/test_rspush.py

  • Committer: Aaron Bentley
  • Date: 2008-01-11 03:01:54 UTC
  • Revision ID: aaron.bentley@utoronto.ca-20080111030154-apm50v0b0tu93prh
Support branch6 formats in rspush

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
 
 
18
import os
 
19
 
18
20
from bzrlib.bzrdir import BzrDir
19
 
from bzrlib.tests import TestCaseWithTransport
 
21
from bzrlib.tests import TestCaseWithTransport, TestSkipped
20
22
 
21
 
from bzrlib.plugins.bzrtools.bzrtools import rspush, NotStandalone
 
23
from bzrlib.plugins.bzrtools.bzrtools import (
 
24
    history_subset,
 
25
    NoRsync,
 
26
    NotStandalone,
 
27
    rspush,
 
28
    rsync,
 
29
    RsyncNoFile,
 
30
)
22
31
 
23
32
 
24
33
class MockRSync(object):
35
44
 
36
45
class TestRSPush(TestCaseWithTransport):
37
46
 
 
47
    def test_rsync(self):
 
48
        cwd = os.getcwd()
 
49
        try:
 
50
            self.assertRaises(RsyncNoFile, rsync, "a", "b", silent=True)
 
51
        except NoRsync:
 
52
            raise TestSkipped('rsync not installed')
 
53
        self.assertRaises(RsyncNoFile, rsync, cwd + "/a", cwd + "/b",
 
54
                          excludes=("*.py",), silent=True)
 
55
        self.assertRaises(NoRsync, rsync, cwd + "/a", cwd + "/b",
 
56
                          excludes=("*.py",), silent=True,
 
57
                          rsync_name="rsyncc")
 
58
 
38
59
    def test_rspush_locking(self):
39
60
        tree = self.make_branch_and_tree('tree', format='dirstate-tags')
40
61
        tree.commit('some changes')
72
93
        mock_rsync = MockRSync()
73
94
        self.assertRaises(NotStandalone, rspush, tree, 'example.org:foo',
74
95
                          _rsync=mock_rsync)
 
96
 
 
97
    def do_history_subset(self, format):
 
98
        tree_a = self.make_branch_and_tree('tree_a', format=format)
 
99
        tree_a.lock_write()
 
100
        self.addCleanup(tree_a.unlock)
 
101
        tree_a.commit('foo')
 
102
        tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree()
 
103
        tree_a.commit('bar')
 
104
        try:
 
105
            self.assertTrue(history_subset('tree_b/', tree_a.branch))
 
106
        except NoRsync:
 
107
            raise TestSkipped('rsync not installed')
 
108
        self.assertFalse(history_subset('tree_a/', tree_b.branch))
 
109
 
 
110
    def do_history_subset_no_commits(self, format):
 
111
        tree_a = self.make_branch_and_tree('tree_a', format=format)
 
112
        tree_b = self.make_branch_and_tree('tree_b', format=format)
 
113
        try:
 
114
            self.assertTrue(history_subset('tree_b/', tree_a.branch))
 
115
        except NoRsync:
 
116
            raise TestSkipped('rsync not installed')
 
117
 
 
118
    def test_history_subset_dirstate(self):
 
119
        self.do_history_subset('dirstate')
 
120
 
 
121
    def test_history_subset_no_commits_dirstate(self):
 
122
        self.do_history_subset_no_commits('dirstate')
 
123
 
 
124
    def test_history_subset_pack(self):
 
125
        self.do_history_subset('pack-0.92')
 
126
 
 
127
    def test_history_subset_no_commits_pack(self):
 
128
        self.do_history_subset_no_commits('pack-0.92')