~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__dirstate_helpers.py

  • Committer: Andrew Bennetts
  • Date: 2010-01-18 07:00:11 UTC
  • mto: (4973.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4975.
  • Revision ID: andrew.bennetts@canonical.com-20100118070011-zu374wvd0lcgai5a
Move news_merge plugin from contrib to bzrlib/plugins, change it to be enabled via a 'news_merge_files' config option, move more code out of the __init__ to minimise overhead, and add lots of docstrings, add NEWS entry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2007, 2008, 2009 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
737
737
 
738
738
    def test_trailing_garbage(self):
739
739
        tree, state, expected = self.create_basic_dirstate()
740
 
        # On Unix, we can write extra data as long as we haven't read yet, but
 
740
        # On Linux, we can write extra data as long as we haven't read yet, but
741
741
        # on Win32, if you've opened the file with FILE_SHARE_READ, trying to
742
742
        # open it in append mode will fail.
743
743
        state.unlock()
831
831
 
832
832
    def setUp(self):
833
833
        super(TestUpdateEntry, self).setUp()
834
 
        self.overrideAttr(dirstate, 'update_entry', self.update_entry)
 
834
        orig = dirstate.update_entry
 
835
        def cleanup():
 
836
            dirstate.update_entry = orig
 
837
        self.addCleanup(cleanup)
 
838
        dirstate.update_entry = self.update_entry
835
839
 
836
840
    def get_state_with_a(self):
837
841
        """Create a DirState tracking a single object named 'a'"""
1274
1278
 
1275
1279
    def setUp(self):
1276
1280
        super(TestProcessEntry, self).setUp()
1277
 
        self.overrideAttr(dirstate, '_process_entry', self._process_entry)
 
1281
        orig = dirstate._process_entry
 
1282
        def cleanup():
 
1283
            dirstate._process_entry = orig
 
1284
        self.addCleanup(cleanup)
 
1285
        dirstate._process_entry = self._process_entry
1278
1286
 
1279
1287
    def assertChangedFileIds(self, expected, tree):
1280
1288
        tree.lock_read()
1289
1297
        # This is a direct test of bug #495023, it relies on osutils.is_inside
1290
1298
        # getting called in an inner function. Which makes it a bit brittle,
1291
1299
        # but at least it does reproduce the bug.
 
1300
        def is_inside_raises(*args, **kwargs):
 
1301
            raise RuntimeError('stop this')
1292
1302
        tree = self.make_branch_and_tree('tree')
1293
1303
        self.build_tree(['tree/file', 'tree/dir/', 'tree/dir/sub',
1294
1304
                         'tree/dir2/', 'tree/dir2/sub2'])
1297
1307
        tree.lock_read()
1298
1308
        self.addCleanup(tree.unlock)
1299
1309
        basis_tree = tree.basis_tree()
1300
 
        def is_inside_raises(*args, **kwargs):
1301
 
            raise RuntimeError('stop this')
1302
 
        self.overrideAttr(osutils, 'is_inside', is_inside_raises)
 
1310
        orig = osutils.is_inside
 
1311
        self.addCleanup(setattr, osutils, 'is_inside', orig)
 
1312
        osutils.is_inside = is_inside_raises
1303
1313
        self.assertListRaises(RuntimeError, tree.iter_changes, basis_tree)
1304
1314
 
1305
1315
    def test_simple_changes(self):