/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/blackbox/test_inventory.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
        tree.commit('init', rev_id='one')
34
34
        self.tree = tree
35
35
 
36
 
    def assertInventoryEqual(self, expected, *args, **kwargs):
 
36
    def assertInventoryEqual(self, expected, args=None, **kwargs):
37
37
        """Test that the output of 'bzr inventory' is as expected.
38
38
 
39
39
        Any arguments supplied will be passed to run_bzr.
40
40
        """
41
 
        out, err = self.run_bzr('inventory', *args, **kwargs)
 
41
        command = 'inventory'
 
42
        if args is not None:
 
43
            command += ' ' + args
 
44
        out, err = self.run_bzr(command, **kwargs)
42
45
        self.assertEqual(expected, out)
43
46
        self.assertEqual('', err)
44
 
        
 
47
 
45
48
    def test_inventory(self):
46
49
        self.assertInventoryEqual('a\nb\nb/c\n')
47
50
 
48
51
    def test_inventory_kind(self):
49
 
        self.assertInventoryEqual('a\nb/c\n', '--kind', 'file')
50
 
        self.assertInventoryEqual('b\n', '--kind', 'directory')
 
52
        self.assertInventoryEqual('a\nb/c\n', '--kind file')
 
53
        self.assertInventoryEqual('b\n', '--kind directory')
51
54
 
52
55
    def test_inventory_show_ids(self):
53
56
        expected = ''.join(('%-50s %s\n' % (path, file_id))
61
64
 
62
65
    def test_inventory_specific_files(self):
63
66
        self.assertInventoryEqual('a\n', 'a')
64
 
        self.assertInventoryEqual('b\nb/c\n', 'b', 'b/c')
 
67
        self.assertInventoryEqual('b\nb/c\n', 'b b/c')
65
68
        # 'bzr inventory' recurses into subdirectories
66
69
        self.assertInventoryEqual('b\nb/c\n', 'b')
67
70
 
71
74
        b_line = '%-50s %s\n' % ('b', 'b-id')
72
75
        c_line = '%-50s %s\n' % ('b/c', 'c-id')
73
76
 
74
 
        self.assertInventoryEqual('', '--kind', 'directory', 'a')
75
 
        self.assertInventoryEqual(a_line + c_line, '--kind', 'file',
76
 
                                                   '--show-ids')
77
 
        self.assertInventoryEqual(c_line, '--kind', 'file', '--show-ids',
78
 
                                          'b', 'b/c')
 
77
        self.assertInventoryEqual('', '--kind directory a')
 
78
        self.assertInventoryEqual(a_line + c_line, '--kind file --show-ids')
 
79
        self.assertInventoryEqual(c_line, '--kind file --show-ids b b/c')
79
80
 
80
81
    def test_in_subdir(self):
81
82
        os.chdir('b')
97
98
        self.tree.commit('rename b/d => d')
98
99
 
99
100
        # Passing just -r returns the inventory of that revision
100
 
        self.assertInventoryEqual('a\nb\nb/c\n', '-r', '1')
101
 
        self.assertInventoryEqual('a\nb\nb/c\nb/d\ne\n', '-r', '2')
 
101
        self.assertInventoryEqual('a\nb\nb/c\n', '-r 1')
 
102
        self.assertInventoryEqual('a\nb\nb/c\nb/d\ne\n', '-r 2')
102
103
 
103
104
        # Passing a path will lookup the path in the old and current locations
104
 
        self.assertInventoryEqual('b/d\n', '-r', '2', 'b/d')
105
 
        self.assertInventoryEqual('b/d\n', '-r', '2', 'd')
 
105
        self.assertInventoryEqual('b/d\n', '-r 2 b/d')
 
106
        self.assertInventoryEqual('b/d\n', '-r 2 d')
106
107
 
107
108
        self.tree.rename_one('e', 'b/e')
108
109
        self.tree.commit('rename e => b/e')
109
110
 
110
111
        # When supplying just a directory paths that are now,
111
112
        # or used to be, in that directory are shown
112
 
        self.assertInventoryEqual('b\nb/c\nb/d\ne\n', '-r', '2', 'b')
 
113
        self.assertInventoryEqual('b\nb/c\nb/d\ne\n', '-r 2 b')
113
114
 
114
115
    def test_missing_file(self):
115
116
        self.run_bzr_error([r'Path\(s\) are not versioned: no-such-file'],
116
 
                           'inventory', 'no-such-file')
 
117
                           'inventory no-such-file')