~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_dirstate.py

  • Committer: Martin Pool
  • Date: 2008-06-11 02:36:40 UTC
  • mfrom: (3490 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3492.
  • Revision ID: mbp@sourcefrog.net-20080611023640-db0lqd75yueksdw7
Merge news

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,
27
28
    )
28
29
from bzrlib.memorytree import MemoryTree
162
163
        """
163
164
        # The state should already be write locked, since we just had to do
164
165
        # some operation to get here.
165
 
        assert state._lock_token is not None
 
166
        self.assertTrue(state._lock_token is not None)
166
167
        try:
167
168
            self.assertEqual(expected_result[0],  state.get_parent_ids())
168
169
            # there should be no ghosts in this tree.
2054
2055
        # the end it would still be fairly arbitrary, and we don't want the
2055
2056
        # extra overhead if we can avoid it. So sort everything to make sure
2056
2057
        # equality is true
2057
 
        assert len(map_keys) == len(paths)
 
2058
        self.assertEqual(len(map_keys), len(paths))
2058
2059
        expected = {}
2059
2060
        for path, keys in zip(paths, map_keys):
2060
2061
            if keys is None:
2079
2080
        :param paths: A list of directories
2080
2081
        """
2081
2082
        result = state._bisect_dirblocks(paths)
2082
 
        assert len(map_keys) == len(paths)
2083
 
 
 
2083
        self.assertEqual(len(map_keys), len(paths))
2084
2084
        expected = {}
2085
2085
        for path, keys in zip(paths, map_keys):
2086
2086
            if keys is None:
2515
2515
        state._discard_merge_parents()
2516
2516
        state._validate()
2517
2517
        self.assertEqual(exp_dirblocks, state._dirblocks)
 
2518
 
 
2519
 
 
2520
class Test_InvEntryToDetails(TestCaseWithDirState):
 
2521
 
 
2522
    def assertDetails(self, expected, inv_entry):
 
2523
        details = dirstate.DirState._inv_entry_to_details(inv_entry)
 
2524
        self.assertEqual(expected, details)
 
2525
        # details should always allow join() and always be a plain str when
 
2526
        # finished
 
2527
        (minikind, fingerprint, size, executable, tree_data) = details
 
2528
        self.assertIsInstance(minikind, str)
 
2529
        self.assertIsInstance(fingerprint, str)
 
2530
        self.assertIsInstance(tree_data, str)
 
2531
 
 
2532
    def test_unicode_symlink(self):
 
2533
        # In general, the code base doesn't support a target that contains
 
2534
        # non-ascii characters. So we just assert tha 
 
2535
        inv_entry = inventory.InventoryLink('link-file-id', 'name',
 
2536
                                            'link-parent-id')
 
2537
        inv_entry.revision = 'link-revision-id'
 
2538
        inv_entry.symlink_target = u'link-target'
 
2539
        details = self.assertDetails(('l', 'link-target', 0, False,
 
2540
                                      'link-revision-id'), inv_entry)