Rev 1528: Make more DeltaBuildEditor functions overridable by subclasses. in http://people.samba.org/bzr/jelmer/bzr-svn/trunk

Jelmer Vernooij jelmer at samba.org
Sat Aug 2 20:08:37 BST 2008


At http://people.samba.org/bzr/jelmer/bzr-svn/trunk

------------------------------------------------------------
revno: 1528
revision-id: jelmer at samba.org-20080802190836-bex4laptt0909aj6
parent: jelmer at samba.org-20080802184233-prdqvddtyokr3rpd
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Sat 2008-08-02 21:08:36 +0200
message:
  Make more DeltaBuildEditor functions overridable by subclasses.
modified:
  fetch.py                       fetch.py-20060625004942-x2lfaib8ra707a8p-1
=== modified file 'fetch.py'
--- a/fetch.py	2008-08-02 18:42:33 +0000
+++ b/fetch.py	2008-08-02 19:08:36 +0000
@@ -155,14 +155,11 @@
         return self.mapping.generate_file_id(self.source.uuid, self.revmeta.revnum, 
                                              self.revmeta.branch_path, new_path)
 
-    def _rename(self, file_id, parent_id, path):
-        assert isinstance(path, unicode)
-        assert isinstance(parent_id, str)
-        # Only rename if not right yet
-        if (self.inventory[file_id].parent_id == parent_id and 
-            self.inventory[file_id].name == urlutils.basename(path)):
-            return
-        self.inventory.rename(file_id, parent_id, urlutils.basename(path))
+    def _rename(self, file_id, parent_id, old_path, new_path, kind):
+        raise NotImplementedError
+
+    def _remove_recursive(self, file_id, path):
+        raise NotImplementedError
 
 
 class DirectoryBuildEditor(object):
@@ -198,7 +195,7 @@
             assert copyfrom_path == self.editor.old_inventory.id2path(file_id)
             assert copyfrom_path not in self.editor._premature_deletes
             self.editor._premature_deletes.add(copyfrom_path)
-            self.editor._rename(file_id, self.new_id, path)
+            self.editor._rename(file_id, self.new_id, copyfrom_path, path, 'directory')
             ie = self.editor.inventory[file_id]
             old_file_id = file_id
         else:
@@ -268,7 +265,7 @@
             assert copyfrom_path not in self.editor._premature_deletes
             self.editor._premature_deletes.add(copyfrom_path)
             # No need to rename if it's already in the right spot
-            self.editor._rename(file_id, self.new_id, path)
+            self.editor._rename(file_id, self.new_id, copyfrom_path, path, 'file')
         return FileBuildEditor(self.editor, path, file_id)
 
     def open_file(self, path, base_revnum):
@@ -299,7 +296,7 @@
                 if p.startswith("%s/" % path):
                     self.editor._premature_deletes.remove(p)
         else:
-            self.editor.inventory.remove_recursive_id(self.editor._get_old_id(self.old_id, path))
+            self.editor._remove_recursive(self.editor._get_old_id(self.old_id, path), path)
 
 
 class FileBuildEditor(object):
@@ -436,6 +433,18 @@
     def _start_revision(self):
         pass
 
+    def _rename(self, file_id, parent_id, old_path, new_path, kind):
+        assert isinstance(new_path, unicode)
+        assert isinstance(parent_id, str)
+        # Only rename if not right yet
+        if (self.inventory[file_id].parent_id == parent_id and 
+            self.inventory[file_id].name == urlutils.basename(new_path)):
+            return
+        self.inventory.rename(file_id, parent_id, urlutils.basename(new_path))
+
+    def _remove_recursive(self, file_id, path):
+        self.editor.inventory.remove_recursive_id(file_id)
+
 
 
 class TreeDeltaBuildeditor(DeltaBuildEditor):
@@ -448,6 +457,15 @@
         # To make sure we fall over if anybody tries to use it:
         self.delta.unchanged = None
 
+    def _rename(self, file_id, parent_id, old_path, new_path, kind):
+        # FIXME: Fill in text_modified and meta_modified
+        self.delta.renamed.append((old_path, new_path, file_id, kind, 
+                                   text_modified, meta_modified))
+
+    def _remove_recursive(self, file_id, path):
+        # FIXME: Fill in kind
+        self.delta.removed.append((path, file_id, 'unknown-kind'))
+
 
 class WeaveRevisionBuildEditor(RevisionBuildEditor):
     """Subversion commit editor that can write to a weave-based repository.




More information about the bazaar-commits mailing list