Rev 2444: Add and fix up basic comparison of subtrees. in file:///home/mbp/bzr/Work/subtree/
Martin Pool
mbp at sourcefrog.net
Mon Mar 5 06:37:25 GMT 2007
------------------------------------------------------------
revno: 2444
revision-id: mbp at sourcefrog.net-20070305063046-unnu602hw4j5jgrq
parent: mbp at sourcefrog.net-20070305061143-feioqg2poiixysp6
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: subtree
timestamp: Mon 2007-03-05 17:30:46 +1100
message:
Add and fix up basic comparison of subtrees.
modified:
bzrlib/tests/intertree_implementations/test_compare.py test_compare.py-20060724101752-09ysswo1a92uqyoz-2
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
=== modified file 'bzrlib/tests/intertree_implementations/test_compare.py'
--- a/bzrlib/tests/intertree_implementations/test_compare.py 2007-03-05 06:11:43 +0000
+++ b/bzrlib/tests/intertree_implementations/test_compare.py 2007-03-05 06:30:46 +0000
@@ -39,6 +39,8 @@
# TODO: test specific_files when the target tree has a file and the source a
# dir with children, same id and same path.
# TODO: test comparisons between trees with different root ids. mbp 20070301
+#
+# TODO: More comparisons between trees with subtrees in different states.
class TestCompare(TestCaseWithTwoTrees):
@@ -722,15 +724,25 @@
try:
self.assertEqual([], list(tree2._iter_changes(tree1)))
subtree1.commit('commit', rev_id='commit-a')
- self.assertEqual([('subtree-id',
- 'sub',
- True,
- (True, True),
- ('root-id', 'root-id'),
- ('sub', 'sub'),
- ('tree-reference', 'tree-reference'),
- (False, False))],
- list(tree2._iter_changes(tree1)))
+ self.assertEqual([
+ ('root-id',
+ (u'', u''),
+ False,
+ (True, True),
+ (None, None),
+ (u'', u''),
+ ('directory', 'directory'),
+ (False, False)),
+ ('subtree-id',
+ ('sub', 'sub',),
+ False,
+ (True, True),
+ ('root-id', 'root-id'),
+ ('sub', 'sub'),
+ ('tree-reference', 'tree-reference'),
+ (False, False))],
+ list(tree2._iter_changes(tree1,
+ include_unchanged=True)))
finally:
tree1.unlock()
tree2.unlock()
=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py 2007-03-05 05:49:51 +0000
+++ b/bzrlib/workingtree_4.py 2007-03-05 06:30:46 +0000
@@ -1646,30 +1646,30 @@
# cases:
#
# Source | Target | disk | action
- # r | fdl | | add source to search, add id path move and perform
+ # r | fdlt | | add source to search, add id path move and perform
# | | | diff check on source-target
- # r | fdl | a | dangling file that was present in the basis.
+ # r | fdlt | a | dangling file that was present in the basis.
# | | | ???
# r | a | | add source to search
# r | a | a |
# r | r | | this path is present in a non-examined tree, skip.
# r | r | a | this path is present in a non-examined tree, skip.
- # a | fdl | | add new id
- # a | fdl | a | dangling locally added file, skip
+ # a | fdlt | | add new id
+ # a | fdlt | a | dangling locally added file, skip
# a | a | | not present in either tree, skip
# a | a | a | not present in any tree, skip
# a | r | | not present in either tree at this path, skip as it
# | | | may not be selected by the users list of paths.
# a | r | a | not present in either tree at this path, skip as it
# | | | may not be selected by the users list of paths.
- # fdl | fdl | | content in both: diff them
- # fdl | fdl | a | deleted locally, but not unversioned - show as deleted ?
- # fdl | a | | unversioned: output deleted id for now
- # fdl | a | a | unversioned and deleted: output deleted id
- # fdl | r | | relocated in this tree, so add target to search.
+ # fdlt | fdlt | | content in both: diff them
+ # fdlt | fdlt | a | deleted locally, but not unversioned - show as deleted ?
+ # fdlt | a | | unversioned: output deleted id for now
+ # fdlt | a | a | unversioned and deleted: output deleted id
+ # fdlt | r | | relocated in this tree, so add target to search.
# | | | Dont diff, we will see an r,fd; pair when we reach
# | | | this id at the other path.
- # fdl | r | a | relocated in this tree, so add target to search.
+ # fdlt | r | a | relocated in this tree, so add target to search.
# | | | Dont diff, we will see an r,fd; pair when we reach
# | | | this id at the other path.
@@ -1713,9 +1713,9 @@
source_minikind = source_details[0]
if source_minikind in 'fdlr' and target_minikind in 'fdl':
# claimed content in both: diff
- # r | fdl | | add source to search, add id path move and perform
+ # r | fdlt | | add source to search, add id path move and perform
# | | | diff check on source-target
- # r | fdl | a | dangling file that was present in the basis.
+ # r | fdlt | a | dangling file that was present in the basis.
# | | | ???
if source_minikind in 'r':
# add the source to the search path to find any children it
@@ -1770,6 +1770,11 @@
else:
content_change = (link_or_sha1 != source_details[1])
target_exec = False
+ elif target_kind == 'tree-reference':
+ if source_minikind != 't':
+ content_change = True
+ else:
+ content_change = False
else:
raise Exception, "unknown kind %s" % path_info[2]
# parent id is the entry for the path in the target tree
@@ -1811,7 +1816,7 @@
(old_basename, entry[0][1]),
(_minikind_to_kind[source_minikind], target_kind),
(source_exec, target_exec)),)
- elif source_minikind in 'a' and target_minikind in 'fdl':
+ elif source_minikind in 'a' and target_minikind in 'fdlt':
# looks like a new file
if path_info is not None:
path = pathjoin(entry[0][0], entry[0][1])
@@ -1834,7 +1839,7 @@
# but its not on disk: we deliberately treat this as just
# never-present. (Why ?! - RBC 20070224)
pass
- elif source_minikind in 'fdl' and target_minikind in 'a':
+ elif source_minikind in 'fdlt' and target_minikind in 'a':
# unversioned, possibly, or possibly not deleted: we dont care.
# if its still on disk, *and* theres no other entry at this
# path [we dont know this in this routine at the moment -
@@ -1850,7 +1855,7 @@
(entry[0][1], None),
(_minikind_to_kind[source_minikind], None),
(source_details[3], None)),)
- elif source_minikind in 'fdl' and target_minikind in 'r':
+ elif source_minikind in 'fdlt' and target_minikind in 'r':
# a rename; could be a true rename, or a rename inherited from
# a renamed parent. TODO: handle this efficiently. Its not
# common case to rename dirs though, so a correct but slow
More information about the bazaar-commits
mailing list