~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2006-01-06 01:13:05 UTC
  • mfrom: (1534.1.4 integration)
  • Revision ID: mbp@sourcefrog.net-20060106011305-3772285d84b5cbb4
[merge] robertc

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""Black-box tests for bzr missing.
 
2
"""
 
3
 
 
4
import os
 
5
 
 
6
from bzrlib.branch import Branch
 
7
from bzrlib.tests import TestCaseInTempDir
 
8
 
 
9
class TestMissing(TestCaseInTempDir):
 
10
    def test_missing(self):
 
11
        missing = "You are missing 1 revision(s):"
 
12
 
 
13
        # create a source branch
 
14
        os.mkdir('a')
 
15
        os.chdir('a')
 
16
        self.capture('init')
 
17
        open('a', 'wb').write('initial\n')
 
18
        self.capture('add a')
 
19
        self.capture('commit -m inital')
 
20
 
 
21
        # clone and add a differing revision
 
22
        self.capture('branch . ../b')
 
23
        os.chdir('../b')
 
24
        open('a', 'ab').write('more\n')
 
25
        self.capture('commit -m more')
 
26
 
 
27
        # compare a against b
 
28
        os.chdir('../a')
 
29
        lines = self.capture('missing ../b', retcode=1).splitlines()
 
30
        # we're missing the extra revision here
 
31
        self.assertEqual(missing, lines[0])
 
32
        self.assertEqual(8, len(lines))
 
33
 
 
34
        # get extra revision from b
 
35
        self.capture('merge ../b')
 
36
        self.capture('commit -m merge')
 
37
 
 
38
        # compare again, but now we have the 'merge' commit extra
 
39
        lines = self.capture('missing ../b', retcode=1).splitlines()
 
40
        self.assertEqual("You have 1 extra revision(s):", lines[0])
 
41
        self.assertEqual(8, len(lines))
 
42
        lines2 = self.capture('missing ../b --mine-only', retcode=1)
 
43
        lines2 = lines2.splitlines()
 
44
        self.assertEqual(lines, lines2)
 
45
        lines3 = self.capture('missing ../b --theirs-only', retcode=1)
 
46
        lines3 = lines3.splitlines()
 
47
        self.assertEqual(0, len(lines3))
 
48
 
 
49
        # relative to a, missing the 'merge' commit 
 
50
        os.chdir('../b')
 
51
        lines = self.capture('missing ../a', retcode=1).splitlines()
 
52
        self.assertEqual(missing, lines[0])
 
53
        self.assertEqual(8, len(lines))
 
54
        lines2 = self.capture('missing ../a --theirs-only', retcode=1)
 
55
        lines2 = lines2.splitlines()
 
56
        self.assertEqual(lines, lines2)
 
57
        lines3 = self.capture('missing ../a --mine-only', retcode=1)
 
58
        lines3 = lines3.splitlines()
 
59
        self.assertEqual(0, len(lines3))
 
60
        lines4 = self.capture('missing ../a --short', retcode=1)
 
61
        lines4 = lines4.splitlines()
 
62
        self.assertEqual(4, len(lines4))
 
63
        lines5 = self.capture('missing ../a --line', retcode=1)
 
64
        lines5 = lines5.splitlines()
 
65
        self.assertEqual(2, len(lines5))
 
66
        lines6 = self.capture('missing ../a --reverse', retcode=1)
 
67
        lines6 = lines6.splitlines()
 
68
        self.assertEqual(lines6, lines)
 
69
        lines7 = self.capture('missing ../a --show-ids', retcode=1)
 
70
        lines7 = lines7.splitlines()
 
71
        self.assertEqual(11, len(lines7))
 
72
        lines8 = self.capture('missing ../a --verbose', retcode=1)
 
73
        lines8 = lines8.splitlines()
 
74
        self.assertEqual("modified:", lines8[-2])
 
75
        self.assertEqual("  a", lines8[-1])
 
76
 
 
77
        
 
78
        # after a pull we're back on track
 
79
        self.capture('pull')
 
80
        self.assertEqual("Branches are up to date.\n", 
 
81
                         self.capture('missing ../a'))
 
82