Merge lp:~jelmer/bzr-svn/require-fileprop-settings into lp:bzr-svn/1.1

Proposed by Jelmer Vernooij
Status: Merged
Merged at revision: 3651
Proposed branch: lp:~jelmer/bzr-svn/require-fileprop-settings
Merge into: lp:bzr-svn/1.1
Diff against target: 179 lines (+54/-5)
7 files modified
NEWS (+3/-0)
commit.py (+1/-1)
config.py (+9/-0)
errors.py (+5/-0)
push.py (+3/-1)
repository.py (+8/-3)
tests/mapping3/__init__.py (+25/-0)
To merge this branch: bzr merge lp:~jelmer/bzr-svn/require-fileprop-settings
Reviewer Review Type Date Requested Status
bzr-svn developers Pending
Review via email: mp+54629@code.launchpad.net

Description of the change

Disable pushing to file properties by default.

This can be disabled by setting `allow_metadata_in_file_properties`.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2011-03-23 18:03:00 +0000
3+++ NEWS 2011-03-23 23:35:40 +0000
4@@ -67,6 +67,9 @@
5 * Fix ControlDir.sprout() implementation for newer versions of bzr.
6 (Jelmer Vernooij, #717937)
7
8+ * bzr-svn no longer uses file properties to store metadata anymore, unless
9+ `allow_metadata_in_file_properties`. (Jelmer Vernooij, #704716)
10+
11 FEATURES
12
13 * When roundtripping revisions a revision property with the Bazaar testament is
14
15=== modified file 'commit.py'
16--- commit.py 2011-03-23 16:05:18 +0000
17+++ commit.py 2011-03-23 23:35:40 +0000
18@@ -493,7 +493,7 @@
19 self._svnprops = lazy_dict({}, dict,
20 self._base_branch_props.iteritems())
21 if push_metadata:
22- (self.set_custom_revprops, self.set_custom_fileprops) = self.repository._properties_to_set(self.mapping)
23+ (self.set_custom_revprops, self.set_custom_fileprops) = self.repository._properties_to_set(self.mapping, config)
24 else:
25 self.set_custom_revprops = False
26 self.set_custom_fileprops = False
27
28=== modified file 'config.py'
29--- config.py 2011-03-22 21:44:43 +0000
30+++ config.py 2011-03-23 23:35:40 +0000
31@@ -369,6 +369,15 @@
32 return value
33 return None
34
35+ def get_allow_metadata_in_fileprops(self):
36+ """Check whether file properties may be used to store bzr-svn metadata.
37+
38+ """
39+ try:
40+ return self.get_bool("allow_metadata_in_file_properties")
41+ except KeyError:
42+ return False
43+
44 def get_append_revisions_only(self, default=None):
45 """Check whether it is possible to remove revisions from the mainline.
46 """
47
48=== modified file 'errors.py'
49--- errors.py 2011-03-15 00:32:10 +0000
50+++ errors.py 2011-03-23 23:35:40 +0000
51@@ -273,6 +273,11 @@
52 BzrError.__init__(self, msg=msg)
53
54
55+class RequiresMetadataInFileProps(BzrError):
56+
57+ _fmt = """This operation requires storing bzr-svn metadata in Subversion file properties. These file properties may cause spurious conflicts for other Subversion users during merges. To allow this, set `allow_metadata_in_file_properties = True` in your configuration and try again."""
58+
59+
60 class TextChecksumMismatch(VersionedFileInvalidChecksum):
61
62 _fmt = """checksum mismatch: %(expected_checksum)r != %(actual_checksum)r in %(path)s:%(revnum)d"""
63
64=== modified file 'push.py'
65--- push.py 2011-03-23 02:04:30 +0000
66+++ push.py 2011-03-23 23:35:40 +0000
67@@ -686,8 +686,10 @@
68 if not mapping.supports_hidden:
69 raise AssertionError("mapping format %r doesn't support hidden" %
70 mapping)
71+ to_url = urlutils.join(repository.base, branch_path)
72+ config = BranchConfig(to_url, repository.uuid)
73 (set_custom_revprops,
74- set_custom_fileprops) = repository._properties_to_set(mapping)
75+ set_custom_fileprops) = repository._properties_to_set(mapping, config)
76 if set_custom_revprops:
77 mapping.export_hidden_revprops(branch_path, revprops)
78 if (not set_custom_fileprops and
79
80=== modified file 'repository.py'
81--- repository.py 2011-03-18 14:34:46 +0000
82+++ repository.py 2011-03-23 23:35:40 +0000
83@@ -574,7 +574,7 @@
84 return mapping_registry.get(config_mapping_name)
85 return mapping_registry.get_default()
86
87- def _properties_to_set(self, mapping):
88+ def _properties_to_set(self, mapping, target_config):
89 """Determine what sort of custom properties to set when
90 committing a new round-tripped revision.
91
92@@ -583,9 +583,14 @@
93 """
94 supports_custom_revprops = self.transport.has_capability("commit-revprops")
95 if supports_custom_revprops and mapping.can_use_revprops:
96- return (True, mapping.must_use_fileprops)
97+ use_revprops = True
98+ use_fileprops = mapping.must_use_fileprops
99 else:
100- return (False, mapping.can_use_fileprops)
101+ use_revprops = False
102+ use_fileprops = mapping.can_use_fileprops
103+ if use_fileprops and not target_config.get_allow_metadata_in_fileprops():
104+ raise errors.RequiresMetadataInFileProps()
105+ return (use_revprops, use_fileprops)
106
107 def get_mapping(self):
108 """Get the default mapping that is used for this repository."""
109
110=== modified file 'tests/mapping3/__init__.py'
111--- tests/mapping3/__init__.py 2011-03-14 00:39:38 +0000
112+++ tests/mapping3/__init__.py 2011-03-23 23:35:40 +0000
113@@ -26,6 +26,12 @@
114 from bzrlib.tests import TestCase
115 from bzrlib.workingtree import WorkingTree
116
117+from bzrlib.plugins.svn.config import (
118+ BranchConfig,
119+ )
120+from bzrlib.plugins.svn.errors import (
121+ RequiresMetadataInFileProps,
122+ )
123 from bzrlib.plugins.svn.layout.standard import (
124 RootLayout,
125 TrunkLayout,
126@@ -459,6 +465,7 @@
127 def test_commit_revision_id(self):
128 self.make_checkout(self.repos_url, "dc")
129 wt = WorkingTree.open("dc")
130+ wt.branch.get_config().set_user_option("allow_metadata_in_file_properties", "True")
131 self.build_tree({'dc/foo/bla': "data", 'dc/bla': "otherdata"})
132 wt.add('bla')
133 wt.commit(message="data")
134@@ -474,13 +481,26 @@
135 self.client_get_prop("dc",
136 "bzr:revision-id:v3-none", 2))
137
138+ def test_commit_metadata_requires_config_change(self):
139+ self.make_checkout(self.repos_url, "dc")
140+
141+ wt = WorkingTree.open("dc")
142+ self.build_tree({'dc/foo/bla': "data", 'dc/bla': "otherdata"})
143+ wt.add('bla')
144+ self.assertRaises(RequiresMetadataInFileProps, wt.commit,
145+ message="data")
146+ wt.branch.get_config().set_user_option("allow_metadata_in_file_properties", "True")
147+ wt.commit(message="data")
148+
149 def test_commit_metadata(self):
150 self.make_checkout(self.repos_url, "dc")
151
152 wt = WorkingTree.open("dc")
153 self.build_tree({'dc/foo/bla': "data", 'dc/bla': "otherdata"})
154 wt.add('bla')
155+ wt.branch.get_config().set_user_option("allow_metadata_in_file_properties", "True")
156 wt.commit(message="data")
157+
158 branch = Branch.open(self.repos_url)
159 builder = branch.get_commit_builder([branch.last_revision()],
160 timestamp=4534.0, timezone=2, committer="fry",
161@@ -502,6 +522,8 @@
162 self.build_tree({'dc/foo/bla': "data"})
163 self.client_add("dc/foo")
164 wt = WorkingTree.open("dc")
165+ wt.branch.get_config().set_user_option("allow_metadata_in_file_properties", "True")
166+
167 wt.set_pending_merges(["some-ghost-revision"])
168 self.assertEqual(["some-ghost-revision"], wt.get_parent_ids()[1:])
169 wt.commit(message="data")
170@@ -525,6 +547,9 @@
171
172 # Push first branch into Subversion
173 newdir = BzrDir.open(repos_url+"/trunk")
174+ config = BranchConfig(repos_url+"/trunk", newdir.find_repository().uuid)
175+ config.set_user_option("allow_metadata_in_file_properties", "True")
176+
177 newbranch = newdir.import_branch(bzrwt.branch)
178
179 c = ra.RemoteAccess(repos_url)

Subscribers

People subscribed via source and target branches