~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/workingtree_implementations/test_parents.py

  • Committer: Matt Nordhoff
  • Date: 2009-04-04 02:50:01 UTC
  • mfrom: (4253 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4256.
  • Revision ID: mnordhoff@mattnordhoff.com-20090404025001-z1403k0tatmc8l91
Merge bzr.dev, fixing conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Tests of the parent related functions of WorkingTrees."""
18
18
 
24
24
    osutils,
25
25
    revision as _mod_revision,
26
26
    symbol_versioning,
 
27
    tests,
27
28
    )
28
29
from bzrlib.inventory import (
29
30
    Inventory,
32
33
    InventoryLink,
33
34
    )
34
35
from bzrlib.revision import Revision
35
 
from bzrlib.tests import (
36
 
    KnownFailure,
37
 
    SymlinkFeature,
38
 
    TestNotApplicable,
39
 
    UnicodeFilenameFeature,
40
 
    )
41
36
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
42
37
from bzrlib.uncommit import uncommit
43
38
 
234
229
 
235
230
    def test_unicode_symlink(self):
236
231
        # this tests bug #272444
237
 
        self.requireFeature(SymlinkFeature)
238
 
        self.requireFeature(UnicodeFilenameFeature)
 
232
        self.requireFeature(tests.SymlinkFeature)
 
233
        self.requireFeature(tests.UnicodeFilenameFeature)
239
234
 
240
235
        tree = self.make_branch_and_tree('tree1')
241
236
 
245
240
        os.symlink(u'\u03a9','tree1/link_name')
246
241
        tree.add(['link_name'],['link-id'])
247
242
 
248
 
        try:
249
 
            # the actual commit occurs without errors (strangely):
250
 
            revision1 = tree.commit('added a link to a Unicode target')
251
 
            # python 2.4 failed with UnicodeDecodeError on this commit:
252
 
            revision2 = tree.commit('this revision will be discarded')
253
 
            # python 2.5 failed with UnicodeEncodeError on set_parent_ids:
254
 
            tree.set_parent_ids([revision1])
255
 
        except (UnicodeEncodeError, UnicodeDecodeError):
256
 
            raise KnownFailure('there is no support for'
257
 
                               ' symlinks to non-ASCII targets (bug #272444)')
 
243
        revision1 = tree.commit('added a link to a Unicode target')
 
244
        revision2 = tree.commit('this revision will be discarded')
 
245
        tree.set_parent_ids([revision1])
258
246
 
259
247
 
260
248
class TestAddParent(TestParents):
266
254
        uncommit(tree.branch, tree=tree)
267
255
        tree.add_parent_tree_id(first_revision)
268
256
        self.assertConsistentParents([first_revision], tree)
269
 
        
 
257
 
270
258
    def test_add_first_parent_id_ghost_rejects(self):
271
259
        """Test adding the first parent id - as a ghost"""
272
260
        tree = self.make_branch_and_tree('.')
273
261
        self.assertRaises(errors.GhostRevisionUnusableHere,
274
262
            tree.add_parent_tree_id, 'first-revision')
275
 
        
 
263
 
276
264
    def test_add_first_parent_id_ghost_force(self):
277
265
        """Test adding the first parent id - as a ghost"""
278
266
        tree = self.make_branch_and_tree('.')
285
273
        tree.add_parent_tree_id('first-revision', allow_leftmost_as_ghost=True)
286
274
        tree.add_parent_tree_id('second')
287
275
        self.assertConsistentParents(['first-revision', 'second'], tree)
288
 
        
 
276
 
289
277
    def test_add_second_parent_id(self):
290
278
        """Test adding the second parent id"""
291
279
        tree = self.make_branch_and_tree('.')
294
282
        second_revision = tree.commit('second post')
295
283
        tree.add_parent_tree_id(first_revision)
296
284
        self.assertConsistentParents([second_revision, first_revision], tree)
297
 
        
 
285
 
298
286
    def test_add_second_parent_id_ghost(self):
299
287
        """Test adding the second parent id - as a ghost"""
300
288
        tree = self.make_branch_and_tree('.')
301
289
        first_revision = tree.commit('first post')
302
290
        tree.add_parent_tree_id('second')
303
291
        self.assertConsistentParents([first_revision, 'second'], tree)
304
 
        
 
292
 
305
293
    def test_add_first_parent_tree(self):
306
294
        """Test adding the first parent id"""
307
295
        tree = self.make_branch_and_tree('.')
310
298
        tree.add_parent_tree((first_revision,
311
299
            tree.branch.repository.revision_tree(first_revision)))
312
300
        self.assertConsistentParents([first_revision], tree)
313
 
        
 
301
 
314
302
    def test_add_first_parent_tree_ghost_rejects(self):
315
303
        """Test adding the first parent id - as a ghost"""
316
304
        tree = self.make_branch_and_tree('.')
317
305
        self.assertRaises(errors.GhostRevisionUnusableHere,
318
306
            tree.add_parent_tree, ('first-revision', None))
319
 
        
 
307
 
320
308
    def test_add_first_parent_tree_ghost_force(self):
321
309
        """Test adding the first parent id - as a ghost"""
322
310
        tree = self.make_branch_and_tree('.')
323
311
        tree.add_parent_tree(('first-revision', None),
324
312
            allow_leftmost_as_ghost=True)
325
313
        self.assertConsistentParents(['first-revision'], tree)
326
 
        
 
314
 
327
315
    def test_add_second_parent_tree(self):
328
316
        """Test adding the second parent id"""
329
317
        tree = self.make_branch_and_tree('.')
333
321
        tree.add_parent_tree((first_revision,
334
322
            tree.branch.repository.revision_tree(first_revision)))
335
323
        self.assertConsistentParents([second_revision, first_revision], tree)
336
 
        
 
324
 
337
325
    def test_add_second_parent_tree_ghost(self):
338
326
        """Test adding the second parent id - as a ghost"""
339
327
        tree = self.make_branch_and_tree('.')
344
332
 
345
333
class UpdateToOneParentViaDeltaTests(TestCaseWithWorkingTree):
346
334
    """Tests for the update_basis_by_delta call.
347
 
    
 
335
 
348
336
    This is intuitively defined as 'apply an inventory delta to the basis and
349
337
    discard other parents', but for trees that have an inventory that is not
350
338
    managed as a tree-by-id, the implementation requires roughly duplicated