Rev 1238: Rename baton to editor, which is more appropriate for the OO interface. in http://people.samba.org/bzr/jelmer/bzr-svn/0.4/

Jelmer Vernooij jelmer at samba.org
Tue Jun 17 23:26:01 BST 2008


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

------------------------------------------------------------
revno: 1238
revision-id: jelmer at samba.org-20080617222600-mwb5selnhivyzmtu
parent: jelmer at samba.org-20080617222130-x7hg1cok27gp6qme
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Wed 2008-06-18 00:26:00 +0200
message:
  Rename baton to editor, which is more appropriate for the OO interface.
modified:
  commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
=== modified file 'commit.py'
--- a/commit.py	2008-06-17 22:21:30 +0000
+++ b/commit.py	2008-06-17 22:26:00 +0000
@@ -185,28 +185,28 @@
         """See CommitBuilder.modified_directory()."""
         self.modified_dirs.add(file_id)
 
-    def _file_process(self, file_id, contents, baton):
+    def _file_process(self, file_id, contents, file_editor):
         """Pass the changes to a file to the Subversion commit editor.
 
         :param file_id: Id of the file to modify.
         :param contents: Contents of the file.
-        :param baton: Baton under which the file is known to the editor.
+        :param file_editor: Subversion FileEditor object.
         """
-        assert baton is not None
-        (txdelta, txbaton) = baton.apply_textdelta(None)
+        assert file_editor is not None
+        (txdelta, txbaton) = file_editor.apply_textdelta(None)
         digest = txdelta_send_stream(StringIO(contents), txdelta, txbaton)
         if 'validate' in debug.debug_flags:
             from fetch import md5_strings
             assert digest == md5_strings(contents)
 
-    def _dir_process(self, path, file_id, baton):
+    def _dir_process(self, path, file_id, dir_editor):
         """Pass the changes to a directory to the commit editor.
 
         :param path: Path (from repository root) to the directory.
         :param file_id: File id of the directory
-        :param baton: Baton of the directory for the editor.
+        :param dir_editor: Subversion DirEditor object.
         """
-        assert baton is not None
+        assert dir_editor is not None
         # Loop over entries of file_id in self.old_inv
         # remove if they no longer exist with the same name
         # or parents
@@ -222,7 +222,7 @@
                     # ... name changed
                     self.new_inventory[child_ie.file_id].name != child_name):
                     self.mutter('removing %r(%r)', (child_name, child_ie.file_id))
-                    baton.delete_entry(
+                    dir_editor.delete_entry(
                         urlutils.join(self.branch.get_branch_path(), path, child_name), 
                         self.base_revnum)
 
@@ -240,7 +240,7 @@
             # add them if they didn't exist in old_inv 
             if not child_ie.file_id in self.old_inv:
                 self.mutter('adding %s %r', child_ie.kind, new_child_path)
-                child_baton = baton.add_file(
+                child_editor = dir_editor.add_file(
                     full_new_child_path, None, -1)
 
 
@@ -250,7 +250,7 @@
                 self.mutter('copy %s %r -> %r', child_ie.kind, 
                                   self.old_inv.id2path(child_ie.file_id), 
                                   new_child_path)
-                child_baton = baton.add_file(
+                child_editor = dir_editor.add_file(
                         full_new_child_path, 
                     urlutils.join(self.repository.transport.svn_url, self.base_path, self.old_inv.id2path(child_ie.file_id)),
                     self.base_revnum)
@@ -259,13 +259,13 @@
             elif child_ie.revision is None:
                 self.mutter('open %s %r', child_ie.kind, new_child_path)
 
-                child_baton = baton.open_file(
+                child_editor = dir_editor.open_file(
                         full_new_child_path, self.base_revnum)
 
             else:
                 # Old copy of the file was retained. No need to send changes
                 assert child_ie.file_id not in self.modified_files
-                child_baton = None
+                child_editor = None
 
             if child_ie.file_id in self.old_inv:
                 old_executable = self.old_inv[child_ie.file_id].executable
@@ -274,13 +274,13 @@
                 old_special = False
                 old_executable = False
 
-            if child_baton is not None:
+            if child_editor is not None:
                 if old_executable != child_ie.executable:
                     if child_ie.executable:
                         value = properties.PROP_EXECUTABLE_VALUE
                     else:
                         value = None
-                    child_baton.change_prop(
+                    child_editor.change_prop(
                             properties.PROP_EXECUTABLE, value)
 
                 if old_special != (child_ie.kind == 'symlink'):
@@ -289,16 +289,16 @@
                     else:
                         value = None
 
-                    child_baton.change_prop(
+                    child_editor.change_prop(
                             properties.PROP_SPECIAL, value)
 
             # handle the file
             if child_ie.file_id in self.modified_files:
                 self._file_process(child_ie.file_id, 
-                    self.modified_files[child_ie.file_id], child_baton)
+                    self.modified_files[child_ie.file_id], child_editor)
 
-            if child_baton is not None:
-                child_baton.close(None)
+            if child_editor is not None:
+                child_editor.close(None)
 
         # Loop over subdirectories of file_id in self.new_inventory
         for child_name in self.new_inventory[file_id].children:
@@ -310,7 +310,7 @@
             # add them if they didn't exist in old_inv 
             if not child_ie.file_id in self.old_inv:
                 self.mutter('adding dir %r', child_ie.name)
-                child_baton = baton.add_directory(
+                child_editor = dir_editor.add_directory(
                     urlutils.join(self.branch.get_branch_path(), 
                                   new_child_path), None, -1)
 
@@ -318,7 +318,7 @@
             elif self.old_inv.id2path(child_ie.file_id) != new_child_path:
                 old_child_path = self.old_inv.id2path(child_ie.file_id)
                 self.mutter('copy dir %r -> %r', old_child_path, new_child_path)
-                child_baton = baton.add_directory(
+                child_editor = dir_editor.add_directory(
                     urlutils.join(self.branch.get_branch_path(), new_child_path),
                     urlutils.join(self.repository.transport.svn_url, self.base_path, old_child_path), self.base_revnum)
 
@@ -327,7 +327,7 @@
             elif self.new_inventory[child_ie.file_id].revision is None:
                 self.mutter('open dir %r', new_child_path)
 
-                child_baton = baton.open_directory(
+                child_editor = dir_editor.open_directory(
                         urlutils.join(self.branch.get_branch_path(), new_child_path), 
                         self.base_revnum)
             else:
@@ -336,15 +336,15 @@
 
             # Handle this directory
             if child_ie.file_id in self.modified_dirs:
-                self._dir_process(new_child_path, child_ie.file_id, child_baton)
-
-            child_baton.close()
-
-    def open_branch_batons(self, root, elements, existing_elements, 
+                self._dir_process(new_child_path, child_ie.file_id, child_editor)
+
+            child_editor.close()
+
+    def open_branch_editors(self, root, elements, existing_elements, 
                            base_path, base_rev, replace_existing):
-        """Open a specified directory given a baton for the repository root.
+        """Open a specified directory given an editor for the repository root.
 
-        :param root: Baton for the repository root
+        :param root: Editor for the repository root
         :param elements: List of directory names to open
         :param existing_elements: List of directory names that exist
         :param base_path: Path to base top-level branch on
@@ -479,12 +479,12 @@
                 raise AppendRevisionsOnlyViolation(self.branch.base)
 
             # TODO: Accept create_prefix argument (#118787)
-            branch_batons = self.open_branch_batons(root, bp_parts,
+            branch_editors = self.open_branch_editors(root, bp_parts,
                 existing_bp_parts, self.base_path, self.base_revnum, 
                 replace_existing)
 
             self._dir_process("", self.new_inventory.root.file_id, 
-                branch_batons[-1])
+                branch_editors[-1])
 
             # Set all the revprops
             for prop, value in self._svnprops.items():
@@ -492,11 +492,11 @@
                     warning("Setting property %r with invalid characters in name", prop)
                 if value is not None:
                     value = value.encode('utf-8')
-                branch_batons[-1].change_prop(prop, value)
+                branch_editors[-1].change_prop(prop, value)
                 self.mutter("Setting root file property %r -> %r", prop, value)
 
-            for baton in reversed(branch_batons):
-                baton.close()
+            for dir_editor in reversed(branch_editors):
+                dir_editor.close()
 
             self.editor.close()
         finally:




More information about the bazaar-commits mailing list