~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Patch Queue Manager
  • Date: 2016-02-01 19:56:05 UTC
  • mfrom: (6615.1.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20160201195605-o7rl92wf6uyum3fk
(vila) Open trunk again as 2.8b1 (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2007 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2009, 2010, 2011, 2016 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
19
19
import os
20
20
 
21
21
import bzrlib.osutils
22
 
from bzrlib.tests.blackbox import ExternalBase
 
22
from bzrlib.tests import TestCaseWithTransport
23
23
from bzrlib.trace import mutter
24
24
from bzrlib.workingtree import WorkingTree
25
25
 
26
26
 
27
 
class TestRevert(ExternalBase):
 
27
class TestRevert(TestCaseWithTransport):
28
28
 
29
29
    def _prepare_tree(self):
30
30
        self.run_bzr('init')
43
43
        f.close()
44
44
 
45
45
        # check status
46
 
        self.assertEquals('modified:\n  dir/file\n', self.run_bzr('status')[0])
 
46
        self.assertEqual('modified:\n  dir/file\n', self.run_bzr('status')[0])
47
47
 
48
48
    def _prepare_rename_mod_tree(self):
49
49
        self.build_tree(['a/', 'a/b', 'a/c', 'a/d/', 'a/d/e', 'f/', 'f/g',
66
66
        os.chdir('dir')
67
67
        mutter('cd dir\n')
68
68
 
69
 
        self.assertEquals('1\n', self.run_bzr('revno')[0])
 
69
        self.assertEqual('1\n', self.run_bzr('revno')[0])
70
70
        self.run_bzr('revert %s file' % param)
71
 
        self.assertEquals('spam', open('file', 'rb').read())
 
71
        self.assertEqual('spam', open('file', 'rb').read())
72
72
 
73
73
    def test_revert_in_subdir(self):
74
74
        self.helper()
93
93
        """Test that revert DIRECTORY does what's expected"""
94
94
        self._prepare_rename_mod_tree()
95
95
        self.run_bzr('revert a')
96
 
        self.failUnlessExists('a/b')
97
 
        self.failUnlessExists('a/d')
98
 
        self.failIfExists('a/g')
 
96
        self.assertPathExists('a/b')
 
97
        self.assertPathExists('a/d')
 
98
        self.assertPathDoesNotExist('a/g')
99
99
        self.expectFailure(
100
100
            "j is in the delta revert applies because j was renamed too",
101
 
            self.failUnlessExists, 'j')
102
 
        self.failUnlessExists('h')
 
101
            self.assertPathExists, 'j')
 
102
        self.assertPathExists('h')
103
103
        self.run_bzr('revert f')
104
 
        self.failIfExists('j')
105
 
        self.failIfExists('h')
106
 
        self.failUnlessExists('a/d/e')
 
104
        self.assertPathDoesNotExist('j')
 
105
        self.assertPathDoesNotExist('h')
 
106
        self.assertPathExists('a/d/e')
107
107
 
108
108
    def test_revert_chatter(self):
109
109
        self._prepare_rename_mod_tree()
120
120
    def test_revert(self):
121
121
        self.run_bzr('init')
122
122
 
123
 
        file('hello', 'wt').write('foo')
 
123
        with file('hello', 'wt') as f: f.write('foo')
124
124
        self.run_bzr('add hello')
125
125
        self.run_bzr('commit -m setup hello')
126
126
 
127
 
        file('goodbye', 'wt').write('baz')
 
127
        with file('goodbye', 'wt') as f: f.write('baz')
128
128
        self.run_bzr('add goodbye')
129
129
        self.run_bzr('commit -m setup goodbye')
130
130
 
131
 
        file('hello', 'wt').write('bar')
132
 
        file('goodbye', 'wt').write('qux')
 
131
        with file('hello', 'wt') as f: f.write('bar')
 
132
        with file('goodbye', 'wt') as f: f.write('qux')
133
133
        self.run_bzr('revert hello')
134
134
        self.check_file_contents('hello', 'foo')
135
135
        self.check_file_contents('goodbye', 'qux')
148
148
            self.run_bzr('commit -m f')
149
149
            os.unlink('symlink')
150
150
            self.run_bzr('revert')
151
 
            self.failUnlessExists('symlink')
 
151
            self.assertPathExists('symlink')
152
152
            os.unlink('symlink')
153
153
            os.symlink('a-different-path', 'symlink')
154
154
            self.run_bzr('revert')
157
157
        else:
158
158
            self.log("skipping revert symlink tests")
159
159
 
160
 
        file('hello', 'wt').write('xyz')
 
160
        with file('hello', 'wt') as f: f.write('xyz')
161
161
        self.run_bzr('commit -m xyz hello')
162
162
        self.run_bzr('revert -r 1 hello')
163
163
        self.check_file_contents('hello', 'foo')
199
199
        first_rev_id = tree.commit('initial commit')
200
200
        self.build_tree_contents([('file', 'new content')])
201
201
        existing_parents = tree.get_parent_ids()
202
 
        self.assertEquals([first_rev_id], existing_parents)
 
202
        self.assertEqual([first_rev_id], existing_parents)
203
203
        merged_parents = existing_parents + ['merged-in-rev']
204
204
        tree.set_parent_ids(merged_parents)
205
 
        self.assertEquals(merged_parents, tree.get_parent_ids())
 
205
        self.assertEqual(merged_parents, tree.get_parent_ids())
206
206
        self.run_bzr(['revert', '--forget-merges'])
207
 
        self.assertEquals([first_rev_id], tree.get_parent_ids())
 
207
        self.assertEqual([first_rev_id], tree.get_parent_ids())
208
208
        # changed files are not reverted
209
209
        self.assertFileEqual('new content', 'file')
210
210
        # you can give it the path of a tree