Rev 1803: More v1/v2 fixes. in file:///data/jelmer/bzr-svn/trunk/
Jelmer Vernooij
jelmer at samba.org
Thu Sep 4 12:47:13 BST 2008
At file:///data/jelmer/bzr-svn/trunk/
------------------------------------------------------------
revno: 1803
revision-id: jelmer at samba.org-20080904114709-dooctxhw4r1o80dk
parent: jelmer at samba.org-20080904101515-u0ocn12dye7awxrr
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Thu 2008-09-04 13:47:09 +0200
message:
More v1/v2 fixes.
modified:
__init__.py __init__.py-20051008155114-eae558e6cf149e1d
branch.py svnbranch.py-20051017135706-11c749eb0dab04a7
commit.py commit.py-20060607190346-qvq128wgfubhhgm2-1
config.py config.py-20070624185721-0j8f1ly75uo4s1lk-1
layout.py layout.py-20080323165407-y9qw8nx4oykvoe1k-1
mapping2.py mapping.py-20080904055555-lw057kjuadn0r2ma-2
mapping3/__init__.py __init__.py-20080502174630-9324zh25kka98vlw-1
mapping4.py mapping4.py-20080827182338-y4xzpsf43vyiwcir-1
repository.py repository.py-20060306123302-1f8c5069b3fe0265
tests/mapping_implementations/test_repository.py test_repository.py-20080902013845-ity7d1ymye69sobm-2
tests/test_fileids.py test_fileids.py-20060622131341-19gyrlgqy8yl2od5-1
tests/test_repository.py test_repos.py-20060508151940-ddc49a59257ca712
upgrade.py upgrade.py-20070106192108-0rakplee2lzah4gs-1
=== modified file '__init__.py'
--- a/__init__.py 2008-09-04 10:15:15 +0000
+++ b/__init__.py 2008-09-04 11:47:09 +0000
@@ -199,8 +199,9 @@
from bzrlib.plugins.svn.layout import layout_registry
from bzrlib.errors import BzrCommandError
- ret = layout_registry.parse(layoutname)
- if ret is None:
+ try:
+ ret = layout_registry.get(layoutname)
+ except KeyError:
raise BzrCommandError('No such repository layout %r' % layoutname)
return ret
=== modified file 'branch.py'
--- a/branch.py 2008-09-04 07:01:24 +0000
+++ b/branch.py 2008-09-04 11:47:09 +0000
@@ -416,7 +416,8 @@
if todo is None:
raise DivergedBranches(self, other)
if _push_merged is None:
- _push_merged = self.layout.push_merged_revisions(self.project)
+ _push_merged = (self.layout.push_merged_revisions(self.project) and
+ self.get_config().get_push_merged_revisions())
self._push_missing_revisions(graph, other, other_graph, todo,
_push_merged)
=== modified file 'commit.py'
--- a/commit.py 2008-09-04 08:54:40 +0000
+++ b/commit.py 2008-09-04 11:47:09 +0000
@@ -871,11 +871,13 @@
if target_branch.get_branch_path() != bp:
target_branch.set_branch_path(bp)
- if layout.push_merged_revisions(target_branch.project) and len(rev.parent_ids) > 1:
+ target_config = target_branch.get_config()
+ if (layout.push_merged_revisions(target_branch.project) and
+ len(rev.parent_ids) > 1 and
+ target_config.get_push_merged_revisions()):
push_ancestors(self.target, self.source, layout, "", rev.parent_ids, graph,
create_prefix=True)
- target_config = target_branch.get_config()
push_revision_tree(graph, target_branch, target_config,
self.source, parent_revid, revision_id, rev)
finally:
=== modified file 'config.py'
--- a/config.py 2008-08-31 01:15:57 +0000
+++ b/config.py 2008-09-04 11:47:09 +0000
@@ -277,3 +277,7 @@
if mask_value is not None:
trace.warning('Value "%s" is masked by "%s" from'
' branch.conf', value, mask_value)
+
+ def get_push_merged_revisions(self):
+ """Check whether merged revisions should be pushed."""
+ return self._get_repository_config().get_push_merged_revisions()
=== modified file 'layout.py'
--- a/layout.py 2008-09-04 10:15:15 +0000
+++ b/layout.py 2008-09-04 11:47:09 +0000
@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from bzrlib import urlutils, ui
+from bzrlib import registry, urlutils, ui
from bzrlib.errors import NotBranchError
from bzrlib.trace import mutter
from bzrlib.plugins.svn.core import SubversionException, NODE_DIR
@@ -23,8 +23,8 @@
class RepositoryLayout(object):
"""Describes a repository layout."""
- def __init__(self, repository):
- self._config = repository.get_config()
+ def __init__(self):
+ pass
def get_tag_path(self, name, project=""):
"""Return the path at which the tag with specified name should be found.
@@ -120,6 +120,7 @@
class TrunkLayout(RepositoryLayout):
def __init__(self, level=None):
+ assert level is None or isinstance(level, int)
self.level = level
def get_tag_path(self, name, project=""):
@@ -148,7 +149,7 @@
:param project: Name of the project.
"""
- return self._config.get_push_merged_revisions()
+ return False
def get_branch_path(self, name, project=""):
"""Return the path at which the branch with specified name should be found.
@@ -178,7 +179,8 @@
else:
t = "branch"
j = i
- return (t,
+ if self.level in (j, None):
+ return (t,
"/".join(parts[:j]).strip("/"),
"/".join(parts[:i+1]).strip("/"),
"/".join(parts[i+1:]).strip("/"))
@@ -206,7 +208,10 @@
return get_root_paths(repository, [self._add_project("tags/*", project)], revnum, self.is_tag, project)
def __repr__(self):
- return "%s()" % self.__class__.__name__
+ if self.level is None:
+ return "%s()" % self.__class__.__name__
+ else:
+ return "%s(%d)" % (self.__class__.__name__, self.level)
class RootLayout(RepositoryLayout):
@@ -257,14 +262,14 @@
"""
return ('branch', '', '', path)
- def get_branches(self, revnum, project=None, pb=None):
+ def get_branches(self, repository, revnum, project=None, pb=None):
"""Retrieve a list of paths that refer to branches in a specific revision.
:result: Iterator over tuples with (project, branch path)
"""
raise NotImplementedError
- def get_tags(self, revnum, project=None, pb=None):
+ def get_tags(self, repository, revnum, project=None, pb=None):
"""Retrieve a list of paths that refer to tags in a specific revision.
:result: Iterator over tuples with (project, branch path)
@@ -356,5 +361,15 @@
yield "", bp, bp.split("/")[-1]
+def repository_guess_layout(repository, revnum):
+ return None # FIXME
+
+
layout_registry = registry.Registry()
+layout_registry.register("root", RootLayout())
+layout_registry.register("none", RootLayout())
+layout_registry.register("trunk", TrunkLayout())
+layout_registry.register("trunk0", TrunkLayout(0))
+layout_registry.register("trunk1", TrunkLayout(1))
+layout_registry.register("trunk2", TrunkLayout(2))
=== modified file 'mapping2.py'
--- a/mapping2.py 2008-09-04 07:58:37 +0000
+++ b/mapping2.py 2008-09-04 11:47:09 +0000
@@ -30,7 +30,7 @@
name = "v1"
roundtripping = False
- def __init__(self, layout=None):
+ def __init__(self, layout):
super(BzrSvnMappingv1, self).__init__()
self._layout = layout
@@ -45,9 +45,11 @@
branch_path = unescape_svn_path(revid[fash+1:])
revnum = int(revid[0:at])
assert revnum >= 0
- return (uuid, branch_path, revnum, cls())
+ return (uuid, branch_path, revnum, cls(LegacyLayout.from_branch_path(branch_path)))
- def revision_id_foreign_to_bzr(self, (uuid, revnum, path)):
+ @classmethod
+ def revision_id_foreign_to_bzr(cls, (uuid, revnum, path)):
+ assert isinstance(path, str)
return "svn-v1:%d@%s-%s" % (revnum, uuid, escape_svn_path(path))
def __eq__(self, other):
@@ -62,11 +64,10 @@
def import_revision(self, svn_revprops, fileprops, uuid, branch, revnum, rev):
parse_svn_revprops(svn_revprops, rev)
- @staticmethod
- def generate_file_id(uuid, revnum, branch, inv_path):
- if inv_path == "":
+ def generate_file_id(self, uuid, revnum, branch, inv_path):
+ if inv_path == u"":
return ROOT_ID
- return "%s-%s" % (self.revision_id_foreign_to_bzr((uuid, revnum, branch)), escape_svn_path(inv_path))
+ return "%s-%s" % (self.revision_id_foreign_to_bzr((uuid, revnum, branch)), escape_svn_path(inv_path.encode("utf-8")))
def import_fileid_map(self, revprops, fileprops):
return {}
@@ -83,16 +84,9 @@
@classmethod
def from_repository(cls, repository, _hinted_branch_path=None):
if _hinted_branch_path is None:
- return cls(TrunkLegacyLayout(repository))
+ return cls(TrunkLegacyLayout())
- parts = _hinted_branch_path.strip("/").split("/")
- for i in range(0,len(parts)):
- if parts[i] == "trunk" or \
- parts[i] == "branches" or \
- parts[i] == "tags":
- return cls(TrunkLegacyLayout(repository, level=i))
-
- return cls(RootLegacyLayout(repository))
+ return cls(LegacyLayout.from_branch_path(_hinted_branch_path))
def get_guessed_layout(self, repository):
return self._layout
@@ -118,7 +112,7 @@
branch_path = unescape_svn_path(revid[fash+1:])
revnum = int(revid[0:at])
assert revnum >= 0
- return (uuid, branch_path, revnum, cls())
+ return (uuid, branch_path, revnum, cls(LegacyLayout.from_branch_path(branch_path)))
def revision_id_foreign_to_bzr(self, (uuid, revnum, path)):
return "svn-v2:%d@%s-%s" % (revnum, uuid, escape_svn_path(path))
@@ -135,11 +129,22 @@
def get_branch_path(self, name, project=""):
return None
+ @classmethod
+ def from_branch_path(cls, path):
+ parts = path.strip("/").split("/")
+ for i in range(0,len(parts)):
+ if parts[i] == "trunk" or \
+ parts[i] == "branches" or \
+ parts[i] == "tags":
+ return TrunkLegacyLayout(level=i)
+
+ return RootLegacyLayout()
+
class TrunkLegacyLayout(LegacyLayout):
- def __init__(self, repository, level=0):
- super(TrunkLegacyLayout, self).__init__(repository)
+ def __init__(self, level=0):
+ super(TrunkLegacyLayout, self).__init__()
self.level = level
def parse(self, path):
@@ -169,12 +174,10 @@
return False
-
-class RootLegacyLayout(RepositoryLayout):
+class RootLegacyLayout(LegacyLayout):
def parse(self, path):
return ("branch", "", "", path)
- def is_branch(self, branch_path, project=None):
- return branch_path == ""
-
+ def is_branch(self, path, project=None):
+ return path == ""
=== modified file 'mapping3/__init__.py'
--- a/mapping3/__init__.py 2008-09-04 10:15:15 +0000
+++ b/mapping3/__init__.py 2008-09-04 11:47:09 +0000
@@ -71,7 +71,7 @@
def push_merged_revisions(self, project=""):
try:
self.scheme.get_branch_path("somebranch")
- return self.repository.get_config().get_push_merged_revisions()
+ return True
except NotImplementedError:
return False
@@ -176,7 +176,8 @@
return SchemeDerivedLayout(repository, self.guessed_scheme or self.scheme)
def check_layout(self, repository, layout):
- repository.get_mapping().scheme = scheme_from_layout(layout)
+ scheme = scheme_from_layout(layout)
+ repository.get_mapping().scheme = scheme
config_set_scheme(repository, scheme, scheme)
@classmethod
=== modified file 'mapping4.py'
--- a/mapping4.py 2008-09-04 08:54:40 +0000
+++ b/mapping4.py 2008-09-04 11:47:09 +0000
@@ -45,7 +45,7 @@
if _hinted_branch_path == "":
return cls(layout.RootLayout())
else:
- return cls(layout.TrunkLayout(repository))
+ return cls(layout.TrunkLayout())
@classmethod
def from_revprops(cls, revprops):
=== modified file 'repository.py'
--- a/repository.py 2008-09-04 09:40:03 +0000
+++ b/repository.py 2008-09-04 11:47:09 +0000
@@ -600,6 +600,8 @@
created.add(bp)
elif paths[p][0] == 'D' and rp == "":
deleted.add(bp)
+ except errors.NotBranchError:
+ pass
except errors.InvalidSvnBranchPath:
pass
return deleted, created
@@ -623,7 +625,7 @@
branches = []
pb = ui.ui_factory.nested_progress_bar()
try:
- for project, bp, nick in layout.get_branches(revnum, pb=pb):
+ for project, bp, nick in layout.get_branches(self, revnum, pb=pb):
branches.append(SvnBranch(self, bp, _skip_check=True))
finally:
pb.finished()
@@ -799,9 +801,9 @@
if not check_removed and from_revnum == 0:
it = iter([])
if find_branches:
- it = chain(it, layout.get_branches(to_revnum, project))
+ it = chain(it, layout.get_branches(self, to_revnum, project))
if find_tags:
- it = chain(it, layout.get_tags(to_revnum, project))
+ it = chain(it, layout.get_tags(self, to_revnum, project))
for (project, branch, nick) in it:
yield (branch, to_revnum, True)
else:
=== modified file 'tests/mapping_implementations/test_repository.py'
--- a/tests/mapping_implementations/test_repository.py 2008-09-04 10:15:15 +0000
+++ b/tests/mapping_implementations/test_repository.py 2008-09-04 11:47:09 +0000
@@ -112,7 +112,7 @@
repos = Repository.open(repos_url)
repos.set_layout(RootLayout())
self.assertRaises(NoSuchRevision, list,
- repos._revmeta_provider.iter_reverse_branch_changes("/", 20, 0, repos.get_layout()))
+ repos._revmeta_provider.iter_reverse_branch_changes("/", 20, 0))
def test_follow_branch_switched_parents(self):
repos_url = self.make_client('a', 'dc')
@@ -216,7 +216,7 @@
dc.close()
repos = Repository.open(repos_url)
- repos.set_layout(repos, TrunkLayout(0))
+ repos.set_layout(TrunkLayout(0))
mapping = repos.get_mapping()
self.assertEqual(set([
repos.generate_revision_id(1, "trunk", mapping),
@@ -735,6 +735,7 @@
self.client_commit("dc", "Third Message") #3
self.client_update("dc")
repository = Repository.open(repos_url)
+ repository.set_layout(RootLayout())
mapping = repository.get_mapping()
inv = repository.get_inventory(
repository.generate_revision_id(1, "", mapping))
=== modified file 'tests/test_fileids.py'
--- a/tests/test_fileids.py 2008-09-04 10:15:15 +0000
+++ b/tests/test_fileids.py 2008-09-04 11:47:09 +0000
@@ -181,7 +181,7 @@
class TestFileMapping(TestCase):
def setUp(self):
- self.generate_file_id = lambda uuid, revnum, bp, ip: "%d@%s:%s:%s" % (uuid, revnum, bp, ip)
+ self.generate_file_id = lambda uuid, revnum, bp, ip: "%d@%s:%s:%s" % (revnum, uuid, bp, ip)
def apply_mappings(self, mappings, find_children=None, renames={}):
map = {}
=== modified file 'tests/test_repository.py'
--- a/tests/test_repository.py 2008-09-04 09:40:03 +0000
+++ b/tests/test_repository.py 2008-09-04 11:47:09 +0000
@@ -39,68 +39,62 @@
class TestSubversionRepositoryWorks(SubversionTestCase):
"""Generic Subversion Repository tests."""
+ def setUp(self):
+ super(TestSubversionRepositoryWorks, self).setUp()
+ self.repos_path = 'a'
+ self.repos_url = self.make_repository(self.repos_path)
+
def test_get_config_global_set(self):
- repos_url = self.make_repository("a")
cfg = GlobalConfig()
cfg.set_user_option("foo", "Still Life")
- repos = Repository.open(repos_url)
+ repos = Repository.open(self.repos_url)
self.assertEquals("Still Life",
repos.get_config().get_user_option("foo"))
def test_get_config(self):
- repos_url = self.make_repository("a")
- repos = Repository.open(repos_url)
+ repos = Repository.open(self.repos_url)
repos.get_config().set_user_option("foo", "Van Der Graaf Generator")
- repos = Repository.open(repos_url)
+ repos = Repository.open(self.repos_url)
self.assertEquals("Van Der Graaf Generator",
repos.get_config().get_user_option("foo"))
def test_repr(self):
- repos_url = self.make_repository("a")
-
- dc = self.get_commit_editor(repos_url)
+ dc = self.get_commit_editor(self.repos_url)
dc.add_file("foo").modify("data")
dc.close()
- repos = Repository.open(repos_url)
+ repos = Repository.open(self.repos_url)
self.assertEqual("SvnRepository('%s/')" % urlutils.local_path_to_url(urlutils.join(self.test_dir, "a")), repos.__repr__())
def test_gather_stats(self):
- repos_url = self.make_repository("a")
- repos = Repository.open(repos_url)
+ repos = Repository.open(self.repos_url)
stats = repos.gather_stats()
self.assertEquals(1, stats['revisions'])
self.assertTrue(stats.has_key("firstrev"))
self.assertTrue(stats.has_key("latestrev"))
self.assertFalse(stats.has_key('committers'))
- def test_url(self):
- """ Test repository URL is kept """
- bzrdir = self.make_local_bzrdir('b', 'bc')
- self.assertTrue(isinstance(bzrdir, BzrDir))
-
def test_uuid(self):
""" Test UUID is retrieved correctly """
- bzrdir = self.make_local_bzrdir('c', 'cc')
- self.assertTrue(isinstance(bzrdir, BzrDir))
- repository = bzrdir._find_repository()
- fs = self.open_fs('c')
+ fs = self.open_fs(self.repos_path)
+ repository = Repository.open(self.repos_url)
self.assertEqual(fs.get_uuid(), repository.uuid)
def test_is_shared(self):
- repos_url = self.make_client('d', 'dc')
+ self.make_checkout(self.repos_url, 'dc')
self.build_tree({'dc/foo/bla': "data"})
self.client_add("dc/foo")
self.client_commit("dc", "My Message")
- repository = Repository.open(repos_url)
+ repository = Repository.open(self.repos_url)
self.assertTrue(repository.is_shared())
def test_format(self):
""" Test repository format is correct """
- bzrdir = self.make_local_bzrdir('a', 'ac')
+ self.make_checkout(self.repos_url, 'ac')
+ bzrdir = BzrDir.open("ac")
self.assertEqual(bzrdir._format.get_format_string(), \
"Subversion Local Checkout")
@@ -108,13 +102,11 @@
"Subversion Local Checkout")
def test_make_working_trees(self):
- repos_url = self.make_repository("a")
- repos = Repository.open(repos_url)
+ repos = Repository.open(self.repos_url)
self.assertFalse(repos.make_working_trees())
def test_get_physical_lock_status(self):
- repos_url = self.make_repository("a")
- repos = Repository.open(repos_url)
+ repos = Repository.open(self.repos_url)
self.assertFalse(repos.get_physical_lock_status())
=== modified file 'upgrade.py'
--- a/upgrade.py 2008-09-04 08:54:40 +0000
+++ b/upgrade.py 2008-09-04 11:47:09 +0000
@@ -60,17 +60,21 @@
:param svn_repository: Subversion repository object
"""
- orig_basis_tree = wt.basis_tree()
- renames = upgrade_branch(wt.branch, svn_repository, new_mapping=new_mapping,
- allow_changes=allow_changes, verbose=verbose)
- last_revid = wt.branch.last_revision()
- wt.set_last_revision(last_revid)
+ wt.lock_write()
+ try:
+ old_revid = wt.last_revision()
+ renames = upgrade_branch(wt.branch, svn_repository, new_mapping=new_mapping,
+ allow_changes=allow_changes, verbose=verbose)
+ last_revid = wt.branch.last_revision()
+ wt.set_last_revision(last_revid)
- # Adjust file ids in working tree
- for (old_fileid, new_fileid) in determine_fileid_renames(orig_basis_tree, wt.basis_tree()):
- path = wt.id2path(old_fileid)
- wt.remove(path)
- wt.add([path], [new_fileid])
+ # Adjust file ids in working tree
+ for (old_fileid, new_fileid) in determine_fileid_renames(wt.branch.repository.revision_tree(old_revid), wt.basis_tree()):
+ path = wt.id2path(old_fileid)
+ wt.remove(path)
+ wt.add([path], [new_fileid])
+ finally:
+ wt.unlock()
return renames
More information about the bazaar-commits
mailing list