~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Martin Pool
  • Date: 2005-06-22 08:12:31 UTC
  • Revision ID: mbp@sourcefrog.net-20050622081231-630e514240ccb87a
- new exception NotVersionedError
- raise this from Inventory.add_path if parent isnt versioned

Show diffs side-by-side

added added

removed removed

Lines of Context:
430
430
        """Add entry from a path.
431
431
 
432
432
        The immediate parent must already be versioned"""
 
433
        from bzrlib.errors import NotVersionedError
 
434
        
433
435
        parts = bzrlib.osutils.splitpath(relpath)
434
436
        if len(parts) == 0:
435
437
            raise BzrError("cannot re-add root of inventory")
437
439
        if file_id == None:
438
440
            file_id = bzrlib.branch.gen_file_id(relpath)
439
441
 
440
 
        parent_id = self.path2id(parts[:-1])
441
 
        assert parent_id != None
 
442
        parent_path = parts[:-1]
 
443
        parent_id = self.path2id(parent_path)
 
444
        if parent_id == None:
 
445
            raise NotVersionedError(parent_path)
 
446
 
442
447
        ie = InventoryEntry(file_id, parts[-1],
443
448
                            kind=kind, parent_id=parent_id)
444
449
        return self.add(ie)