/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_dirstate.py

  • Committer: Andrew Bennetts
  • Date: 2008-09-08 12:59:00 UTC
  • mfrom: (3695 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3756.
  • Revision ID: andrew.bennetts@canonical.com-20080908125900-8ywtsr7jqyyatjz0
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from bzrlib import (
24
24
    dirstate,
25
25
    errors,
 
26
    inventory,
26
27
    osutils,
 
28
    revision as _mod_revision,
27
29
    )
28
30
from bzrlib.memorytree import MemoryTree
29
31
from bzrlib.tests import (
162
164
        """
163
165
        # The state should already be write locked, since we just had to do
164
166
        # some operation to get here.
165
 
        assert state._lock_token is not None
 
167
        self.assertTrue(state._lock_token is not None)
166
168
        try:
167
169
            self.assertEqual(expected_result[0],  state.get_parent_ids())
168
170
            # there should be no ghosts in this tree.
965
967
            state.set_parent_trees(
966
968
                ((revid1, tree1.branch.repository.revision_tree(revid1)),
967
969
                 (revid2, tree2.branch.repository.revision_tree(revid2)),
968
 
                 ('ghost-rev', tree2.branch.repository.revision_tree(None))),
 
970
                 ('ghost-rev', tree2.branch.repository.revision_tree(
 
971
                                   _mod_revision.NULL_REVISION))),
969
972
                ['ghost-rev'])
970
973
            self.assertEqual([revid1, revid2, 'ghost-rev'],
971
974
                             state.get_parent_ids())
1602
1605
 
1603
1606
        # *really* cheesy way to just get an empty tree
1604
1607
        repo = self.make_repository('repo')
1605
 
        empty_tree = repo.revision_tree(None)
 
1608
        empty_tree = repo.revision_tree(_mod_revision.NULL_REVISION)
1606
1609
        state.set_parent_trees([('null:', empty_tree)], [])
1607
1610
 
1608
1611
        dirblock_names = [d[0] for d in state._dirblocks]
2054
2057
        # the end it would still be fairly arbitrary, and we don't want the
2055
2058
        # extra overhead if we can avoid it. So sort everything to make sure
2056
2059
        # equality is true
2057
 
        assert len(map_keys) == len(paths)
 
2060
        self.assertEqual(len(map_keys), len(paths))
2058
2061
        expected = {}
2059
2062
        for path, keys in zip(paths, map_keys):
2060
2063
            if keys is None:
2079
2082
        :param paths: A list of directories
2080
2083
        """
2081
2084
        result = state._bisect_dirblocks(paths)
2082
 
        assert len(map_keys) == len(paths)
2083
 
 
 
2085
        self.assertEqual(len(map_keys), len(paths))
2084
2086
        expected = {}
2085
2087
        for path, keys in zip(paths, map_keys):
2086
2088
            if keys is None:
2515
2517
        state._discard_merge_parents()
2516
2518
        state._validate()
2517
2519
        self.assertEqual(exp_dirblocks, state._dirblocks)
 
2520
 
 
2521
 
 
2522
class Test_InvEntryToDetails(TestCaseWithDirState):
 
2523
 
 
2524
    def assertDetails(self, expected, inv_entry):
 
2525
        details = dirstate.DirState._inv_entry_to_details(inv_entry)
 
2526
        self.assertEqual(expected, details)
 
2527
        # details should always allow join() and always be a plain str when
 
2528
        # finished
 
2529
        (minikind, fingerprint, size, executable, tree_data) = details
 
2530
        self.assertIsInstance(minikind, str)
 
2531
        self.assertIsInstance(fingerprint, str)
 
2532
        self.assertIsInstance(tree_data, str)
 
2533
 
 
2534
    def test_unicode_symlink(self):
 
2535
        # In general, the code base doesn't support a target that contains
 
2536
        # non-ascii characters. So we just assert tha 
 
2537
        inv_entry = inventory.InventoryLink('link-file-id', 'name',
 
2538
                                            'link-parent-id')
 
2539
        inv_entry.revision = 'link-revision-id'
 
2540
        inv_entry.symlink_target = u'link-target'
 
2541
        details = self.assertDetails(('l', 'link-target', 0, False,
 
2542
                                      'link-revision-id'), inv_entry)