~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_missing.py

  • Committer: John Arbash Meinel
  • Date: 2006-01-05 18:22:07 UTC
  • mto: (1685.1.1 bzr-encoding)
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: john@arbash-meinel.com-20060105182207-6bcbd3f47036cfb3
Added Copyright, changed test_missing to use run_bzr instead of capture.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2005 by Canonical Ltd
 
2
# -*- coding: utf-8 -*-
 
3
# vim: encoding=utf-8
 
4
 
 
5
# This program is free software; you can redistribute it and/or modify
 
6
# it under the terms of the GNU General Public License as published by
 
7
# the Free Software Foundation; either version 2 of the License, or
 
8
# (at your option) any later version.
 
9
 
 
10
# This program is distributed in the hope that it will be useful,
 
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
# GNU General Public License for more details.
 
14
 
 
15
# You should have received a copy of the GNU General Public License
 
16
# along with this program; if not, write to the Free Software
 
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1
18
"""Black-box tests for bzr missing.
2
19
"""
3
20
 
8
25
 
9
26
class TestMissing(TestCaseInTempDir):
10
27
    def test_missing(self):
 
28
        def bzr(*args, **kwargs):
 
29
            return self.run_bzr(*args, **kwargs)[0]
11
30
        missing = "You are missing 1 revision(s):"
12
31
 
13
32
        # create a source branch
14
33
        os.mkdir('a')
15
34
        os.chdir('a')
16
 
        self.capture('init')
 
35
        bzr('init')
17
36
        open('a', 'wb').write('initial\n')
18
 
        self.capture('add a')
19
 
        self.capture('commit -m inital')
 
37
        bzr('add', 'a')
 
38
        bzr('commit', '-m', 'inital')
20
39
 
21
40
        # clone and add a differing revision
22
 
        self.capture('branch . ../b')
 
41
        bzr('branch', '.', '../b')
23
42
        os.chdir('../b')
24
43
        open('a', 'ab').write('more\n')
25
 
        self.capture('commit -m more')
 
44
        bzr('commit', '-m', 'more')
26
45
 
27
46
        # compare a against b
28
47
        os.chdir('../a')
29
 
        lines = self.capture('missing ../b', retcode=1).splitlines()
 
48
        lines = bzr('missing', '../b', retcode=1).splitlines()
30
49
        # we're missing the extra revision here
31
50
        self.assertEqual(missing, lines[0])
32
51
        self.assertEqual(8, len(lines))
33
52
 
34
53
        # get extra revision from b
35
 
        self.capture('merge ../b')
36
 
        self.capture('commit -m merge')
 
54
        bzr('merge', '../b')
 
55
        bzr('commit', '-m', 'merge')
37
56
 
38
57
        # compare again, but now we have the 'merge' commit extra
39
 
        lines = self.capture('missing ../b', retcode=1).splitlines()
 
58
        lines = bzr('missing', '../b', retcode=1).splitlines()
40
59
        self.assertEqual("You have 1 extra revision(s):", lines[0])
41
60
        self.assertEqual(8, len(lines))
42
 
        lines2 = self.capture('missing ../b --mine-only', retcode=1)
 
61
        lines2 = bzr('missing', '../b', '--mine-only', retcode=1)
43
62
        lines2 = lines2.splitlines()
44
63
        self.assertEqual(lines, lines2)
45
 
        lines3 = self.capture('missing ../b --theirs-only', retcode=1)
 
64
        lines3 = bzr('missing', '../b', '--theirs-only', retcode=1)
46
65
        lines3 = lines3.splitlines()
47
66
        self.assertEqual(0, len(lines3))
48
67
 
49
68
        # relative to a, missing the 'merge' commit 
50
69
        os.chdir('../b')
51
 
        lines = self.capture('missing ../a', retcode=1).splitlines()
 
70
        lines = bzr('missing', '../a', retcode=1).splitlines()
52
71
        self.assertEqual(missing, lines[0])
53
72
        self.assertEqual(8, len(lines))
54
 
        lines2 = self.capture('missing ../a --theirs-only', retcode=1)
 
73
        lines2 = bzr('missing', '../a', '--theirs-only', retcode=1)
55
74
        lines2 = lines2.splitlines()
56
75
        self.assertEqual(lines, lines2)
57
 
        lines3 = self.capture('missing ../a --mine-only', retcode=1)
 
76
        lines3 = bzr('missing', '../a', '--mine-only', retcode=1)
58
77
        lines3 = lines3.splitlines()
59
78
        self.assertEqual(0, len(lines3))
60
 
        lines4 = self.capture('missing ../a --short', retcode=1)
 
79
        lines4 = bzr('missing', '../a', '--short', retcode=1)
61
80
        lines4 = lines4.splitlines()
62
81
        self.assertEqual(4, len(lines4))
63
 
        lines5 = self.capture('missing ../a --line', retcode=1)
 
82
        lines5 = bzr('missing', '../a', '--line', retcode=1)
64
83
        lines5 = lines5.splitlines()
65
84
        self.assertEqual(2, len(lines5))
66
 
        lines6 = self.capture('missing ../a --reverse', retcode=1)
 
85
        lines6 = bzr('missing', '../a', '--reverse', retcode=1)
67
86
        lines6 = lines6.splitlines()
68
87
        self.assertEqual(lines6, lines)
69
 
        lines7 = self.capture('missing ../a --show-ids', retcode=1)
 
88
        lines7 = bzr('missing', '../a', '--show-ids', retcode=1)
70
89
        lines7 = lines7.splitlines()
71
90
        self.assertEqual(11, len(lines7))
72
 
        lines8 = self.capture('missing ../a --verbose', retcode=1)
 
91
        lines8 = bzr('missing', '../a', '--verbose', retcode=1)
73
92
        lines8 = lines8.splitlines()
74
93
        self.assertEqual("modified:", lines8[-2])
75
94
        self.assertEqual("  a", lines8[-1])
76
95
 
77
96
        
78
97
        # after a pull we're back on track
79
 
        self.capture('pull')
 
98
        bzr('pull')
80
99
        self.assertEqual("Branches are up to date.\n", 
81
 
                         self.capture('missing ../a'))
 
100
                         bzr('missing', '../a'))
82
101