Rev 395: merge from upstream in http://people.samba.org/bzr/jelmer/bzr-svn/ver3

Jelmer Vernooij jelmer at samba.org
Sun Jan 14 03:05:33 GMT 2007


------------------------------------------------------------
revno: 395
revision-id: jelmer at samba.org-20070114030508-miy4yc1daskumby1
parent: jelmer at samba.org-20070114015613-yfjhkjcvl3fbt8b4
parent: jelmer at samba.org-20070110052456-z9werxhohglupk05
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: ver3
timestamp: Sun 2007-01-14 04:05:08 +0100
message:
  merge from upstream
modified:
  convert.py                     svn2bzr.py-20051018015439-cb4563bff29e632d
  tests/test_convert.py          test_convert.py-20060705203611-b1l0bapeku6foco0-1
    ------------------------------------------------------------
    revno: 389.1.5
    merged: jelmer at samba.org-20070110052456-z9werxhohglupk05
    parent: jelmer at samba.org-20070110015047-2it8mj9d7bclg2ju
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: main
    timestamp: Wed 2007-01-10 06:24:56 +0100
    message:
      More efficient use of connection, fix bug when used with none-schemes and shared repositories
=== modified file 'convert.py'
--- a/convert.py	2007-01-02 00:45:53 +0000
+++ b/convert.py	2007-01-10 05:24:56 +0000
@@ -26,9 +26,9 @@
 from bzrlib.plugin import load_plugins
 load_plugins()
 
-from bzrlib.bzrdir import BzrDir
+from bzrlib.bzrdir import BzrDir, BzrDirFormat
 from bzrlib.branch import Branch
-from bzrlib.errors import BzrError, NotBranchError, NoSuchFile
+from bzrlib.errors import BzrError, NotBranchError, NoSuchFile, NoRepositoryPresent
 import bzrlib.osutils as osutils
 from bzrlib.progress import DummyProgress
 from bzrlib.repository import Repository
@@ -78,6 +78,7 @@
                        working_trees=False, all=False):
     assert not all or create_shared_repo
 
+
     if os.path.isfile(url):
         tmp_repos = tempfile.mkdtemp(prefix='bzr-svn-dump-')
         mutter('loading dumpfile %r to %r' % (url, tmp_repos))
@@ -86,21 +87,29 @@
     else:
         tmp_repos = None
 
+    dirs = {}
+    to_transport = get_transport(output_url)
+    def get_dir(path):
+        if dirs.has_key(path):
+            return dirs[path]
+        nt = to_transport.clone(path)
+        try:
+            dirs[path] = BzrDir.open_from_transport(nt)
+        except NotBranchError:
+            transport_makedirs(to_transport, urlutils.join(to_transport.base, path))
+            dirs[path] = BzrDirFormat.get_default_format().initialize_on_transport(nt)
+        return dirs[path]
+
     try:
         source_repos = SvnRepository.open(url)
         source_repos.set_branching_scheme(scheme)
-        to_transport = get_transport(output_url)
 
         if create_shared_repo:
             try:
-                target_repos = Repository.open(output_url)
-                assert target_repos.is_shared()
-            except NotBranchError:
-                if scheme.is_branch(""):
-                    BzrDir.create_branch_and_repo(output_url)
-                else:
-                    BzrDir.create_repository(output_url, shared=True)
-                target_repos = Repository.open(output_url)
+                target_repos = get_dir("").open_repository()
+                assert scheme.is_branch("") or target_repos.is_shared()
+            except NoRepositoryPresent:
+                target_repos = get_dir("").create_repository(shared=True)
             target_repos.set_make_working_trees(working_trees)
             if all:
                 source_repos.copy_content_into(target_repos)
@@ -123,17 +132,21 @@
                 pb.update("%s:%d" % (branch, revnum), i, len(existing_branches))
                 revid = source_repos.generate_revision_id(revnum, branch)
 
-                target_url = urlutils.join(to_transport.base, branch)
+                target_dir = get_dir(branch)
+                if not create_shared_repo:
+                    try:
+                        target_dir.open_repository()
+                    except NoRepositoryPresent:
+                        target_dir.create_repository()
                 try:
-                    target_branch = Branch.open(target_url)
-                    if not revid in target_branch.revision_history():
-                        source_branch = Branch.open("%s/%s" % (url, branch))
-                        target_branch.pull(source_branch)
+                    target_branch = target_dir.open_branch()
                 except NotBranchError:
-                    source_branch = Branch.open("%s/%s" % (url, branch))
-                    transport_makedirs(to_transport, target_url)
-                    source_branch.bzrdir.sprout(target_url, 
-                                                source_branch.last_revision())
+                    target_branch = target_dir.create_branch()
+                if not revid in target_branch.revision_history():
+                    source_branch = Branch.open(urlutils.join(url, branch))
+                    target_branch.pull(source_branch)
+                if working_trees and not target_dir.has_workingtree():
+                    target_dir.create_workingtree()
                 i+=1
         finally:
             pb.finished()

=== modified file 'tests/test_convert.py'
--- a/tests/test_convert.py	2007-01-09 04:25:01 +0000
+++ b/tests/test_convert.py	2007-01-10 05:24:56 +0000
@@ -91,7 +91,6 @@
         newrepos = Repository.open("e")
         self.assertFalse(newrepos.has_revision(oldrepos.generate_revision_id(2, "branches/somebranch")))
 
-
     def test_fetch_dead(self):
         self.build_tree({'dc/branches/somebranch/somefile': 'data'})
         self.client_add("dc/branches/somebranch")
@@ -113,6 +112,18 @@
 
         self.assertTrue(Repository.open("e").is_shared())
 
+    def test_shared_import_continue_with_wt(self):
+        convert_repository("svn+"+self.repos_url, "e", 
+                TrunkBranchingScheme(), working_trees=True)
+        convert_repository("svn+"+self.repos_url, "e", 
+                TrunkBranchingScheme(), working_trees=True)
+
+    def test_shared_import_nonescheme_empty(self):
+        BzrDir.create_repository("e", shared=True)
+
+        convert_repository("svn+"+self.repos_url, "e", 
+                NoBranchingScheme(), True)
+
     def test_shared_import_with_wt(self):
         BzrDir.create_repository("e", shared=True)
 




More information about the bazaar-commits mailing list