~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_workingtree/test_workingtree.py

  • Committer: Patch Queue Manager
  • Date: 2012-01-28 13:24:39 UTC
  • mfrom: (6450.1.1 bzr.dev)
  • Revision ID: pqm@pqm.ubuntu.com-20120128132439-phvlss4cq7bf5rji
(jelmer) Merge the 2.5 branch. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
175
175
        tree = self.make_branch_and_tree('.')
176
176
 
177
177
        self.build_tree(['hello.txt'])
178
 
        file('hello.txt', 'w').write('initial hello')
 
178
        with file('hello.txt', 'w') as f: f.write('initial hello')
179
179
 
180
180
        self.assertRaises(PathsNotVersionedError,
181
181
                          tree.revert, ['hello.txt'])
183
183
        tree.commit('create initial hello.txt')
184
184
 
185
185
        self.check_file_contents('hello.txt', 'initial hello')
186
 
        file('hello.txt', 'w').write('new hello')
 
186
        with file('hello.txt', 'w') as f: f.write('new hello')
187
187
        self.check_file_contents('hello.txt', 'new hello')
188
188
 
189
189
        # revert file modified since last revision
197
197
        self.check_file_contents('hello.txt.~1~', 'new hello')
198
198
 
199
199
        # backup files are numbered
200
 
        file('hello.txt', 'w').write('new hello2')
 
200
        with file('hello.txt', 'w') as f: f.write('new hello2')
201
201
        tree.revert(['hello.txt'])
202
202
        self.check_file_contents('hello.txt', 'initial hello')
203
203
        self.check_file_contents('hello.txt.~1~', 'new hello')
206
206
    def test_revert_missing(self):
207
207
        # Revert a file that has been deleted since last commit
208
208
        tree = self.make_branch_and_tree('.')
209
 
        file('hello.txt', 'w').write('initial hello')
 
209
        with file('hello.txt', 'w') as f: f.write('initial hello')
210
210
        tree.add('hello.txt')
211
211
        tree.commit('added hello.txt')
212
212
        os.unlink('hello.txt')
708
708
    def make_merge_conflicts(self):
709
709
        from bzrlib.merge import merge_inner
710
710
        tree = self.make_branch_and_tree('mine')
711
 
        file('mine/bloo', 'wb').write('one')
712
 
        file('mine/blo', 'wb').write('on')
 
711
        with file('mine/bloo', 'wb') as f: f.write('one')
 
712
        with file('mine/blo', 'wb') as f: f.write('on')
713
713
        tree.add(['bloo', 'blo'])
714
714
        tree.commit("blah", allow_pointless=False)
715
715
        base = tree.branch.repository.revision_tree(tree.last_revision())
716
716
        bzrdir.BzrDir.open("mine").sprout("other")
717
 
        file('other/bloo', 'wb').write('two')
 
717
        with file('other/bloo', 'wb') as f: f.write('two')
718
718
        othertree = WorkingTree.open('other')
719
719
        othertree.commit('blah', allow_pointless=False)
720
 
        file('mine/bloo', 'wb').write('three')
 
720
        with file('mine/bloo', 'wb') as f: f.write('three')
721
721
        tree.commit("blah", allow_pointless=False)
722
722
        merge_inner(tree.branch, othertree, base, this_tree=tree)
723
723
        return tree