Rev 426: Merge upstream, add helper function for parsing revision ids on branches. in sftp://people.samba.org/~/bzr/bzr-svn/customrevids/

Jelmer Vernooij jelmer at samba.org
Sun Apr 15 18:35:46 BST 2007


At sftp://people.samba.org/~/bzr/bzr-svn/customrevids/

------------------------------------------------------------
revno: 426
revision-id: jelmer at samba.org-20070415173504-fiwgffj0ijbvqj44
parent: jelmer at samba.org-20070414180015-n29pge396twclo2t
parent: jelmer at samba.org-20070415161553-4s5vprta60mch70r
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: customrevids
timestamp: Sun 2007-04-15 19:35:04 +0200
message:
  Merge upstream, add helper function for parsing revision ids on branches.
modified:
  NEWS                           news-20061231030336-h9fhq245ie0de8bs-1
  TODO                           todo-20060729211917-2kpobww0zyvvo0j2-1
  branch.py                      svnbranch.py-20051017135706-11c749eb0dab04a7
  checkout.py                    workingtree.py-20060306120941-b083cb0fdd4a69de
  commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
  convert.py                     svn2bzr.py-20051018015439-cb4563bff29e632d
  format.py                      format.py-20060406233823-b6fa009fe35dfde7
  tests/test_branch.py           test_branch.py-20060508162215-74ffeb5d608f8e20
  tests/test_checkout.py         test_checkout.py-20070101154110-eevkc29qj0q7udz5-1
  tests/test_commit.py           test_commit.py-20060624213521-l5kcufywkh9mnilk-1
  tests/test_convert.py          test_convert.py-20060705203611-b1l0bapeku6foco0-1
    ------------------------------------------------------------
    revno: 421.1.23
    merged: jelmer at samba.org-20070415161553-4s5vprta60mch70r
    parent: jelmer at samba.org-20070328121602-c6b3z2zc093l02h3
    parent: jelmer at samba.org-20070415161300-w8q2nd1f32e4ik16
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: main
    timestamp: Sun 2007-04-15 18:15:53 +0200
    message:
      Merge some fixes from 0.3 branch.
    ------------------------------------------------------------
    revno: 402.1.43
    merged: jelmer at samba.org-20070415161300-w8q2nd1f32e4ik16
    parent: jelmer at samba.org-20070408133954-7eltt6nsd6orgvnw
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.3
    timestamp: Sun 2007-04-15 18:13:00 +0200
    message:
      Fix compatibility with bzr.dev.
    ------------------------------------------------------------
    revno: 402.1.42
    merged: jelmer at samba.org-20070408133954-7eltt6nsd6orgvnw
    parent: jelmer at samba.org-20070408012744-947rmcugvtga8ld8
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.3
    timestamp: Sun 2007-04-08 15:39:54 +0200
    message:
      No longer mark bug 91641 as fixed.
    ------------------------------------------------------------
    revno: 402.1.41
    merged: jelmer at samba.org-20070408012744-947rmcugvtga8ld8
    parent: jelmer at samba.org-20070403203246-0tnykd16qpi4uy3n
    parent: mwh at quickbeam-20070407224317-ltv1d3qhujm9pypi
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.3
    timestamp: Sun 2007-04-08 03:27:44 +0200
    message:
      Add test for bug #91641
        ------------------------------------------------------------
        revno: 402.1.19.1.1
        merged: mwh at quickbeam-20070407224317-ltv1d3qhujm9pypi
        parent: jelmer at samba.org-20070311232925-2nc3xpxxmoftgbyi
        committer: Michael Hudson <mwh at quickbeam>
        branch nick: bzrsvn
        timestamp: Sat 2007-04-07 23:43:17 +0100
        message:
          failing test
    ------------------------------------------------------------
    revno: 402.1.40
    merged: jelmer at samba.org-20070403203246-0tnykd16qpi4uy3n
    parent: jelmer at samba.org-20070403125101-53li3xzbpbsxryb3
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.3
    timestamp: Tue 2007-04-03 22:32:46 +0200
    message:
      Set parent URLs in svn-import. (#94406)
    ------------------------------------------------------------
    revno: 402.1.39
    merged: jelmer at samba.org-20070403125101-53li3xzbpbsxryb3
    parent: jelmer at samba.org-20070325151508-eliztm1ms969fjk8
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: 0.3
    timestamp: Tue 2007-04-03 14:51:01 +0200
    message:
      Initial work on supporting "upgrades" of .svn directories to .bzr directories.
=== modified file 'NEWS'
--- a/NEWS	2007-03-15 16:30:13 +0000
+++ b/NEWS	2007-04-15 16:15:53 +0000
@@ -30,6 +30,8 @@
 
   * Don't do extra checkout before push if possible. (#91885)
 
+  * Set parent URLs in svn-import. (#94406)
+
 bzr-svn 0.3.2	2007-03-13
 
   BUG FIXES

=== modified file 'TODO'
--- a/TODO	2007-03-25 18:41:40 +0000
+++ b/TODO	2007-04-15 16:15:53 +0000
@@ -1,3 +1,4 @@
+- rename 'main' to 0.4
 - simplify find_branches by using Transport.list_dir() ?
 - replace 'undefined' by scheme name in revision ids
 - fix commits in heavyweight checkouts somehow
@@ -19,3 +20,4 @@
 - add tests for objects returned by WorkingTree.pull(), Branch.pull()
 - blackbox tests
 - test Branch.get_parent()
+- split fetch tests out of test_repos

=== modified file 'branch.py'
--- a/branch.py	2007-03-25 18:41:40 +0000
+++ b/branch.py	2007-04-15 17:35:04 +0000
@@ -78,6 +78,11 @@
         checkout_branch.pull(self, stop_revision=revision_id)
         return checkout.create_workingtree(revision_id)
 
+    def parse_revision_id(self, revid):
+        (bp, revnum) = self.repository.parse_revision_id(revid)
+        assert bp == self.branch_path
+        return revnum
+
     def _create_lightweight_checkout(self, to_location, revision_id=None):
         peg_rev = svn.core.svn_opt_revision_t()
         peg_rev.kind = svn.core.svn_opt_revision_head
@@ -86,8 +91,7 @@
         if revision_id is None:
             rev.kind = svn.core.svn_opt_revision_head
         else:
-            assert revision_id in self.revision_history()
-            (_, revnum) = self.repository.parse_revision_id(revision_id)
+            revnum = self.parse_revision_id(revision_id)
             rev.kind = svn.core.svn_opt_revision_number
             rev.value.number = revnum
             mutter('hist: %r' % self.revision_history())

=== modified file 'checkout.py'
--- a/checkout.py	2007-03-25 19:50:45 +0000
+++ b/checkout.py	2007-04-15 17:35:04 +0000
@@ -29,6 +29,7 @@
 from bzrlib.workingtree import WorkingTree, WorkingTreeFormat
 
 from branch import SvnBranch
+from convert import SvnConverter
 from repository import (SvnRepository, escape_svn_path, SVN_PROP_BZR_MERGE,
                         SVN_PROP_SVK_MERGE, SVN_PROP_BZR_FILEIDS, 
                         revision_id_to_svk_feature) 
@@ -349,8 +350,7 @@
             self.base_tree = RevisionTree(self, Inventory(), revid)
             return
 
-        (bp, rev) = self.branch.repository.parse_revision_id(revid)
-        assert bp == self.branch.branch_path
+        rev = self.branch.parse_revision_id(revid)
         self.base_revnum = rev
         self.base_revid = revid
         self.base_tree = SvnBasisTree(self)
@@ -362,7 +362,7 @@
         def update_settings(wc, path):
             id = newrevtree.inventory.path2id(path)
             mutter("Updating settings for %r" % id)
-            (_, revnum) = self.branch.repository.parse_revision_id(
+            revnum = self.branch.parse_revision_id(
                     newrevtree.inventory[id].revision)
 
             svn.wc.process_committed2(self.abspath(path).rstrip("/"), wc, 
@@ -487,7 +487,7 @@
             stop_revision = self.branch.last_revision()
         rev = svn.core.svn_opt_revision_t()
         rev.kind = svn.core.svn_opt_revision_number
-        rev.value.number = self.branch.repository.parse_revision_id(stop_revision)[1]
+        rev.value.number = self.branch.parse_revision_id(stop_revision)
         fetched = svn.client.update(self.basedir, rev, True, self.client_ctx)
         self.base_revid = self.branch.repository.generate_revision_id(fetched, self.branch.branch_path)
         result.new_revid = self.branch.generate_revision_id(fetched)
@@ -631,19 +631,19 @@
         if not self.scheme.is_branch(self.branch_path) and not self.scheme.is_tag(self.branch_path):
             raise NotBranchError(path=self.transport.base)
 
-    def clone(self, path, revision_id=None, basis=None, force_new_repo=False):
+    def clone(self, path, revision_id=None, force_new_repo=False):
         raise NotImplementedError(self.clone)
 
     def open_workingtree(self, _unsupported=False):
         return SvnWorkingTree(self, self.local_path, self.open_branch())
 
-    def sprout(self, url, revision_id=None, basis=None, force_new_repo=False, 
+    def sprout(self, url, revision_id=None, force_new_repo=False, 
                recurse='down'):
         # FIXME: honor force_new_repo
         # FIXME: Use recurse
         result = BzrDirFormat.get_default_format().initialize(url)
         repo = self.find_repository()
-        repo.clone(result, revision_id, basis)
+        repo.clone(result, revision_id)
         branch = self.open_branch()
         branch.sprout(result, revision_id)
         result.create_workingtree()
@@ -710,3 +710,9 @@
 
     def initialize_on_transport(self, transport):
         raise NotImplementedError(self.initialize_on_transport)
+
+    def get_converter(self, format=None):
+        """See BzrDirFormat.get_converter()."""
+        if format is None:
+            format = BzrDirFormat.get_default_format()
+        return SvnConverter(format)

=== modified file 'commit.py'
--- a/commit.py	2007-04-14 18:00:15 +0000
+++ b/commit.py	2007-04-15 17:35:04 +0000
@@ -307,8 +307,8 @@
         if self.branch.last_revision() is None:
             self.base_revnum = 0
         else:
-            self.base_revnum = self.repository.parse_revision_id(
-                          self.branch.last_revision())[1]
+            self.base_revnum = self.branch.parse_revision_id(
+                          self.branch.last_revision())
 
         root = svn.delta.editor_invoke_open_root(self.editor, editor_baton, 
                                                  self.base_revnum)

=== modified file 'convert.py'
--- a/convert.py	2007-03-28 04:49:59 +0000
+++ b/convert.py	2007-04-15 16:15:53 +0000
@@ -20,7 +20,7 @@
 from bzrlib.plugin import load_plugins
 load_plugins()
 
-from bzrlib.bzrdir import BzrDir, BzrDirFormat
+from bzrlib.bzrdir import BzrDir, BzrDirFormat, Converter
 from bzrlib.branch import Branch
 from bzrlib.errors import (BzrError, NotBranchError, 
                            NoSuchFile, NoRepositoryPresent)
@@ -70,7 +70,6 @@
                        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))
@@ -130,12 +129,14 @@
                         target_dir.open_repository()
                     except NoRepositoryPresent:
                         target_dir.create_repository()
+                source_branch_url = urlutils.join(url, branch)
                 try:
                     target_branch = target_dir.open_branch()
                 except NotBranchError:
                     target_branch = target_dir.create_branch()
+                    target_branch.set_parent(source_branch_url)
                 if not revid in target_branch.revision_history():
-                    source_branch = Branch.open(urlutils.join(url, branch))
+                    source_branch = Branch.open(source_branch_url)
                     # Check if target_branch contains a subset of 
                     # source_branch. If that is not the case, 
                     # assume that source_branch has been replaced 
@@ -143,7 +144,6 @@
                     if not target_branch.last_revision() in \
                             source_branch.revision_history():
                         target_branch.set_revision_history([])
-
                     target_branch.pull(source_branch)
                 if working_trees and not target_dir.has_workingtree():
                     target_dir.create_workingtree()
@@ -153,3 +153,12 @@
     finally:
         if tmp_repos:
             osutils.rmtree(tmp_repos)
+
+
+class SvnConverter(Converter):
+    """Converts from a Subversion dir to another dir."""
+    def __init__(self, target_format):
+        self.target_format = target_format
+
+    def convert(self, to_convert, pb):
+        pass

=== modified file 'format.py'
--- a/format.py	2007-03-25 18:41:40 +0000
+++ b/format.py	2007-04-15 16:15:53 +0000
@@ -55,27 +55,27 @@
                 self.branch_path != ""):
             raise NotBranchError(path=self.root_transport.base)
 
-    def clone(self, url, revision_id=None, basis=None, force_new_repo=False):
+    def clone(self, url, revision_id=None, force_new_repo=False):
         """See BzrDir.clone().
 
         Not supported on Subversion connections.
         """
         raise NotImplementedError(SvnRemoteAccess.clone)
 
-    def sprout(self, url, revision_id=None, basis=None, force_new_repo=False,
+    def sprout(self, url, revision_id=None, force_new_repo=False,
             recurse='down'):
         """See BzrDir.sprout()."""
         # FIXME: Use recurse
         result = BzrDirFormat.get_default_format().initialize(url)
         repo = self.find_repository()
         if force_new_repo:
-            result_repo = repo.clone(result, revision_id, basis)
+            result_repo = repo.clone(result, revision_id)
         else:
             try:
                 result_repo = result.find_repository()
                 result_repo.fetch(repo, revision_id=revision_id)
             except NoRepositoryPresent:
-                result_repo = repo.clone(result, revision_id, basis)
+                result_repo = repo.clone(result, revision_id)
 
         branch = self.open_branch()
         result_branch = branch.sprout(result, revision_id)
@@ -183,3 +183,4 @@
     def is_supported(self):
         """See BzrDir.is_supported()."""
         return True
+

=== modified file 'tests/test_branch.py'
--- a/tests/test_branch.py	2007-03-28 04:00:14 +0000
+++ b/tests/test_branch.py	2007-04-15 17:35:04 +0000
@@ -16,7 +16,7 @@
 
 from bzrlib.branch import Branch
 from bzrlib.bzrdir import BzrDir
-from bzrlib.errors import NoSuchFile
+from bzrlib.errors import NoSuchFile, NoSuchRevision
 from bzrlib.repository import Repository
 from bzrlib.trace import mutter
 
@@ -36,6 +36,18 @@
         branch.revision_history()
         self.assertEqual(branch.generate_revision_id(0), branch.last_revision())
 
+    def test_parse_revision_id_unknown(self):
+        repos_url = self.make_client("a", "dc")
+        branch = Branch.open(repos_url)
+        self.assertRaises(NoSuchRevision, 
+                lambda: branch.parse_revision_id("bla"))
+
+    def test_parse_revision_id(self):
+        repos_url = self.make_client("a", "dc")
+        branch = Branch.open(repos_url)
+        self.assertEquals(0, 
+                branch.parse_revision_id(branch.last_revision()))
+
     def test_set_parent(self):
         repos_url = self.make_client('a', 'dc')
         branch = Branch.open(repos_url)

=== modified file 'tests/test_checkout.py'
--- a/tests/test_checkout.py	2007-03-28 04:00:14 +0000
+++ b/tests/test_checkout.py	2007-04-15 16:15:53 +0000
@@ -18,7 +18,8 @@
 from bzrlib.errors import NoRepositoryPresent
 from bzrlib.tests import TestCase
 
-from checkout import SvnWorkingTreeFormat
+from convert import SvnConverter
+from checkout import SvnWorkingTreeFormat, SvnWorkingTreeDirFormat
 from tests import TestCaseWithSubversionRepository
 
 class TestWorkingTreeFormat(TestCase):
@@ -36,6 +37,14 @@
     def test_open(self):
         self.assertRaises(NotImplementedError, self.format.open, None)
 
+class TestCheckoutFormat(TestCase):
+    def setUp(self):
+        super(TestCheckoutFormat, self).setUp()
+        self.format = SvnWorkingTreeDirFormat()
+
+    def test_get_converter(self):
+        self.assertIsInstance(self.format.get_converter(), SvnConverter)
+
 
 class TestCheckout(TestCaseWithSubversionRepository):
     def test_not_for_writing(self):

=== modified file 'tests/test_commit.py'
--- a/tests/test_commit.py	2007-04-14 18:00:15 +0000
+++ b/tests/test_commit.py	2007-04-15 17:35:04 +0000
@@ -111,6 +111,43 @@
         self.assertEqual("my-revision-id", 
                 self.client_get_prop(self.repos_url, "bzr:revision-id-%d" % MAPPING_VERSION, 2))
 
+    def test_mwh(self):
+        repo = self.make_client('d', 'sc')
+        def mv(*mvs):
+            for a, b in mvs:
+                self.client_copy(a, b)
+                self.client_delete(a)
+            self.client_commit('sc', '.')
+            self.client_update('sc')
+        self.build_tree({'sc/de/foo':'data', 'sc/de/bar':'DATA'})
+        self.client_add('sc/de')
+        self.client_commit('sc', 'blah')
+        self.client_update('sc')
+        os.mkdir('sc/de/trunk')
+        self.client_add('sc/de/trunk')
+        mv(('sc/de/foo', 'sc/de/trunk'), ('sc/de/bar', 'sc/de/trunk'))
+        mv(('sc/de', 'sc/pyd')) 
+        self.client_delete('sc/pyd/trunk/foo')
+        self.client_commit('sc', '.')
+        self.client_update('sc')
+
+        self.make_checkout(repo + '/pyd/trunk', 'pyd')
+        assert open('pyd/bar').read() == 'DATA'
+
+        olddir = BzrDir.open("pyd")
+        os.mkdir('bc')
+        newdir = olddir.sprout("bc")
+        newdir.open_branch().pull(olddir.open_branch())
+        wt = newdir.open_workingtree()
+        assert open('bc/bar').read() == 'DATA'
+        open('bc/bar', 'w').write('data')
+        wt.commit(message="Commit from Bzr")
+        olddir.open_branch().pull(newdir.open_branch())
+
+        self.client_update('pyd')
+        assert open('pyd/bar').read() == 'data'
+        
+
 class TestPush(TestCaseWithSubversionRepository):
     def setUp(self):
         super(TestPush, self).setUp()

=== modified file 'tests/test_convert.py'
--- a/tests/test_convert.py	2007-03-25 18:41:40 +0000
+++ b/tests/test_convert.py	2007-04-15 16:15:53 +0000
@@ -70,6 +70,14 @@
         self.build_tree({'dc/trunk/file': 'otherdata'})
         self.client_commit("dc", "change")
 
+    def test_sets_parent_urls(self):
+        convert_repository(self.repos_url, "e", TrunkBranchingScheme(), 
+                           all=False, create_shared_repo=True)
+        self.assertEquals(self.repos_url+"/trunk", 
+                Branch.open("e/trunk").get_parent())
+        self.assertEquals(self.repos_url+"/branches/abranch", 
+                Branch.open("e/branches/abranch").get_parent())
+
     def test_fetch_alive(self):
         self.build_tree({'dc/branches/somebranch/somefile': 'data'})
         self.client_add("dc/branches/somebranch")




More information about the bazaar-commits mailing list