Rev 2440: Add a check that all entries have a valid parent entry. in http://bzr.arbash-meinel.com/branches/bzr/0.16-dev/rename_directory_105479
John Arbash Meinel
john at arbash-meinel.com
Fri Apr 20 18:57:32 BST 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.16-dev/rename_directory_105479
------------------------------------------------------------
revno: 2440
revision-id: john at arbash-meinel.com-20070420175713-64x3r196vbqad3y2
parent: john at arbash-meinel.com-20070420164821-ml7cw68e09gcr54d
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: rename_directory_105479
timestamp: Fri 2007-04-20 12:57:13 -0500
message:
Add a check that all entries have a valid parent entry.
If we have a non-absent entry, it must have a valid directory entry as a parent.
(You can't have a present entry in an absent directory, or in a missing dir)
modified:
bzrlib/dirstate.py dirstate.py-20060728012006-d6mvoihjb3je9peu-1
-------------- next part --------------
=== modified file 'bzrlib/dirstate.py'
--- a/bzrlib/dirstate.py 2007-04-20 08:05:24 +0000
+++ b/bzrlib/dirstate.py 2007-04-20 17:57:13 +0000
@@ -2212,6 +2212,29 @@
"dirblock for %r is not sorted:\n%s" % \
(dirblock[0], pformat(dirblock)))
+
+ def check_valid_parent():
+ """Check that the current entry has a valid parent.
+
+ This makes sure that the parent has a record,
+ and that the parent isn't marked as "absent" in the
+ current tree. (It is invalid to have a non-absent file in an absent
+ directory.)
+ """
+ if entry[0][0:2] == ('', ''):
+ # There should be no parent for the root row
+ return
+ parent_entry = self._get_entry(tree_index, path_utf8=entry[0][0])
+ if parent_entry == (None, None):
+ raise AssertionError(
+ "no parent entry for: %s in tree %s"
+ % (this_path, tree_index))
+ else:
+ if parent_entry[1][tree_index][0] != 'd':
+ raise AssertionError(
+ "Parent entry for %s is not marked as a valid"
+ " directory. %s" % (this_path, parent_entry,))
+
# For each file id, for each tree: either
# the file id is not present at all; all rows with that id in the
# key have it marked as 'absent'
@@ -2258,6 +2281,7 @@
raise AssertionError(
"entry %r inconsistent with previous path %r" % \
(entry, previous_path))
+ check_valid_parent()
else:
if minikind == 'a':
# absent; should not occur anywhere else
@@ -2267,6 +2291,7 @@
this_tree_map[file_id] = tree_state[1]
else:
this_tree_map[file_id] = this_path
+ check_valid_parent()
def _wipe_state(self):
"""Forget all state information about the dirstate."""
More information about the bazaar-commits
mailing list