Rev 445: Support commits in heavy checkouts. in file:///home/jelmer/bzr-svn/customrevids/

Jelmer Vernooij jelmer at samba.org
Fri May 18 19:01:27 BST 2007


At file:///home/jelmer/bzr-svn/customrevids/

------------------------------------------------------------
revno: 445
revision-id: jelmer at samba.org-20070518180127-pbj2l7tgikgxe77h
parent: jelmer at samba.org-20070518173705-7e51s6m9bdn3h6wd
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: customrevids
timestamp: Fri 2007-05-18 19:01:27 +0100
message:
  Support commits in heavy checkouts.
modified:
  NEWS                           news-20061231030336-h9fhq245ie0de8bs-1
  __init__.py                    __init__.py-20051008155114-eae558e6cf149e1d
  commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
  fetch.py                       fetch.py-20060625004942-x2lfaib8ra707a8p-1
  format.py                      format.py-20060406233823-b6fa009fe35dfde7
  tests/test_commit.py           test_commit.py-20060624213521-l5kcufywkh9mnilk-1
=== modified file 'NEWS'
--- a/NEWS	2007-05-16 13:30:28 +0000
+++ b/NEWS	2007-05-18 18:01:27 +0000
@@ -16,6 +16,10 @@
    * Remove branches when they are being replaced. Fixes DivergedBranches 
      error when using svn-import (#81908).
 
+   * Support true push (#80612).
+
+   * Support commits in heavy checkouts (#79330).
+
   IMPROVEMENTS
 
   PERFORMANCE

=== modified file '__init__.py'
--- a/__init__.py	2007-05-16 13:30:28 +0000
+++ b/__init__.py	2007-05-18 18:01:27 +0000
@@ -97,7 +97,8 @@
 
 from bzrlib.repository import InterRepository
 
-from fetch import InterSvnRepository
+from fetch import InterFromSvnRepository
+from commit import InterToSvnRepository
 
 BzrDirFormat.register_control_format(format.SvnFormat)
 
@@ -106,7 +107,8 @@
 
 BzrDirFormat.register_control_format(checkout.SvnWorkingTreeDirFormat)
 
-InterRepository.register_optimiser(InterSvnRepository)
+InterRepository.register_optimiser(InterFromSvnRepository)
+InterRepository.register_optimiser(InterToSvnRepository)
 
 from bzrlib.branch import Branch
 from bzrlib.commands import Command, register_command, display_command, Option

=== modified file 'commit.py'
--- a/commit.py	2007-05-18 16:49:29 +0000
+++ b/commit.py	2007-05-18 18:01:27 +0000
@@ -22,13 +22,15 @@
 from bzrlib.errors import InvalidRevisionId, DivergedBranches
 from bzrlib.inventory import Inventory
 import bzrlib.osutils as osutils
-from bzrlib.repository import RootCommitBuilder
+from bzrlib.repository import RootCommitBuilder, InterRepository
+from bzrlib.revision import NULL_REVISION
 from bzrlib.trace import mutter
 
 from repository import (SVN_PROP_BZR_MERGE, SVN_PROP_BZR_FILEIDS,
                         SVN_PROP_SVK_MERGE, SVN_PROP_BZR_REVISION_INFO, 
                         SVN_PROP_BZR_REVISION_ID, revision_id_to_svk_feature,
-                        generate_revision_metadata)
+                        generate_revision_metadata, SvnRepositoryFormat, 
+                        SvnRepository)
 from revids import escape_svn_path
 
 import os
@@ -505,3 +507,63 @@
             raise DivergedBranches(source, target)
         raise
 
+class InterToSvnRepository(InterRepository):
+    """Any to Subversion repository actions."""
+
+    _matching_repo_format = SvnRepositoryFormat()
+
+    @staticmethod
+    def _get_repo_format_to_test():
+        return None
+
+    def copy_content(self, revision_id=None, basis=None, pb=None):
+        """See InterRepository.copy_content."""
+        assert revision_id is not None, "fetching all revisions not supported"
+        # Go back over the LHS parent until we reach a revid we know
+        todo = []
+        while not self.target.has_revision(revision_id):
+            todo.append(revision_id)
+            revision_id = self.source.revision_parents(revision_id)[0]
+            if revision_id == NULL_REVISION:
+                raise "Unrelated repositories."
+        todo.reverse()
+        mutter("pushing %r into svn" % todo)
+        while len(todo) > 0:
+            revision_id = todo.pop()
+
+            rev = self.source.get_revision(revision_id)
+            inv = self.source.get_inventory(revision_id)
+
+            mutter('pushing %r' % (revision_id))
+
+            old_tree = self.source.revision_tree(revision_id)
+            parent_revid = self.source.revision_parents(revision_id)[0]
+            new_tree = self.source.revision_tree(parent_revid)
+
+            (bp, _) = self.target.lookup_revision_id(parent_revid)
+            target_branch = Branch.open("%s/%s" % (self.target.base, bp))
+
+            builder = SvnCommitBuilder(self.target, target_branch, 
+                               rev.parent_ids,
+                               target_branch.get_config(),
+                               rev.timestamp,
+                               rev.timezone,
+                               rev.committer,
+                               rev.properties, 
+                               revision_id,
+                               new_tree.inventory)
+                         
+            delta = new_tree.changes_from(old_tree)
+            builder.new_inventory = inv
+            replay_delta(builder, delta, old_tree)
+            builder.commit(rev.message)
+ 
+
+    def fetch(self, revision_id=None, pb=None):
+        """Fetch revisions. """
+        self.copy_content(revision_id=revision_id, pb=pb)
+
+    @staticmethod
+    def is_compatible(source, target):
+        """Be compatible with SvnRepository."""
+        return isinstance(target, SvnRepository)

=== modified file 'fetch.py'
--- a/fetch.py	2007-05-18 15:11:30 +0000
+++ b/fetch.py	2007-05-18 18:01:27 +0000
@@ -314,7 +314,7 @@
                                      self.file_stream, self.pool)
 
 
-class InterSvnRepository(InterRepository):
+class InterFromSvnRepository(InterRepository):
     """Svn to any repository actions."""
 
     _matching_repo_format = SvnRepositoryFormat()
@@ -467,6 +467,7 @@
     @staticmethod
     def is_compatible(source, target):
         """Be compatible with SvnRepository."""
+        mutter("Checking from %r %r" % (source, target))
         # FIXME: Also check target uses VersionedFile
         return isinstance(source, SvnRepository)
 

=== modified file 'format.py'
--- a/format.py	2007-05-17 16:52:31 +0000
+++ b/format.py	2007-05-18 18:01:27 +0000
@@ -24,7 +24,6 @@
 from svn.core import SubversionException
 import svn.core, svn.repos
 
-from branch import SvnBranch
 from repository import SvnRepository
 from scheme import BranchingScheme
 from transport import SvnRaTransport, bzr_to_svn_url, get_svn_ra_transport
@@ -124,6 +123,7 @@
 
     def create_branch(self):
         """See BzrDir.create_branch()."""
+        from branch import SvnBranch
         repos = self.open_repository()
         # TODO: Check if there are any revisions in this repository 
         # yet if it is the top-level one
@@ -133,6 +133,7 @@
 
     def open_branch(self, unsupported=True):
         """See BzrDir.open_branch()."""
+        from branch import SvnBranch
 
         if not self.scheme.is_branch(self.branch_path) and \
            not self.scheme.is_tag(self.branch_path):

=== modified file 'tests/test_commit.py'
--- a/tests/test_commit.py	2007-05-18 17:37:05 +0000
+++ b/tests/test_commit.py	2007-05-18 18:01:27 +0000
@@ -383,4 +383,6 @@
         local_dir.open_branch().bind(master_branch)
         self.build_tree({'b/file': 'data'})
         wt.add('file')
-        wt.commit(message="Commit from Bzr")
+        revid = wt.commit(message="Commit from Bzr")
+        master_branch = Branch.open(repos_url)
+        self.assertEquals(revid, master_branch.last_revision())




More information about the bazaar-commits mailing list