Rev 2571: Fix WorkingTree(3).add to not reset the entire inventory but modify the existing one. in sftp://rookery/~/public_html/baz2.0/add

Robert Collins robertc at robertcollins.net
Mon Jul 2 23:46:23 BST 2007


At sftp://rookery/~/public_html/baz2.0/add

------------------------------------------------------------
revno: 2571
revision-id: robertc at robertcollins.net-20070702224620-rptec516zwv3opwn
parent: robertc at robertcollins.net-20070702223611-50tnzmbeoryqid75
committer: Robert Collins <robertc at robertcollins.net>
branch nick: add
timestamp: Tue 2007-07-03 08:46:20 +1000
message:
  Fix WorkingTree(3).add to not reset the entire inventory but modify the existing one.
modified:
  bzrlib/add.py                  add.py-20050323030017-3a77d63feda58e33
  bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
=== modified file 'bzrlib/add.py'
--- a/bzrlib/add.py	2007-07-02 22:36:11 +0000
+++ b/bzrlib/add.py	2007-07-02 22:46:20 +0000
@@ -364,17 +364,17 @@
     return added + [path.raw_path]
 
 
-def __add_one(tree, inv, parent_ie, path, kind, action):
+def __add_one(tree, inv, parent_ie, path, kind, file_id_callback):
     """Add a new entry to the inventory.
 
     :param inv: Inventory which will receive the new entry.
     :param parent_ie: Parent inventory entry.
     :param kind: Kind of new entry (file, directory, etc)
-    :param action: callback(inv, parent_ie, path, kind); return a file_id 
+    :param file_id_callback: callback(inv, parent_ie, path, kind); return a file_id 
         or None to generate a new file id
     :returns: None
     """
-    file_id = action(inv, parent_ie, path, kind)
+    file_id = file_id_callback(inv, parent_ie, path, kind)
     entry = bzrlib.inventory.make_entry(kind, path.base_path, parent_ie.file_id,
                                         file_id=file_id)
     inv.add(entry)

=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py	2007-06-28 07:15:28 +0000
+++ b/bzrlib/workingtree.py	2007-07-02 22:46:20 +0000
@@ -615,7 +615,7 @@
         # should probably put it back with the previous ID.
         # the read and write working inventory should not occur in this 
         # function - they should be part of lock_write and unlock.
-        inv = self.read_working_inventory()
+        inv = self.inventory
         for f, file_id, kind in zip(files, ids, kinds):
             assert kind is not None
             if file_id is None:
@@ -623,7 +623,7 @@
             else:
                 file_id = osutils.safe_file_id(file_id)
                 inv.add_path(f, kind=kind, file_id=file_id)
-        self._write_inventory(inv)
+            self._inventory_is_modified = True
 
     @needs_tree_write_lock
     def _gather_kinds(self, files, kinds):



More information about the bazaar-commits mailing list