[Pkg-bazaar-commits] ./bzr/unstable r753: - new exception NotVersionedError

Martin Pool mbp at sourcefrog.net
Fri Apr 10 08:20:55 UTC 2009


------------------------------------------------------------
revno: 753
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Wed 2005-06-22 18:12:31 +1000
message:
  - new exception NotVersionedError
  - raise this from Inventory.add_path if parent isnt versioned
modified:
  bzrlib/errors.py
  bzrlib/inventory.py
-------------- next part --------------
=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py	2005-06-17 07:28:53 +0000
+++ b/bzrlib/errors.py	2005-06-22 08:12:31 +0000
@@ -39,6 +39,10 @@
     pass
 
 
+class NotVersionedError(BzrError):
+    """Specified object is not versioned."""
+
+
 class BadFileKindError(BzrError):
     """Specified file is of a kind that cannot be added.
 

=== modified file 'bzrlib/inventory.py'
--- a/bzrlib/inventory.py	2005-06-17 07:28:53 +0000
+++ b/bzrlib/inventory.py	2005-06-22 08:12:31 +0000
@@ -430,6 +430,8 @@
         """Add entry from a path.
 
         The immediate parent must already be versioned"""
+        from bzrlib.errors import NotVersionedError
+        
         parts = bzrlib.osutils.splitpath(relpath)
         if len(parts) == 0:
             raise BzrError("cannot re-add root of inventory")
@@ -437,8 +439,11 @@
         if file_id == None:
             file_id = bzrlib.branch.gen_file_id(relpath)
 
-        parent_id = self.path2id(parts[:-1])
-        assert parent_id != None
+        parent_path = parts[:-1]
+        parent_id = self.path2id(parent_path)
+        if parent_id == None:
+            raise NotVersionedError(parent_path)
+
         ie = InventoryEntry(file_id, parts[-1],
                             kind=kind, parent_id=parent_id)
         return self.add(ie)



More information about the Pkg-bazaar-commits mailing list