Rev 2730: want_unversioned working for dirstate trees, _iter_changes behaviour on generic implementations broken due to underlying behaviour. in http://people.ubuntu.com/~robertc/baz2.0/commit-candidates
Robert Collins
robertc at robertcollins.net
Thu Aug 23 08:29:59 BST 2007
At http://people.ubuntu.com/~robertc/baz2.0/commit-candidates
------------------------------------------------------------
revno: 2730
revision-id: robertc at robertcollins.net-20070823072957-nyxgpdwdlmjlsmbe
parent: robertc at robertcollins.net-20070823064228-onf9ozxb7wa8umiz
committer: Robert Collins <robertc at robertcollins.net>
branch nick: commit-candidates
timestamp: Thu 2007-08-23 17:29:57 +1000
message:
want_unversioned working for dirstate trees, _iter_changes behaviour on generic implementations broken due to underlying behaviour.
modified:
bzrlib/mutabletree.py mutabletree.py-20060906023413-4wlkalbdpsxi2r4y-2
bzrlib/tests/workingtree_implementations/test_iter_commit_candidates.py test_iter_commit_can-20070822055451-ygz697i0te0mcg8p-1
=== modified file 'bzrlib/mutabletree.py'
--- a/bzrlib/mutabletree.py 2007-08-23 06:32:24 +0000
+++ b/bzrlib/mutabletree.py 2007-08-23 07:29:57 +0000
@@ -211,7 +211,8 @@
revprops=revprops, *args, **kwargs)
return committed_id
- def iter_commit_candidates(self, parent_trees, specific_files=None):
+ def iter_commit_candidates(self, parent_trees, specific_files=None,
+ want_unversioned=False):
"""Iterate over the items which may need to be committed.
This iterator will examine each path currently versioned in the tree.
@@ -268,6 +269,12 @@
:param specific_files: An optional limit for the paths to include during
commit. If provided it should be a list of relative paths within the
tree.
+ :param want_unversioned: When True, paths within the selected_files
+ group, or the entire tree if that is None, that are not versioned,
+ are included in the result. This is useful for two things, one is
+ dynamically adding such files during commit, the other is for
+ performing a strict commit where unversioned files are a reason for
+ error.
:return: An iterator over paths in the tree which are not excluded from
being recorded during commit. Each item that the iterator yields
contains a three-tuple. The first element is a tuple:
@@ -313,13 +320,11 @@
# if there are multiple parents we need to compare last_modified
include_unchanged = parent_count > 1
try:
- strict = False
- auto_add_delete = True
input_iterator = self._iter_changes(trees[0],
include_unchanged=include_unchanged,
specific_files=specific_files,
extra_trees=trees[1:],
- want_unversioned=auto_add_delete or strict,
+ want_unversioned=want_unversioned,
require_versioned=True)
for (file_id, (basis_path, path), content_change,
(basis_versioned, versioned), (basis_parent, parent),
=== modified file 'bzrlib/tests/workingtree_implementations/test_iter_commit_candidates.py'
--- a/bzrlib/tests/workingtree_implementations/test_iter_commit_candidates.py 2007-08-23 06:42:28 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_iter_commit_candidates.py 2007-08-23 07:29:57 +0000
@@ -159,12 +159,14 @@
tree.unlock()
def _check_specific_permutations(self, expected_results, tree,
- new_specific_files, old_specific_files):
+ new_specific_files, old_specific_files, want_unversioned=False,
+ cut_results=True):
"""Test that we get expected results where specific_files might break."""
# all renamed, no specific paths.
self.assertEqual(expected_results,
list(tree.iter_commit_candidates(
{tree.last_revision():tree.basis_tree()},
+ want_unversioned=want_unversioned,
)))
# NB: we use sets below because following renames etc does
# not have our constraint of alphabetical ordering.
@@ -173,49 +175,33 @@
set(tree.iter_commit_candidates(
{tree.last_revision():tree.basis_tree()},
specific_files=old_specific_files,
+ want_unversioned=want_unversioned,
)))
# all by new name
self.assertEqual(set(expected_results),
set(tree.iter_commit_candidates(
{tree.last_revision():tree.basis_tree()},
specific_files=new_specific_files,
- )))
- # dir only by old name
- self.assertEqual(set(expected_results[0:1]),
- set(tree.iter_commit_candidates(
- {tree.last_revision():tree.basis_tree()},
- specific_files=old_specific_files[0:1],
- )))
- # dir only by new name
- self.assertEqual(set(expected_results[0:1]),
- set(tree.iter_commit_candidates(
- {tree.last_revision():tree.basis_tree()},
- specific_files=new_specific_files[0:1],
- )))
- # file only by old name
- self.assertEqual(set(expected_results[1:2]),
- set(tree.iter_commit_candidates(
- {tree.last_revision():tree.basis_tree()},
- specific_files=old_specific_files[1:2],
- )))
- # file only by new name
- self.assertEqual(set(expected_results[1:2]),
- set(tree.iter_commit_candidates(
- {tree.last_revision():tree.basis_tree()},
- specific_files=new_specific_files[1:2],
- )))
- if has_symlinks:
- # link only by old name
- self.assertEqual(set(expected_results[2:3]),
+ want_unversioned=want_unversioned,
+ )))
+ for offset, _ in enumerate(expected_results):
+ # old name
+ if cut_results:
+ cut_result = set(expected_results[offset:offset + 1])
+ else:
+ cut_result = set(expected_results)
+ self.assertEqual(cut_result,
set(tree.iter_commit_candidates(
{tree.last_revision():tree.basis_tree()},
- specific_files=old_specific_files[2:3],
+ specific_files=old_specific_files[offset:offset + 1],
+ want_unversioned=want_unversioned,
)))
- # link only by new name
- self.assertEqual(set(expected_results[2:3]),
+ # new name
+ self.assertEqual(cut_result,
set(tree.iter_commit_candidates(
{tree.last_revision():tree.basis_tree()},
- specific_files=new_specific_files[2:3],
+ specific_files=new_specific_files[offset:offset + 1],
+ want_unversioned=want_unversioned,
)))
def test_deleted_items(self):
@@ -256,5 +242,44 @@
finally:
tree.unlock()
-# tests to write:
-# strict
+ def test_want_unversioned(self):
+ tree = self.make_branch_and_tree('tree')
+ # get a tree with one dir committed, so we can rename it
+ paths = ['dir']
+ ids = ['dirid']
+ self.build_tree(['tree/dir/'])
+ tree.add(paths, ids)
+ rev_id1 = tree.commit('commit')
+ # now rename the directory, so we can check the unversion files are
+ # found across renames.
+ tree.rename_one('dir', 'dir_to')
+ self.build_tree(['tree/dir_to/file'])
+ tree.lock_write()
+ tree_root = tree.path2id('')
+ expected_results = list([
+ ((u'dir_to', 'dirid', tree_root, 'dir_to', 'directory', False, None),
+ ((tree_root, 'dir', 'directory', False, None, rev_id1),),
+ False),
+ ((u'dir_to/file', None, None, 'file', 'file', False, None),
+ ((None, None, None, None, None, None),),
+ True)])
+ try:
+ old_specific_files = ['dir']
+ new_specific_files = ['dir_to']
+ self._check_specific_permutations(expected_results, tree,
+ new_specific_files, old_specific_files, want_unversioned=True,
+ cut_results=False)
+ finally:
+ tree.unlock()
+
+ def test_unversioned_not_reported(self):
+ tree = self.make_branch_and_tree('tree')
+ tree.commit('a commit')
+ self.build_tree(['tree/file'])
+ tree.lock_write()
+ try:
+ self.assertEqual([],
+ list(tree.iter_commit_candidates({
+ tree.last_revision():tree.basis_tree()})))
+ finally:
+ tree.unlock()
More information about the bazaar-commits
mailing list