~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/dirstate.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-04-21 15:11:39 UTC
  • mfrom: (2438.1.16 rename_directory_105479)
  • Revision ID: pqm@pqm.ubuntu.com-20070421151139-5wau2ukbpx5z1hv2
(John Arbash Meinel) Fix bug #105479: properly handle moving a directory with children that have been added, renamed, removed

Show diffs side-by-side

added added

removed removed

Lines of Context:
2212
2212
                    "dirblock for %r is not sorted:\n%s" % \
2213
2213
                    (dirblock[0], pformat(dirblock)))
2214
2214
 
 
2215
 
 
2216
        def check_valid_parent():
 
2217
            """Check that the current entry has a valid parent.
 
2218
 
 
2219
            This makes sure that the parent has a record,
 
2220
            and that the parent isn't marked as "absent" in the
 
2221
            current tree. (It is invalid to have a non-absent file in an absent
 
2222
            directory.)
 
2223
            """
 
2224
            if entry[0][0:2] == ('', ''):
 
2225
                # There should be no parent for the root row
 
2226
                return
 
2227
            parent_entry = self._get_entry(tree_index, path_utf8=entry[0][0])
 
2228
            if parent_entry == (None, None):
 
2229
                raise AssertionError(
 
2230
                    "no parent entry for: %s in tree %s"
 
2231
                    % (this_path, tree_index))
 
2232
            if parent_entry[1][tree_index][0] != 'd':
 
2233
                raise AssertionError(
 
2234
                    "Parent entry for %s is not marked as a valid"
 
2235
                    " directory. %s" % (this_path, parent_entry,))
 
2236
 
2215
2237
        # For each file id, for each tree: either
2216
2238
        # the file id is not present at all; all rows with that id in the
2217
2239
        # key have it marked as 'absent'
2258
2280
                            raise AssertionError(
2259
2281
                            "entry %r inconsistent with previous path %r" % \
2260
2282
                            (entry, previous_path))
 
2283
                        check_valid_parent()
2261
2284
                else:
2262
2285
                    if minikind == 'a':
2263
2286
                        # absent; should not occur anywhere else
2267
2290
                        this_tree_map[file_id] = tree_state[1]
2268
2291
                    else:
2269
2292
                        this_tree_map[file_id] = this_path
 
2293
                        check_valid_parent()
2270
2294
 
2271
2295
    def _wipe_state(self):
2272
2296
        """Forget all state information about the dirstate."""