Rev 5545: (vila) Fix spurious orphan reports (Vincent Ladeuil) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Nov 19 17:40:27 GMT 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5545 [merge]
revision-id: pqm at pqm.ubuntu.com-20101119174025-76prtl0dsb9770aj
parent: pqm at pqm.ubuntu.com-20101118204540-un6e3t40melfjp9v
parent: v.ladeuil+lp at free.fr-20101119162825-ea26gswbb0jxadhj
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2010-11-19 17:40:25 +0000
message:
(vila) Fix spurious orphan reports (Vincent Ladeuil)
modified:
bzrlib/tests/test_transform.py test_transaction.py-20060105172520-b3ffb3946550e6c4
bzrlib/transform.py transform.py-20060105172343-dd99e54394d91687
=== modified file 'bzrlib/tests/test_transform.py'
--- a/bzrlib/tests/test_transform.py 2010-10-15 14:21:03 +0000
+++ b/bzrlib/tests/test_transform.py 2010-11-19 08:34:39 +0000
@@ -3272,15 +3272,20 @@
policy)
def _prepare_orphan(self, wt):
- self.build_tree(['dir/', 'dir/foo'])
- wt.add(['dir'], ['dir-id'])
- wt.commit('add dir')
+ self.build_tree(['dir/', 'dir/file', 'dir/foo'])
+ wt.add(['dir', 'dir/file'], ['dir-id', 'file-id'])
+ wt.commit('add dir and file ignoring foo')
tt = transform.TreeTransform(wt)
self.addCleanup(tt.finalize)
+ # dir and bar are deleted
dir_tid = tt.trans_id_tree_path('dir')
+ file_tid = tt.trans_id_tree_path('dir/file')
orphan_tid = tt.trans_id_tree_path('dir/foo')
+ tt.delete_contents(file_tid)
+ tt.unversion_file(file_tid)
tt.delete_contents(dir_tid)
tt.unversion_file(dir_tid)
+ # There should be a conflict because dir still contain foo
raw_conflicts = tt.find_conflicts()
self.assertLength(1, raw_conflicts)
self.assertEqual(('missing parent', 'new-1'), raw_conflicts[0])
@@ -3290,7 +3295,13 @@
wt = self.make_branch_and_tree('.')
self._set_orphan_policy(wt, 'move')
tt, orphan_tid = self._prepare_orphan(wt)
+ warnings = []
+ def warning(*args):
+ warnings.append(args[0] % args[1:])
+ self.overrideAttr(trace, 'warning', warning)
remaining_conflicts = resolve_conflicts(tt)
+ self.assertEquals(['dir/foo has been orphaned in bzr-orphans'],
+ warnings)
# Yeah for resolved conflicts !
self.assertLength(0, remaining_conflicts)
# We have a new orphan
=== modified file 'bzrlib/transform.py'
--- a/bzrlib/transform.py 2010-11-07 15:56:46 +0000
+++ b/bzrlib/transform.py 2010-11-19 16:28:25 +0000
@@ -703,27 +703,29 @@
return conflicts
def _parent_type_conflicts(self, by_parent):
- """parents must have directory 'contents'."""
+ """Children must have a directory parent"""
conflicts = []
for parent_id, children in by_parent.iteritems():
if parent_id is ROOT_PARENT:
continue
- if not self._any_contents(children):
+ no_children = True
+ for child_id in children:
+ if self.final_kind(child_id) is not None:
+ no_children = False
+ break
+ if no_children:
continue
+ # There is at least a child, so we need an existing directory to
+ # contain it.
kind = self.final_kind(parent_id)
if kind is None:
+ # The directory will be deleted
conflicts.append(('missing parent', parent_id))
elif kind != "directory":
+ # Meh, we need a *directory* to put something in it
conflicts.append(('non-directory parent', parent_id))
return conflicts
- def _any_contents(self, trans_ids):
- """Return true if any of the trans_ids, will have contents."""
- for trans_id in trans_ids:
- if self.final_kind(trans_id) is not None:
- return True
- return False
-
def _set_executability(self, path, trans_id):
"""Set the executability of versioned files """
if supports_executable():
@@ -820,9 +822,14 @@
"""
orphans = []
# Find the potential orphans, stop if one item should be kept
- for c in self.by_parent()[dir_id]:
- if self.final_file_id(c) is None:
- orphans.append(c)
+ for child_tid in self.by_parent()[dir_id]:
+ if child_tid in self._removed_contents:
+ # The child is removed as part of the transform. Since it was
+ # versioned before, it's not an orphan
+ continue
+ elif self.final_file_id(child_tid) is None:
+ # The child is not versioned
+ orphans.append(child_tid)
else:
# We have a versioned file here, searching for orphans is
# meaningless.
More information about the bazaar-commits
mailing list