Rev 1422: use connection for commit editor. in http://people.samba.org/bzr/jelmer/bzr-svn/trunk

Jelmer Vernooij jelmer at samba.org
Tue Jul 1 23:51:27 BST 2008


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

------------------------------------------------------------
revno: 1422
revision-id: jelmer at samba.org-20080701225123-26f5gbqf9nmb9s7j
parent: jelmer at samba.org-20080701221549-rwwvwbs7zka6gebr
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Wed 2008-07-02 00:51:23 +0200
message:
  use connection for commit editor.
modified:
  commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
  transport.py                   transport.py-20060406231150-b3472d06b3a0818d
=== modified file 'commit.py'
--- a/commit.py	2008-07-01 22:15:49 +0000
+++ b/commit.py	2008-07-01 22:51:23 +0000
@@ -455,55 +455,61 @@
             for prop in self._svn_revprops:
                 if not properties.is_valid_property_name(prop):
                     warning("Setting property %r with invalid characters in name", prop)
-            if self.repository.transport.has_capability("commit-revprops"):
-                self.editor = self.repository.transport.get_commit_editor(
-                        self._svn_revprops, done, None, False)
-                self._svn_revprops = {}
-            else:
-                if set_revprops:
-                    raise
-                # Try without bzr: revprops
-                self.editor = self.repository.transport.get_commit_editor({
-                    properties.PROP_REVISION_LOG: self._svn_revprops[properties.PROP_REVISION_LOG]},
-                    done, None, False)
-                del self._svn_revprops[properties.PROP_REVISION_LOG]
-
-            root = self.editor.open_root(self.base_revnum)
-
-            replace_existing = False
-            # See whether the base of the commit matches the lhs parent
-            # if not, we need to replace the existing directory
-            if len(bp_parts) == len(existing_bp_parts):
-                if self.base_path.strip("/") != "/".join(bp_parts).strip("/"):
-                    replace_existing = True
-                elif self.base_revnum < self.repository._log.find_latest_change(self.branch.get_branch_path(), repository_latest_revnum):
-                    replace_existing = True
-
-            if replace_existing and self.branch._get_append_revisions_only():
-                raise AppendRevisionsOnlyViolation(self.branch.base)
-
-            # TODO: Accept create_prefix argument (#118787)
-            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_editors[-1])
-
-            # Set all the revprops
-            if self.push_metadata:
-                for prop, value in self._svnprops.items():
-                    if not properties.is_valid_property_name(prop):
-                        warning("Setting property %r with invalid characters in name", prop)
-                    if value is not None:
-                        value = value.encode('utf-8')
-                    branch_editors[-1].change_prop(prop, value)
-                    self.mutter("Setting root file property %r -> %r", prop, value)
-
-            for dir_editor in reversed(branch_editors):
-                dir_editor.close()
-
-            self.editor.close()
+            has_commit_revprops = self.repository.transport.has_capability("commit-revprops")
+            conn = self.repository.transport.get_connection()
+            try:
+                if has_commit_revprops:
+                    self.editor = conn.get_commit_editor(
+                            self._svn_revprops, done, None, False)
+                    self._svn_revprops = {}
+                else:
+                    if set_revprops:
+                        raise
+                    # Try without bzr: revprops
+                    self.editor = conn.get_commit_editor({
+                        properties.PROP_REVISION_LOG: self._svn_revprops[properties.PROP_REVISION_LOG]},
+                        done, None, False)
+                    del self._svn_revprops[properties.PROP_REVISION_LOG]
+
+                root = self.editor.open_root(self.base_revnum)
+
+                replace_existing = False
+                # See whether the base of the commit matches the lhs parent
+                # if not, we need to replace the existing directory
+                if len(bp_parts) == len(existing_bp_parts):
+                    if self.base_path.strip("/") != "/".join(bp_parts).strip("/"):
+                        replace_existing = True
+                    elif self.base_revnum < self.repository._log.find_latest_change(self.branch.get_branch_path(), repository_latest_revnum):
+                        replace_existing = True
+
+                if replace_existing and self.branch._get_append_revisions_only():
+                    raise AppendRevisionsOnlyViolation(self.branch.base)
+
+                # TODO: Accept create_prefix argument (#118787)
+                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_editors[-1])
+
+                # Set all the revprops
+                if self.push_metadata:
+                    for prop, value in self._svnprops.items():
+                        if not properties.is_valid_property_name(prop):
+                            warning("Setting property %r with invalid characters in name", prop)
+                        if value is not None:
+                            value = value.encode('utf-8')
+                        branch_editors[-1].change_prop(prop, value)
+                        self.mutter("Setting root file property %r -> %r", prop, value)
+
+                for dir_editor in reversed(branch_editors):
+                    dir_editor.close()
+
+                self.editor.close()
+            finally:
+                if not conn.busy:
+                    self.repository.transport.add_connection(conn)
         finally:
             lock.unlock()
 

=== modified file 'transport.py'
--- a/transport.py	2008-07-01 21:52:34 +0000
+++ b/transport.py	2008-07-01 22:51:23 +0000
@@ -441,12 +441,6 @@
         finally:
             self.add_connection(conn)
 
-    def get_commit_editor(self, revprops, done_cb=None, 
-                          lock_token=None, keep_locks=False):
-        conn = self._open_real_transport()
-        self.mutter('svn get-commit-editor %r' % (revprops,))
-        return conn.get_commit_editor(revprops, done_cb, lock_token, keep_locks)
-
     def listable(self):
         """See Transport.listable().
         """




More information about the bazaar-commits mailing list