Rev 344: Avoid opening possibly remote branches if it can be avoided. in http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev

Jelmer Vernooij jelmer at samba.org
Mon Jan 1 01:00:02 GMT 2007


------------------------------------------------------------
revno: 344
revision-id: jelmer at samba.org-20070101005921-uvksxw5fgj9fjhxp
parent: jelmer at samba.org-20061231205748-2molb5x3pspz17cx
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Mon 2007-01-01 01:59:21 +0100
message:
  Avoid opening possibly remote branches if it can be avoided.
modified:
  convert.py                     svn2bzr.py-20051018015439-cb4563bff29e632d
  format.py                      format.py-20060406233823-b6fa009fe35dfde7
=== modified file 'convert.py'
--- a/convert.py	2006-12-31 03:39:10 +0000
+++ b/convert.py	2007-01-01 00:59:21 +0000
@@ -93,16 +93,23 @@
             i = 0
             for (branch, revnum, exists) in existing_branches:
                 pb.update("%s:%d" % (branch, revnum), i, len(existing_branches))
-                source_branch = Branch.open("%s/%s" % (url, branch))
+                revid = source_repos.generate_revision_id(revnum, branch)
 
                 target_dir = os.path.join(output_dir, branch)
                 try:
                     target_branch = Branch.open(target_dir)
-                    target_branch.pull(source_branch)
+                    if not revid in target_branch.revision_history():
+                        source_branch = Branch.open("%s/%s" % (url, branch))
+                        target_branch.pull(source_branch)
                 except NotBranchError:
+                    source_branch = Branch.open("%s/%s" % (url, branch))
                     os.makedirs(target_dir)
-                    source_branch.bzrdir.sprout(target_dir, 
+                    try:
+                        source_branch.bzrdir.sprout(target_dir, 
                                                 source_branch.last_revision())
+                    except:
+                        os.rmdir(target_dir)
+                        raise
                 i+=1
         finally:
             pb.finished()

=== modified file 'format.py'
--- a/format.py	2006-12-31 20:57:48 +0000
+++ b/format.py	2007-01-01 00:59:21 +0000
@@ -96,7 +96,10 @@
         
         :return: instance of SvnRepository.
         """
-        return SvnRepository(self, SvnRaTransport(self.svn_root_url))
+        transport = self.root_transport
+        if self.svn_root_url != transport.base:
+            transport = SvnRaTransport(self.svn_root_url)
+        return SvnRepository(self, transport)
 
     def open_workingtree(self):
         """See BzrDir.open_workingtree().




More information about the bazaar-commits mailing list