Rev 307: Raise exception when a dir upgrade is detected. in http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev
Jelmer Vernooij
jelmer at samba.org
Tue Dec 26 17:36:09 GMT 2006
------------------------------------------------------------
revno: 307
revision-id: jelmer at samba.org-20061226173531-0z6y53h2pwg073m4
parent: jelmer at samba.org-20061226170019-y9g1pa78mbe723kk
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Tue 2006-12-26 18:35:31 +0100
message:
Raise exception when a dir upgrade is detected.
added:
errors.py errors.py-20061226172623-w1sbj8ynpo0eojqp-1
modified:
repository.py repository.py-20060306123302-1f8c5069b3fe0265
tests/test_repos.py test_repos.py-20060508151940-ddc49a59257ca712
=== added file 'errors.py'
--- a/errors.py 1970-01-01 00:00:00 +0000
+++ b/errors.py 2006-12-26 17:35:31 +0000
@@ -0,0 +1,39 @@
+# Copyright (C) 2006 Jelmer Vernooij <jelmer at samba.org>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+from bzrlib.errors import BzrError
+
+class DirUpgrade(BzrError):
+ _fmt = """Dir %(from_path)s:%(from_revnum)d is upgraded to branch %(to_path)s in %(to_revnum)d. Not supported yet. """
+
+ def __init__(self, from_tuple, to_tuple):
+ BzrError.__init__(self)
+ self.to_path = to_tuple[0]
+ self.to_revnum = to_tuple[1]
+ self.from_path = from_tuple[0]
+ self.from_revnum = from_tuple[1]
+
+
+class NotSvnBranchPath(BzrError):
+ _fmt = """{%(branch_path)s}:%(revnum)s is not a valid Svn branch path"""
+
+ def __init__(self, branch_path, revnum=None):
+ BzrError.__init__(self)
+ self.branch_path = branch_path
+ self.revnum = revnum
+
+
+
=== modified file 'repository.py'
--- a/repository.py 2006-12-26 17:00:19 +0000
+++ b/repository.py 2006-12-26 17:35:31 +0000
@@ -28,7 +28,7 @@
from bzrlib.repository import Repository, RepositoryFormat
from bzrlib.revision import Revision, NULL_REVISION
from bzrlib.transport import Transport
-from bzrlib.trace import mutter, warning
+from bzrlib.trace import mutter
from svn.core import SubversionException, Pool
import svn.core
@@ -42,6 +42,7 @@
import branch
from branchprops import BranchPropertyList
+import errors
import logwalker
from tree import SvnRevisionTree
@@ -53,27 +54,6 @@
SVN_REVPROP_BZR_SIGNATURE = 'bzr:gpg-signature'
-class DirUpgrade(BzrError):
- _fmt = """Dir %(from_path):%(from_revnum) is upgraded to branch %(to_path) in %(to_revnum). Not supported yet. """
-
- def __init__(self, to_tuple, from_tuple=None):
- BzrError.__init__(self)
- self.to_path = to_tuple[0]
- self.to_revnum = to_tuple[1]
- if from_tuple is not None:
- self.from_path = from_tuple[0]
- self.from_revnum = from_tuple[1]
-
-
-class NotSvnBranchPath(BzrError):
- _fmt = """{%(branch_path)s}:%(revnum)s is not a valid Svn branch path"""
-
- def __init__(self, branch_path, revnum=None):
- BzrError.__init__(self)
- self.branch_path = branch_path
- self.revnum = revnum
-
-
_unsafe = "%/-\t "
def escape_svn_path(id):
r = [((c in _unsafe) and ('%%%02x' % ord(c)) or c)
@@ -523,15 +503,9 @@
def follow_history(self, branch_path, revnum):
if not branch_path is None and not self.scheme.is_branch(branch_path):
- raise NotSvnBranchPath(branch_path, revnum)
+ raise errors.NotSvnBranchPath(branch_path, revnum)
for (branch_path, paths, revnum) in self._log.follow_history(branch_path, revnum):
- if branch_path is not None and not self.scheme.is_branch(branch_path):
- # FIXME: if copyfrom_path is not a branch path,
- # should simulate a reverse "split" of a branch
- warning('directory %r:%d upgraded to branch. This is not currently supported.' %
- (branch_path, revnum))
-
changed_paths = {}
for p in paths:
if (branch_path is None or
@@ -550,8 +524,15 @@
assert branch_path is None or len(changed_paths) <= 1
for bp in changed_paths:
+ if (changed_paths[bp].has_key(bp) and
+ changed_paths[bp][bp][1] is not None and
+ not self.scheme.is_branch(changed_paths[bp][bp][1])):
+ # FIXME: if copyfrom_path is not a branch path,
+ # should simulate a reverse "split" of a branch
+ raise errors.DirUpgrade((changed_paths[bp][bp][1], changed_paths[bp][bp][2]), (bp, revnum))
yield (bp, changed_paths[bp], revnum)
+
def has_signature_for_revision_id(self, revision_id):
# TODO: Retrieve from SVN_PROP_BZR_SIGNATURE
return False # SVN doesn't store GPG signatures. Perhaps
=== modified file 'tests/test_repos.py'
--- a/tests/test_repos.py 2006-12-26 17:00:19 +0000
+++ b/tests/test_repos.py 2006-12-26 17:35:31 +0000
@@ -15,12 +15,13 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from bzrlib.bzrdir import BzrDir
-from bzrlib.errors import NoSuchRevision
+from bzrlib.errors import NoSuchRevision, BzrError
from bzrlib.inventory import Inventory
import bzrlib.osutils as osutils
from bzrlib.repository import Repository
from bzrlib.revision import NULL_REVISION
from bzrlib.tests import TestCase
+from bzrlib.trace import mutter
from bzrlib.transport.local import LocalTransport
import os
@@ -28,12 +29,13 @@
import svn.fs
from convert import load_dumpfile
+import errors
import format
from scheme import TrunkBranchingScheme, NoBranchingScheme
from transport import SvnRaTransport
from tests import TestCaseWithSubversionRepository
-from repository import (NotSvnBranchPath,
- parse_svn_revision_id, generate_svn_revision_id,
+import repository
+from repository import (parse_svn_revision_id, generate_svn_revision_id,
svk_feature_to_revision_id, revision_id_to_svk_feature,
MAPPING_VERSION, escape_svn_path, unescape_svn_path)
@@ -1133,6 +1135,50 @@
"svn-v%d:5@%s-" % (MAPPING_VERSION, oldrepos.uuid))
self.assertNotEqual(inv1.path2id("y"), inv2.path2id("y"))
+ def test_fetch_dir_upgrade(self):
+ repos_url = self.make_client('d', 'dc')
+
+ self.build_tree({'dc/trunk/lib/file': 'data'})
+ self.client_add("dc/trunk")
+ self.client_commit("dc", "trunk data")
+
+ self.build_tree({'dc/branches': None})
+ self.client_add("dc/branches")
+ self.client_copy("dc/trunk/lib", "dc/branches/mybranch")
+ self.client_commit("dc", "split out lib")
+
+ oldrepos = Repository.open(repos_url)
+ oldrepos.set_branching_scheme(TrunkBranchingScheme())
+ dir = BzrDir.create("f")
+ newrepos = dir.create_repository()
+ self.assertRaises(BzrError, oldrepos.copy_content_into, newrepos)
+ try:
+ oldrepos.copy_content_into(newrepos)
+ except BzrError, e:
+ self.assertEqual("trunk/lib", e.from_path)
+ self.assertEqual(1, e.from_revnum)
+ self.assertEqual("branches/mybranch", e.to_path)
+ self.assertEqual(2, e.to_revnum)
+
+
+ def notest_fetch_branch_downgrade(self):
+ repos_url = self.make_client('d', 'dc')
+
+ self.build_tree({'dc/trunk/file': 'data'})
+ self.client_add("dc/trunk")
+ self.client_commit("dc", "trunk data")
+
+ self.build_tree({'dc/branches/mybranch': None})
+ self.client_add("dc/branches")
+ self.client_copy("dc/trunk", "dc/branches/mybranch/lib")
+ self.client_commit("dc", "split out lib")
+
+ oldrepos = Repository.open(repos_url)
+ oldrepos.set_branching_scheme(TrunkBranchingScheme())
+ dir = BzrDir.create("f")
+ newrepos = dir.create_repository()
+ oldrepos.copy_content_into(newrepos)
+
# FIXME
def notest_fetch_all(self):
repos_url = self.make_client('d', 'dc')
More information about the bazaar-commits
mailing list