Rev 424: Wrap reporter API in a bit more pythonic way, also making it easier to replace later by another implementation. in http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev

Jelmer Vernooij jelmer at samba.org
Fri Feb 2 19:48:35 GMT 2007


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

------------------------------------------------------------
revno: 424
revision-id: jelmer at samba.org-20070202194810-u6ce2rs57hzaykt4
parent: jelmer at samba.org-20070202141332-yt8jneutdi68j697
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Fri 2007-02-02 20:48:10 +0100
message:
  Wrap reporter API in a bit more pythonic way, also making it easier to replace later by another implementation.
modified:
  NEWS                           news-20061231030336-h9fhq245ie0de8bs-1
  fetch.py                       fetch.py-20060625004942-x2lfaib8ra707a8p-1
  logwalker.py                   logwalker.py-20060621215743-c13fhfnyzh1xzwh2-1
  tests/__init__.py              __init__.py-20060508151940-e9f4d914801a2535
  transport.py                   transport.py-20060406231150-b3472d06b3a0818d
  tree.py                        tree.py-20060624222557-dudlwqcmkf22lt2s-1
=== modified file 'NEWS'
--- a/NEWS	2007-02-02 11:39:47 +0000
+++ b/NEWS	2007-02-02 19:48:10 +0000
@@ -13,6 +13,9 @@
    * svn-import will no longer spin using CPU if the target directory 
      did not exist (#80223).
 
+   * Remove branches when they are being replaced. Fixes DivergedBranches 
+     error when using svn-import (#81908).
+
   IMPROVEMENTS
 
    * A proper warning will now be printed if no sqlite implementation is 

=== modified file 'fetch.py'
--- a/fetch.py	2007-01-06 16:58:18 +0000
+++ b/fetch.py	2007-02-02 19:48:10 +0000
@@ -28,7 +28,7 @@
 import os
 
 from svn.core import SubversionException, Pool
-import svn.core, svn.ra
+import svn.core
 
 from fileids import generate_file_id
 from repository import (SvnRepository, SVN_PROP_BZR_MERGE, SVN_PROP_SVK_MERGE,
@@ -375,31 +375,29 @@
 
                 if parent_revid is None:
                     transport.reparent("%s/%s" % (repos_root, branch))
-                    reporter, reporter_baton = transport.do_update(
+                    reporter = transport.do_update(
                                    revnum, "", True, edit, edit_baton, pool)
 
                     # Report status of existing paths
-                    svn.ra.reporter2_invoke_set_path(reporter, reporter_baton, 
-                        "", revnum, True, None, pool)
+                    reporter.set_path("", revnum, True, None, pool)
                 else:
                     (parent_branch, parent_revnum) = self.source.parse_revision_id(parent_revid)
                     transport.reparent("%s/%s" % (repos_root, parent_branch))
 
                     if parent_branch != branch:
                         switch_url = "%s/%s" % (repos_root, branch)
-                        reporter, reporter_baton = transport.do_switch(
+                        reporter = transport.do_switch(
                                    revnum, "", True, 
                                    switch_url, edit, edit_baton, pool)
                     else:
-                        reporter, reporter_baton = transport.do_update(
+                        reporter = transport.do_update(
                                    revnum, "", True, edit, edit_baton, pool)
 
                     # Report status of existing paths
-                    svn.ra.reporter2_invoke_set_path(reporter, reporter_baton, 
-                        "", parent_revnum, False, None, pool)
+                    reporter.set_path("", parent_revnum, False, None, pool)
 
                 transport.lock()
-                svn.ra.reporter2_invoke_finish_report(reporter, reporter_baton, pool)
+                reporter.finish_report(pool)
                 transport.unlock()
 
                 prev_inv = editor.inventory

=== modified file 'logwalker.py'
--- a/logwalker.py	2007-02-01 10:37:09 +0000
+++ b/logwalker.py	2007-02-02 19:48:10 +0000
@@ -298,11 +298,10 @@
         edit, baton = svn.delta.make_editor(editor, pool)
         root_repos = self.transport.get_repos_root()
         self.transport.reparent(os.path.join(root_repos, path))
-        reporter, reporter_baton = self.transport.do_update(
+        reporter = self.transport.do_update(
                         revnum, "", True, edit, baton, pool)
-        svn.ra.reporter2_invoke_set_path(reporter, reporter_baton, "", revnum, 
-                                         True, None, pool)
-        svn.ra.reporter2_invoke_finish_report(reporter, reporter_baton, pool)
+        reporter.set_path("", revnum, True, None, pool)
+        reporter.finish_report(pool)
         return editor.files
 
     def get_previous(self, path, revnum):

=== modified file 'tests/__init__.py'
--- a/tests/__init__.py	2007-01-29 15:19:34 +0000
+++ b/tests/__init__.py	2007-02-02 19:48:10 +0000
@@ -24,7 +24,7 @@
 
 RENAMES = False
 
-import svn.ra, svn.repos, svn.wc
+import svn.repos, svn.wc
 
 class TestCaseWithSubversionRepository(TestCaseInTempDir):
     """A test case that provides the ability to build Subversion 
@@ -191,17 +191,6 @@
         self.make_checkout(repos_url, clientpath)
         return repos_url
 
-    def make_ra(self, relpath):
-        """Create a repository and a ra connection to it. 
-        
-        :param relpath: Path to create repository at.
-        :return: The ra connection.
-        """
-
-        repos_url = self.make_repository(relpath)
-
-        return svn.ra.open2(repos_url, svn.ra.callbacks2_t(), None, None)
-
     def dumpfile(self, repos):
         """Create a dumpfile for the specified repository.
 

=== modified file 'transport.py'
--- a/transport.py	2007-01-31 12:02:55 +0000
+++ b/transport.py	2007-02-02 19:48:10 +0000
@@ -120,6 +120,33 @@
                 raise NotBranchError(path=url)
             raise
 
+    class Reporter:
+        def __init__(self, (reporter, report_baton)):
+            self._reporter = reporter
+            self._baton = report_baton
+
+        def set_path(self, path, revnum, start_empty, lock_token, pool=None):
+            svn.ra.reporter2_invoke_set_path(self._reporter, self._baton, 
+                        path, revnum, start_empty, lock_token, pool)
+
+        def delete_path(self, path, pool=None):
+            svn.ra.reporter2_invoke_delete_path(self._reporter, self._baton,
+                    path, pool)
+
+        def link_path(self, path, url, revision, start_empty, lock_token, 
+                      pool=None):
+            svn.ra.reporter2_invoke_link_path(self._reporter, self._baton,
+                    path, url, revision, start_empty, lock_token,
+                    pool)
+
+        def finish_report(self, pool=None):
+            svn.ra.reporter2_invoke_finish_report(self._reporter, 
+                    self._baton, pool)
+
+        def abort_report(self, pool=None):
+            svn.ra.reporter2_invoke_abort_report(self._reporter, 
+                    self._baton, pool)
+
     def lock(self):
         assert (not self.is_locked)
         self.is_locked = True
@@ -166,7 +193,7 @@
     @convert_svn_error
     def do_switch(self, switch_rev, switch_target, recurse, switch_url, *args, **kwargs):
         mutter('svn switch -r %d %r -> %r' % (switch_rev, switch_target, switch_url))
-        return svn.ra.do_switch(self._ra, switch_rev, switch_target, recurse, switch_url, *args, **kwargs)
+        return self.Reporter(svn.ra.do_switch(self._ra, switch_rev, switch_target, recurse, switch_url, *args, **kwargs))
 
     @need_lock
     @convert_svn_error
@@ -242,7 +269,7 @@
     @convert_svn_error
     def do_update(self, revnum, path, *args, **kwargs):
         mutter('svn update -r %r %r' % (revnum, path))
-        return svn.ra.do_update(self._ra, revnum, path, *args, **kwargs)
+        return self.Reporter(svn.ra.do_update(self._ra, revnum, path, *args, **kwargs))
 
     @need_lock
     @convert_svn_error

=== modified file 'tree.py'
--- a/tree.py	2007-01-10 01:50:47 +0000
+++ b/tree.py	2007-02-02 19:48:10 +0000
@@ -32,7 +32,7 @@
 from cStringIO import StringIO
 import urllib
 
-import svn.core, svn.wc, svn.delta, svn.ra
+import svn.core, svn.wc, svn.delta
 from svn.core import SubversionException, Pool
 
 def apply_txdelta_handler(src_stream, target_stream, pool):
@@ -62,12 +62,11 @@
         self.file_data = {}
         editor, baton = svn.delta.make_editor(self.editor, pool)
         root_repos = repository.transport.get_repos_root()
-        reporter, reporter_baton = repository.transport.do_switch(
+        reporter = repository.transport.do_switch(
                 self.revnum, "", True, 
                 os.path.join(root_repos, self.branch_path), editor, baton, pool)
-        svn.ra.reporter2_invoke_set_path(reporter, reporter_baton, "", 0, 
-                True, None, pool)
-        svn.ra.reporter2_invoke_finish_report(reporter, reporter_baton, pool)
+        reporter.set_path("", 0, True, None, pool)
+        reporter.finish_report(pool)
         pool.destroy()
 
      def get_file_lines(self, file_id):




More information about the bazaar-commits mailing list