~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
358
358
                               ('a/c/d', 'd-id')], tree.basis_tree())
359
359
        tree._validate()
360
360
 
 
361
    def test_move_directory_into_parent(self):
 
362
        tree = self.make_branch_and_tree('.')
 
363
        self.build_tree(['c/', 'c/b/', 'c/b/d/'])
 
364
        tree.add(['c', 'c/b', 'c/b/d'],
 
365
                 ['c-id', 'b-id', 'd-id'])
 
366
        tree.commit('initial', rev_id='rev-1')
 
367
        root_id = tree.get_root_id()
 
368
 
 
369
        self.assertEqual([('c/b', 'b')],
 
370
                         tree.move(['c/b'], ''))
 
371
        self.assertTreeLayout([('', root_id),
 
372
                               ('b', 'b-id'),
 
373
                               ('c', 'c-id'),
 
374
                               ('b/d', 'd-id'),
 
375
                              ], tree)
 
376
        tree._validate()
 
377
 
 
378
    def test_move_directory_with_children_in_subdir(self):
 
379
        tree = self.make_branch_and_tree('.')
 
380
        self.build_tree(['a/', 'a/b', 'a/c/', 'd/'])
 
381
        tree.add(['a', 'a/b', 'a/c', 'd'],
 
382
                 ['a-id', 'b-id', 'c-id', 'd-id'])
 
383
        tree.commit('initial', rev_id='rev-1')
 
384
        root_id = tree.get_root_id()
 
385
 
 
386
 
 
387
        tree.rename_one('a/b', 'a/c/b')
 
388
        self.assertTreeLayout([('', root_id),
 
389
                               ('a', 'a-id'),
 
390
                               ('d', 'd-id'),
 
391
                               ('a/c', 'c-id'),
 
392
                               ('a/c/b', 'b-id'),
 
393
                              ], tree)
 
394
        self.assertEqual([('a', 'd/a')],
 
395
                         tree.move(['a'], 'd'))
 
396
        self.assertTreeLayout([('', root_id),
 
397
                               ('d', 'd-id'),
 
398
                               ('d/a', 'a-id'),
 
399
                               ('d/a/c', 'c-id'),
 
400
                               ('d/a/c/b', 'b-id'),
 
401
                              ], tree)
 
402
        tree._validate()
 
403
 
 
404
    def test_move_directory_with_deleted_children(self):
 
405
        tree = self.make_branch_and_tree('.')
 
406
        self.build_tree(['a/', 'a/b', 'a/c', 'a/d', 'b/'])
 
407
        tree.add(['a', 'b', 'a/b', 'a/c', 'a/d'],
 
408
                 ['a-id', 'b-id', 'ab-id', 'ac-id', 'ad-id'])
 
409
        tree.commit('initial', rev_id='rev-1')
 
410
        root_id = tree.get_root_id()
 
411
 
 
412
        tree.remove(['a/b', 'a/d'])
 
413
 
 
414
        self.assertEqual([('a', 'b/a')],
 
415
                         tree.move(['a'], 'b'))
 
416
        self.assertTreeLayout([('', root_id),
 
417
                               ('b', 'b-id'),
 
418
                               ('b/a', 'a-id'),
 
419
                               ('b/a/c', 'ac-id'),
 
420
                              ], tree)
 
421
        tree._validate()
 
422
 
 
423
    def test_move_directory_with_new_children(self):
 
424
        tree = self.make_branch_and_tree('.')
 
425
        self.build_tree(['a/', 'a/c', 'b/'])
 
426
        tree.add(['a', 'b', 'a/c'], ['a-id', 'b-id', 'ac-id'])
 
427
        tree.commit('initial', rev_id='rev-1')
 
428
        root_id = tree.get_root_id()
 
429
 
 
430
        self.build_tree(['a/b', 'a/d'])
 
431
        tree.add(['a/b', 'a/d'], ['ab-id', 'ad-id'])
 
432
 
 
433
        self.assertEqual([('a', 'b/a')],
 
434
                         tree.move(['a'], 'b'))
 
435
        self.assertTreeLayout([('', root_id),
 
436
                               ('b', 'b-id'),
 
437
                               ('b/a', 'a-id'),
 
438
                               ('b/a/b', 'ab-id'),
 
439
                               ('b/a/c', 'ac-id'),
 
440
                               ('b/a/d', 'ad-id'),
 
441
                              ], tree)
 
442
        tree._validate()
 
443
 
 
444
    def test_move_directory_with_moved_children(self):
 
445
        tree = self.make_branch_and_tree('.')
 
446
        self.build_tree(['a/', 'a/b', 'a/c', 'd', 'e/'])
 
447
        tree.add(['a', 'a/b', 'a/c', 'd', 'e'],
 
448
                 ['a-id', 'b-id', 'c-id', 'd-id', 'e-id'])
 
449
        tree.commit('initial', rev_id='rev-1')
 
450
        root_id = tree.get_root_id()
 
451
 
 
452
        self.assertEqual([('a/b', 'b')],
 
453
                         tree.move(['a/b'], ''))
 
454
        self.assertTreeLayout([('', root_id),
 
455
                               ('a', 'a-id'),
 
456
                               ('b', 'b-id'),
 
457
                               ('d', 'd-id'),
 
458
                               ('e', 'e-id'),
 
459
                               ('a/c', 'c-id'),
 
460
                              ], tree)
 
461
        self.assertEqual([('d', 'a/d')],
 
462
                         tree.move(['d'], 'a'))
 
463
        self.assertTreeLayout([('', root_id),
 
464
                               ('a', 'a-id'),
 
465
                               ('b', 'b-id'),
 
466
                               ('e', 'e-id'),
 
467
                               ('a/c', 'c-id'),
 
468
                               ('a/d', 'd-id'),
 
469
                              ], tree)
 
470
        self.assertEqual([('a', 'e/a')],
 
471
                         tree.move(['a'], 'e'))
 
472
        self.assertTreeLayout([('', root_id),
 
473
                               ('b', 'b-id'),
 
474
                               ('e', 'e-id'),
 
475
                               ('e/a', 'a-id'),
 
476
                               ('e/a/c', 'c-id'),
 
477
                               ('e/a/d', 'd-id'),
 
478
                              ], tree)
 
479
        tree._validate()
 
480
 
 
481
    def test_move_directory_with_renamed_child(self):
 
482
        tree = self.make_branch_and_tree('.')
 
483
        self.build_tree(['a/', 'a/b', 'a/c', 'd/'])
 
484
        tree.add(['a', 'a/b', 'a/c', 'd'],
 
485
                 ['a-id', 'b-id', 'c-id', 'd-id'])
 
486
        tree.commit('initial', rev_id='rev-1')
 
487
        root_id = tree.get_root_id()
 
488
 
 
489
        tree.rename_one('a/b', 'a/d')
 
490
        self.assertTreeLayout([('', root_id),
 
491
                               ('a', 'a-id'),
 
492
                               ('d', 'd-id'),
 
493
                               ('a/c', 'c-id'),
 
494
                               ('a/d', 'b-id'),
 
495
                              ], tree)
 
496
        self.assertEqual([('a', 'd/a')],
 
497
                         tree.move(['a'], 'd'))
 
498
        self.assertTreeLayout([('', root_id),
 
499
                               ('d', 'd-id'),
 
500
                               ('d/a', 'a-id'),
 
501
                               ('d/a/c', 'c-id'),
 
502
                               ('d/a/d', 'b-id'),
 
503
                              ], tree)
 
504
        tree._validate()
 
505
 
 
506
    def test_move_directory_with_swapped_children(self):
 
507
        tree = self.make_branch_and_tree('.')
 
508
        self.build_tree(['a/', 'a/b', 'a/c', 'a/d', 'e/'])
 
509
        tree.add(['a', 'a/b', 'a/c', 'a/d', 'e'],
 
510
                 ['a-id', 'b-id', 'c-id', 'd-id', 'e-id'])
 
511
        tree.commit('initial', rev_id='rev-1')
 
512
        root_id = tree.get_root_id()
 
513
 
 
514
        tree.rename_one('a/b', 'a/bb')
 
515
        tree.rename_one('a/d', 'a/b')
 
516
        tree.rename_one('a/bb', 'a/d')
 
517
        self.assertTreeLayout([('', root_id),
 
518
                               ('a', 'a-id'),
 
519
                               ('e', 'e-id'),
 
520
                               ('a/b', 'd-id'),
 
521
                               ('a/c', 'c-id'),
 
522
                               ('a/d', 'b-id'),
 
523
                              ], tree)
 
524
        self.assertEqual([('a', 'e/a')],
 
525
                         tree.move(['a'], 'e'))
 
526
        self.assertTreeLayout([('', root_id),
 
527
                               ('e', 'e-id'),
 
528
                               ('e/a', 'a-id'),
 
529
                               ('e/a/b', 'd-id'),
 
530
                               ('e/a/c', 'c-id'),
 
531
                               ('e/a/d', 'b-id'),
 
532
                              ], tree)
 
533
        tree._validate()
 
534
 
361
535
    def test_move_moved(self):
362
536
        """Moving a moved entry works as expected."""
363
537
        tree = self.make_branch_and_tree('.')