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)
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))),
970
973
self.assertEqual([revid1, revid2, 'ghost-rev'],
971
974
state.get_parent_ids())
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)], [])
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))
2059
2062
for path, keys in zip(paths, map_keys):
2060
2063
if keys is None:
2079
2082
:param paths: A list of directories
2081
2084
result = state._bisect_dirblocks(paths)
2082
assert len(map_keys) == len(paths)
2085
self.assertEqual(len(map_keys), len(paths))
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)
2522
class Test_InvEntryToDetails(TestCaseWithDirState):
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
2529
(minikind, fingerprint, size, executable, tree_data) = details
2530
self.assertIsInstance(minikind, str)
2531
self.assertIsInstance(fingerprint, str)
2532
self.assertIsInstance(tree_data, str)
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',
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)