Status: | Needs review |
---|---|
Proposed branch: | lp:~jelmer/brz/pending |
Merge into: | lp:brz |
Prerequisite: | lp:~jelmer/brz/python3.7 |
Diff against target: |
736 lines (+136/-162) 16 files modified
breezy/bzr/bzrdir.py (+43/-72) breezy/bzr/remote.py (+0/-4) breezy/controldir.py (+24/-7) breezy/errors.py (+0/-5) breezy/git/dir.py (+0/-3) breezy/plugins/cvs/__init__.py (+0/-3) breezy/plugins/darcs/__init__.py (+0/-3) breezy/plugins/mtn/__init__.py (+0/-3) breezy/plugins/weave_fmt/bzrdir.py (+35/-21) breezy/plugins/weave_fmt/test_bzrdir.py (+0/-10) breezy/tests/blackbox/test_upgrade.py (+7/-5) breezy/tests/per_controldir/test_controldir.py (+7/-9) breezy/tests/test_bzrdir.py (+5/-5) breezy/tests/test_upgrade.py (+7/-7) breezy/upgrade.py (+7/-5) tools/prepare_for_latex.py (+1/-0) |
To merge this branch: | bzr merge lp:~jelmer/brz/pending |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Martin Packman | Approve | ||
Review via email: mp+359654@code.launchpad.net |
Commit message
Add registration for Converter objects.
Description of the change
Add registration for Converter objects.
To post a comment you must log in.
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote : | # |
Running landing tests failed
https:/
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote : | # |
Merging failed
https:/
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote : | # |
Running landing tests failed
https:/
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote : | # |
Running landing tests failed
https:/
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote : | # |
Merging failed
https:/
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote : | # |
Merging failed
https:/
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote : | # |
Merging failed
https:/
Unmerged revisions
- 7221. By Jelmer Vernooij
-
Merge trunk.
- 7220. By Jelmer Vernooij
-
Merge trunk.
- 7219. By Jelmer Vernooij
-
Add registration for Converter objects.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'breezy/bzr/bzrdir.py' | |||
2 | --- breezy/bzr/bzrdir.py 2018-11-18 19:48:57 +0000 | |||
3 | +++ breezy/bzr/bzrdir.py 2019-02-04 13:47:49 +0000 | |||
4 | @@ -869,10 +869,6 @@ | |||
5 | 869 | self.control_transport, self._format._lock_file_name, | 869 | self.control_transport, self._format._lock_file_name, |
6 | 870 | self._format._lock_class) | 870 | self._format._lock_class) |
7 | 871 | 871 | ||
8 | 872 | def can_convert_format(self): | ||
9 | 873 | """See BzrDir.can_convert_format().""" | ||
10 | 874 | return True | ||
11 | 875 | |||
12 | 876 | def create_branch(self, name=None, repository=None, | 872 | def create_branch(self, name=None, repository=None, |
13 | 877 | append_revisions_only=None): | 873 | append_revisions_only=None): |
14 | 878 | """See ControlDir.create_branch.""" | 874 | """See ControlDir.create_branch.""" |
15 | @@ -1612,21 +1608,6 @@ | |||
16 | 1612 | ' using format:\n %s'), | 1608 | ' using format:\n %s'), |
17 | 1613 | new_branch_format.get_format_description()) | 1609 | new_branch_format.get_format_description()) |
18 | 1614 | 1610 | ||
19 | 1615 | def get_converter(self, format=None): | ||
20 | 1616 | """See BzrDirFormat.get_converter().""" | ||
21 | 1617 | if format is None: | ||
22 | 1618 | format = BzrDirFormat.get_default_format() | ||
23 | 1619 | if (isinstance(self, BzrDirMetaFormat1) | ||
24 | 1620 | and isinstance(format, BzrDirMetaFormat1Colo)): | ||
25 | 1621 | return ConvertMetaToColo(format) | ||
26 | 1622 | if (isinstance(self, BzrDirMetaFormat1Colo) | ||
27 | 1623 | and isinstance(format, BzrDirMetaFormat1)): | ||
28 | 1624 | return ConvertMetaToColo(format) | ||
29 | 1625 | if not isinstance(self, format.__class__): | ||
30 | 1626 | # converting away from metadir is not implemented | ||
31 | 1627 | raise NotImplementedError(self.get_converter) | ||
32 | 1628 | return ConvertMetaToMeta(format) | ||
33 | 1629 | |||
34 | 1630 | @classmethod | 1611 | @classmethod |
35 | 1631 | def get_format_string(cls): | 1612 | def get_format_string(cls): |
36 | 1632 | """See BzrDirFormat.get_format_string().""" | 1613 | """See BzrDirFormat.get_format_string().""" |
37 | @@ -1720,29 +1701,27 @@ | |||
38 | 1720 | return BzrDirMeta1(transport, format) | 1701 | return BzrDirMeta1(transport, format) |
39 | 1721 | 1702 | ||
40 | 1722 | 1703 | ||
42 | 1723 | class ConvertMetaToMeta(controldir.Converter): | 1704 | class ConvertMetaContents(controldir.Converter): |
43 | 1724 | """Converts the components of metadirs.""" | 1705 | """Converts the components of metadirs.""" |
44 | 1725 | 1706 | ||
53 | 1726 | def __init__(self, target_format): | 1707 | @classmethod |
54 | 1727 | """Create a metadir to metadir converter. | 1708 | def is_compatible(cls, source_format, target_format): |
55 | 1728 | 1709 | return (isinstance(source_format, BzrDirMetaFormat1) and | |
56 | 1729 | :param target_format: The final metadir format that is desired. | 1710 | isinstance(target_format, BzrDirMetaFormat1) and |
57 | 1730 | """ | 1711 | source_format.get_format_string() == target_format.get_format_string()) |
58 | 1731 | self.target_format = target_format | 1712 | |
59 | 1732 | 1713 | def convert(self, to_convert, target_format, pb): | |
52 | 1733 | def convert(self, to_convert, pb): | ||
60 | 1734 | """See Converter.convert().""" | 1714 | """See Converter.convert().""" |
61 | 1735 | self.controldir = to_convert | ||
62 | 1736 | self.pb = ui.ui_factory.nested_progress_bar() | 1715 | self.pb = ui.ui_factory.nested_progress_bar() |
63 | 1737 | self.count = 0 | 1716 | self.count = 0 |
64 | 1738 | self.total = 1 | 1717 | self.total = 1 |
65 | 1739 | self.step('checking repository format') | 1718 | self.step('checking repository format') |
66 | 1740 | try: | 1719 | try: |
68 | 1741 | repo = self.controldir.open_repository() | 1720 | repo = to_convert.open_repository() |
69 | 1742 | except errors.NoRepositoryPresent: | 1721 | except errors.NoRepositoryPresent: |
70 | 1743 | pass | 1722 | pass |
71 | 1744 | else: | 1723 | else: |
73 | 1745 | repo_fmt = self.target_format.repository_format | 1724 | repo_fmt = target_format.repository_format |
74 | 1746 | if not isinstance(repo._format, repo_fmt.__class__): | 1725 | if not isinstance(repo._format, repo_fmt.__class__): |
75 | 1747 | from ..repository import CopyConverter | 1726 | from ..repository import CopyConverter |
76 | 1748 | ui.ui_factory.note(gettext('starting repository conversion')) | 1727 | ui.ui_factory.note(gettext('starting repository conversion')) |
77 | @@ -1750,14 +1729,14 @@ | |||
78 | 1750 | raise AssertionError( | 1729 | raise AssertionError( |
79 | 1751 | "Repository in metadir does not support " | 1730 | "Repository in metadir does not support " |
80 | 1752 | "overriding transport") | 1731 | "overriding transport") |
82 | 1753 | converter = CopyConverter(self.target_format.repository_format) | 1732 | converter = CopyConverter(target_format.repository_format) |
83 | 1754 | converter.convert(repo, pb) | 1733 | converter.convert(repo, pb) |
85 | 1755 | for branch in self.controldir.list_branches(): | 1734 | for branch in to_convert.list_branches(): |
86 | 1756 | # TODO: conversions of Branch and Tree should be done by | 1735 | # TODO: conversions of Branch and Tree should be done by |
87 | 1757 | # InterXFormat lookups/some sort of registry. | 1736 | # InterXFormat lookups/some sort of registry. |
88 | 1758 | # Avoid circular imports | 1737 | # Avoid circular imports |
89 | 1759 | old = branch._format.__class__ | 1738 | old = branch._format.__class__ |
91 | 1760 | new = self.target_format.get_branch_format().__class__ | 1739 | new = target_format.get_branch_format().__class__ |
92 | 1761 | while old != new: | 1740 | while old != new: |
93 | 1762 | if (old == fullhistorybranch.BzrBranchFormat5 | 1741 | if (old == fullhistorybranch.BzrBranchFormat5 |
94 | 1763 | and new in (_mod_bzrbranch.BzrBranchFormat6, | 1742 | and new in (_mod_bzrbranch.BzrBranchFormat6, |
95 | @@ -1775,10 +1754,10 @@ | |||
96 | 1775 | raise errors.BadConversionTarget("No converter", new, | 1754 | raise errors.BadConversionTarget("No converter", new, |
97 | 1776 | branch._format) | 1755 | branch._format) |
98 | 1777 | branch_converter.convert(branch) | 1756 | branch_converter.convert(branch) |
100 | 1778 | branch = self.controldir.open_branch() | 1757 | branch = to_convert.open_branch() |
101 | 1779 | old = branch._format.__class__ | 1758 | old = branch._format.__class__ |
102 | 1780 | try: | 1759 | try: |
104 | 1781 | tree = self.controldir.open_workingtree(recommend_upgrade=False) | 1760 | tree = to_convert.open_workingtree(recommend_upgrade=False) |
105 | 1782 | except (errors.NoWorkingTree, errors.NotLocalUrl): | 1761 | except (errors.NoWorkingTree, errors.NotLocalUrl): |
106 | 1783 | pass | 1762 | pass |
107 | 1784 | else: | 1763 | else: |
108 | @@ -1786,56 +1765,48 @@ | |||
109 | 1786 | # InterXFormat lookups | 1765 | # InterXFormat lookups |
110 | 1787 | if (isinstance(tree, workingtree_3.WorkingTree3) | 1766 | if (isinstance(tree, workingtree_3.WorkingTree3) |
111 | 1788 | and not isinstance(tree, workingtree_4.DirStateWorkingTree) | 1767 | and not isinstance(tree, workingtree_4.DirStateWorkingTree) |
113 | 1789 | and isinstance(self.target_format.workingtree_format, | 1768 | and isinstance(target_format.workingtree_format, |
114 | 1790 | workingtree_4.DirStateWorkingTreeFormat)): | 1769 | workingtree_4.DirStateWorkingTreeFormat)): |
115 | 1791 | workingtree_4.Converter3to4().convert(tree) | 1770 | workingtree_4.Converter3to4().convert(tree) |
116 | 1792 | if (isinstance(tree, workingtree_4.DirStateWorkingTree) | 1771 | if (isinstance(tree, workingtree_4.DirStateWorkingTree) |
117 | 1793 | and not isinstance(tree, workingtree_4.WorkingTree5) | 1772 | and not isinstance(tree, workingtree_4.WorkingTree5) |
119 | 1794 | and isinstance(self.target_format.workingtree_format, | 1773 | and isinstance(target_format.workingtree_format, |
120 | 1795 | workingtree_4.WorkingTreeFormat5)): | 1774 | workingtree_4.WorkingTreeFormat5)): |
121 | 1796 | workingtree_4.Converter4to5().convert(tree) | 1775 | workingtree_4.Converter4to5().convert(tree) |
122 | 1797 | if (isinstance(tree, workingtree_4.DirStateWorkingTree) | 1776 | if (isinstance(tree, workingtree_4.DirStateWorkingTree) |
123 | 1798 | and not isinstance(tree, workingtree_4.WorkingTree6) | 1777 | and not isinstance(tree, workingtree_4.WorkingTree6) |
125 | 1799 | and isinstance(self.target_format.workingtree_format, | 1778 | and isinstance(target_format.workingtree_format, |
126 | 1800 | workingtree_4.WorkingTreeFormat6)): | 1779 | workingtree_4.WorkingTreeFormat6)): |
127 | 1801 | workingtree_4.Converter4or5to6().convert(tree) | 1780 | workingtree_4.Converter4or5to6().convert(tree) |
128 | 1802 | self.pb.finished() | 1781 | self.pb.finished() |
129 | 1803 | return to_convert | 1782 | return to_convert |
130 | 1804 | 1783 | ||
131 | 1805 | 1784 | ||
165 | 1806 | class ConvertMetaToColo(controldir.Converter): | 1785 | controldir.Converter.register_converter(ConvertMetaContents) |
166 | 1807 | """Add colocated branch support.""" | 1786 | |
167 | 1808 | 1787 | ||
168 | 1809 | def __init__(self, target_format): | 1788 | class ConvertMetaToColo(controldir.Converter): |
169 | 1810 | """Create a converter.that upgrades a metadir to the colo format. | 1789 | """Convert a 'development-colo' bzrdir to a '2a' bzrdir and vice versa. |
170 | 1811 | 1790 | """ | |
171 | 1812 | :param target_format: The final metadir format that is desired. | 1791 | |
172 | 1813 | """ | 1792 | @classmethod |
173 | 1814 | self.target_format = target_format | 1793 | def is_compatible(self, source_format, target_format): |
174 | 1815 | 1794 | if (isinstance(source_format, BzrDirMetaFormat1) | |
175 | 1816 | def convert(self, to_convert, pb): | 1795 | and isinstance(target_format, BzrDirMetaFormat1Colo)): |
176 | 1817 | """See Converter.convert().""" | 1796 | return True |
177 | 1818 | to_convert.transport.put_bytes('branch-format', | 1797 | if (isinstance(source_format, BzrDirMetaFormat1Colo) |
178 | 1819 | self.target_format.as_string()) | 1798 | and isinstance(target_format, BzrDirMetaFormat1)): |
179 | 1820 | return BzrDir.open_from_transport(to_convert.root_transport) | 1799 | return True |
180 | 1821 | 1800 | return False | |
181 | 1822 | 1801 | ||
182 | 1823 | class ConvertMetaToColo(controldir.Converter): | 1802 | def convert(self, to_convert, target_format, pb): |
183 | 1824 | """Convert a 'development-colo' bzrdir to a '2a' bzrdir.""" | 1803 | """See Converter.convert().""" |
184 | 1825 | 1804 | to_convert.transport.put_bytes('branch-format', | |
185 | 1826 | def __init__(self, target_format): | 1805 | target_format.as_string()) |
186 | 1827 | """Create a converter that converts a 'development-colo' metadir | 1806 | return BzrDir.open_from_transport(to_convert.root_transport) |
187 | 1828 | to a '2a' metadir. | 1807 | |
188 | 1829 | 1808 | ||
189 | 1830 | :param target_format: The final metadir format that is desired. | 1809 | controldir.Converter.register_converter(ConvertMetaToColo) |
157 | 1831 | """ | ||
158 | 1832 | self.target_format = target_format | ||
159 | 1833 | |||
160 | 1834 | def convert(self, to_convert, pb): | ||
161 | 1835 | """See Converter.convert().""" | ||
162 | 1836 | to_convert.transport.put_bytes('branch-format', | ||
163 | 1837 | self.target_format.as_string()) | ||
164 | 1838 | return BzrDir.open_from_transport(to_convert.root_transport) | ||
190 | 1839 | 1810 | ||
191 | 1840 | 1811 | ||
192 | 1841 | class CreateRepository(controldir.RepositoryAcquisitionPolicy): | 1812 | class CreateRepository(controldir.RepositoryAcquisitionPolicy): |
193 | 1842 | 1813 | ||
194 | === modified file 'breezy/bzr/remote.py' | |||
195 | --- breezy/bzr/remote.py 2019-01-01 23:40:59 +0000 | |||
196 | +++ breezy/bzr/remote.py 2019-02-04 13:47:49 +0000 | |||
197 | @@ -932,10 +932,6 @@ | |||
198 | 932 | self._ensure_real() | 932 | self._ensure_real() |
199 | 933 | return self._real_bzrdir.get_workingtree_transport(workingtree_format) | 933 | return self._real_bzrdir.get_workingtree_transport(workingtree_format) |
200 | 934 | 934 | ||
201 | 935 | def can_convert_format(self): | ||
202 | 936 | """Upgrading of remote bzrdirs is not supported yet.""" | ||
203 | 937 | return False | ||
204 | 938 | |||
205 | 939 | def needs_format_conversion(self, format): | 935 | def needs_format_conversion(self, format): |
206 | 940 | """Upgrading of remote bzrdirs is not supported yet.""" | 936 | """Upgrading of remote bzrdirs is not supported yet.""" |
207 | 941 | return False | 937 | return False |
208 | 942 | 938 | ||
209 | === modified file 'breezy/controldir.py' | |||
210 | --- breezy/controldir.py 2018-11-12 01:41:38 +0000 | |||
211 | +++ breezy/controldir.py 2019-02-04 13:47:49 +0000 | |||
212 | @@ -118,11 +118,6 @@ | |||
213 | 118 | API users to check for magic attributes to see what features are supported. | 118 | API users to check for magic attributes to see what features are supported. |
214 | 119 | """ | 119 | """ |
215 | 120 | 120 | ||
216 | 121 | def can_convert_format(self): | ||
217 | 122 | """Return true if this controldir is one whose format we can convert | ||
218 | 123 | from.""" | ||
219 | 124 | return True | ||
220 | 125 | |||
221 | 126 | def list_branches(self): | 121 | def list_branches(self): |
222 | 127 | """Return a sequence of all branches local to this control directory. | 122 | """Return a sequence of all branches local to this control directory. |
223 | 128 | 123 | ||
224 | @@ -990,18 +985,38 @@ | |||
225 | 990 | class Converter(object): | 985 | class Converter(object): |
226 | 991 | """Converts a disk format object from one format to another.""" | 986 | """Converts a disk format object from one format to another.""" |
227 | 992 | 987 | ||
229 | 993 | def convert(self, to_convert, pb): | 988 | _converters = [] |
230 | 989 | |||
231 | 990 | def convert(self, to_convert, target_format, pb): | ||
232 | 994 | """Perform the conversion of to_convert, giving feedback via pb. | 991 | """Perform the conversion of to_convert, giving feedback via pb. |
233 | 995 | 992 | ||
234 | 996 | :param to_convert: The disk object to convert. | 993 | :param to_convert: The disk object to convert. |
235 | 994 | :param target_format: The target format | ||
236 | 997 | :param pb: a progress bar to use for progress information. | 995 | :param pb: a progress bar to use for progress information. |
237 | 998 | """ | 996 | """ |
238 | 997 | raise NotImplementedError(self.convert) | ||
239 | 999 | 998 | ||
240 | 1000 | def step(self, message): | 999 | def step(self, message): |
241 | 1001 | """Update the pb by a step.""" | 1000 | """Update the pb by a step.""" |
242 | 1002 | self.count += 1 | 1001 | self.count += 1 |
243 | 1003 | self.pb.update(message, self.count, self.total) | 1002 | self.pb.update(message, self.count, self.total) |
244 | 1004 | 1003 | ||
245 | 1004 | @classmethod | ||
246 | 1005 | def is_compatible(cls, source_format, target_format): | ||
247 | 1006 | raise NotImplementedError(cls.is_compatible) | ||
248 | 1007 | |||
249 | 1008 | @classmethod | ||
250 | 1009 | def register_converter(cls, converter): | ||
251 | 1010 | cls._converters.append(converter) | ||
252 | 1011 | |||
253 | 1012 | @classmethod | ||
254 | 1013 | def get_converter(cls, source_format, target_format): | ||
255 | 1014 | for converter in cls._converters: | ||
256 | 1015 | if converter.is_compatible(source_format, target_format): | ||
257 | 1016 | return converter() | ||
258 | 1017 | raise errors.BadConversionTarget( | ||
259 | 1018 | "no converter available", target_format, source_format) | ||
260 | 1019 | |||
261 | 1005 | 1020 | ||
262 | 1006 | class ControlDirFormat(object): | 1021 | class ControlDirFormat(object): |
263 | 1007 | """An encapsulation of the initialization and open routines for a format. | 1022 | """An encapsulation of the initialization and open routines for a format. |
264 | @@ -1070,7 +1085,9 @@ | |||
265 | 1070 | :param format: Optional format to override the default format of the | 1085 | :param format: Optional format to override the default format of the |
266 | 1071 | library. | 1086 | library. |
267 | 1072 | """ | 1087 | """ |
269 | 1073 | raise NotImplementedError(self.get_converter) | 1088 | if format is None: |
270 | 1089 | format = ControlDirFormat.get_default_format() | ||
271 | 1090 | return Converter.get_converter(self, format) | ||
272 | 1074 | 1091 | ||
273 | 1075 | def is_supported(self): | 1092 | def is_supported(self): |
274 | 1076 | """Is this format supported? | 1093 | """Is this format supported? |
275 | 1077 | 1094 | ||
276 | === modified file 'breezy/errors.py' | |||
277 | --- breezy/errors.py 2018-11-11 04:08:32 +0000 | |||
278 | +++ breezy/errors.py 2019-02-04 13:47:49 +0000 | |||
279 | @@ -922,11 +922,6 @@ | |||
280 | 922 | self.lock_token = lock_token | 922 | self.lock_token = lock_token |
281 | 923 | 923 | ||
282 | 924 | 924 | ||
283 | 925 | class UpgradeReadonly(BzrError): | ||
284 | 926 | |||
285 | 927 | _fmt = "Upgrade URL cannot work with readonly URLs." | ||
286 | 928 | |||
287 | 929 | |||
288 | 930 | class UpToDateFormat(BzrError): | 925 | class UpToDateFormat(BzrError): |
289 | 931 | 926 | ||
290 | 932 | _fmt = "The branch format %(format)s is already at the most recent format." | 927 | _fmt = "The branch format %(format)s is already at the most recent format." |
291 | 933 | 928 | ||
292 | === modified file 'breezy/git/dir.py' | |||
293 | --- breezy/git/dir.py 2018-11-16 11:37:47 +0000 | |||
294 | +++ breezy/git/dir.py 2019-02-04 13:47:49 +0000 | |||
295 | @@ -107,9 +107,6 @@ | |||
296 | 107 | def is_supported(self): | 107 | def is_supported(self): |
297 | 108 | return True | 108 | return True |
298 | 109 | 109 | ||
299 | 110 | def can_convert_format(self): | ||
300 | 111 | return False | ||
301 | 112 | |||
302 | 113 | def break_lock(self): | 110 | def break_lock(self): |
303 | 114 | # There are no global locks, so nothing to break. | 111 | # There are no global locks, so nothing to break. |
304 | 115 | raise NotImplementedError(self.break_lock) | 112 | raise NotImplementedError(self.break_lock) |
305 | 116 | 113 | ||
306 | === modified file 'breezy/plugins/cvs/__init__.py' | |||
307 | --- breezy/plugins/cvs/__init__.py 2018-11-11 04:08:32 +0000 | |||
308 | +++ breezy/plugins/cvs/__init__.py 2019-02-04 13:47:49 +0000 | |||
309 | @@ -39,9 +39,6 @@ | |||
310 | 39 | class CVSDirFormat(controldir.ControlDirFormat): | 39 | class CVSDirFormat(controldir.ControlDirFormat): |
311 | 40 | """The CVS directory control format.""" | 40 | """The CVS directory control format.""" |
312 | 41 | 41 | ||
313 | 42 | def get_converter(self): | ||
314 | 43 | raise NotImplementedError(self.get_converter) | ||
315 | 44 | |||
316 | 45 | def get_format_description(self): | 42 | def get_format_description(self): |
317 | 46 | return "CVS control directory." | 43 | return "CVS control directory." |
318 | 47 | 44 | ||
319 | 48 | 45 | ||
320 | === modified file 'breezy/plugins/darcs/__init__.py' | |||
321 | --- breezy/plugins/darcs/__init__.py 2018-11-11 04:08:32 +0000 | |||
322 | +++ breezy/plugins/darcs/__init__.py 2019-02-04 13:47:49 +0000 | |||
323 | @@ -37,9 +37,6 @@ | |||
324 | 37 | class DarcsDirFormat(controldir.ControlDirFormat): | 37 | class DarcsDirFormat(controldir.ControlDirFormat): |
325 | 38 | """Darcs directory format.""" | 38 | """Darcs directory format.""" |
326 | 39 | 39 | ||
327 | 40 | def get_converter(self): | ||
328 | 41 | raise NotImplementedError(self.get_converter) | ||
329 | 42 | |||
330 | 43 | def get_format_description(self): | 40 | def get_format_description(self): |
331 | 44 | return "darcs control directory" | 41 | return "darcs control directory" |
332 | 45 | 42 | ||
333 | 46 | 43 | ||
334 | === modified file 'breezy/plugins/mtn/__init__.py' | |||
335 | --- breezy/plugins/mtn/__init__.py 2018-11-11 04:08:32 +0000 | |||
336 | +++ breezy/plugins/mtn/__init__.py 2019-02-04 13:47:49 +0000 | |||
337 | @@ -39,9 +39,6 @@ | |||
338 | 39 | class MonotoneDirFormat(controldir.ControlDirFormat): | 39 | class MonotoneDirFormat(controldir.ControlDirFormat): |
339 | 40 | """Monotone directory format.""" | 40 | """Monotone directory format.""" |
340 | 41 | 41 | ||
341 | 42 | def get_converter(self): | ||
342 | 43 | raise NotImplementedError(self.get_converter) | ||
343 | 44 | |||
344 | 45 | def get_format_description(self): | 42 | def get_format_description(self): |
345 | 46 | return "Monotone control directory" | 43 | return "Monotone control directory" |
346 | 47 | 44 | ||
347 | 48 | 45 | ||
348 | === modified file 'breezy/plugins/weave_fmt/bzrdir.py' | |||
349 | --- breezy/plugins/weave_fmt/bzrdir.py 2018-11-11 04:08:32 +0000 | |||
350 | +++ breezy/plugins/weave_fmt/bzrdir.py 2019-02-04 13:47:49 +0000 | |||
351 | @@ -126,11 +126,6 @@ | |||
352 | 126 | """See ControlDirFormat.get_format_description().""" | 126 | """See ControlDirFormat.get_format_description().""" |
353 | 127 | return "All-in-one format 5" | 127 | return "All-in-one format 5" |
354 | 128 | 128 | ||
355 | 129 | def get_converter(self, format=None): | ||
356 | 130 | """See ControlDirFormat.get_converter().""" | ||
357 | 131 | # there is one and only one upgrade path here. | ||
358 | 132 | return ConvertBzrDir5To6() | ||
359 | 133 | |||
360 | 134 | def _initialize_for_clone(self, url): | 129 | def _initialize_for_clone(self, url): |
361 | 135 | return self.initialize_on_transport(get_transport(url), _cloning=True) | 130 | return self.initialize_on_transport(get_transport(url), _cloning=True) |
362 | 136 | 131 | ||
363 | @@ -190,11 +185,6 @@ | |||
364 | 190 | from .branch import BzrBranchFormat4 | 185 | from .branch import BzrBranchFormat4 |
365 | 191 | return BzrBranchFormat4() | 186 | return BzrBranchFormat4() |
366 | 192 | 187 | ||
367 | 193 | def get_converter(self, format=None): | ||
368 | 194 | """See ControlDirFormat.get_converter().""" | ||
369 | 195 | # there is one and only one upgrade path here. | ||
370 | 196 | return ConvertBzrDir6ToMeta() | ||
371 | 197 | |||
372 | 198 | def _initialize_for_clone(self, url): | 188 | def _initialize_for_clone(self, url): |
373 | 199 | return self.initialize_on_transport(get_transport(url), _cloning=True) | 189 | return self.initialize_on_transport(get_transport(url), _cloning=True) |
374 | 200 | 190 | ||
375 | @@ -236,7 +226,15 @@ | |||
376 | 236 | self.text_count = 0 | 226 | self.text_count = 0 |
377 | 237 | self.revisions = {} | 227 | self.revisions = {} |
378 | 238 | 228 | ||
380 | 239 | def convert(self, to_convert, pb): | 229 | @classmethod |
381 | 230 | def is_compatible(cls, source_format, target_format): | ||
382 | 231 | if not isinstance(target_format, BzrDirFormat5): | ||
383 | 232 | return False | ||
384 | 233 | if not isinstance(source_format, BzrDirFormat4): | ||
385 | 234 | return False | ||
386 | 235 | return True | ||
387 | 236 | |||
388 | 237 | def convert(self, to_convert, target_format, pb): | ||
389 | 240 | """See Converter.convert().""" | 238 | """See Converter.convert().""" |
390 | 241 | self.controldir = to_convert | 239 | self.controldir = to_convert |
391 | 242 | if pb is not None: | 240 | if pb is not None: |
392 | @@ -294,7 +292,7 @@ | |||
393 | 294 | self._cleanup_spare_files_after_format4() | 292 | self._cleanup_spare_files_after_format4() |
394 | 295 | self.branch._transport.put_bytes( | 293 | self.branch._transport.put_bytes( |
395 | 296 | 'branch-format', | 294 | 'branch-format', |
397 | 297 | BzrDirFormat5().get_format_string(), | 295 | target_format.get_format_string(), |
398 | 298 | mode=self.controldir._get_file_mode()) | 296 | mode=self.controldir._get_file_mode()) |
399 | 299 | 297 | ||
400 | 300 | def _cleanup_spare_files_after_format4(self): | 298 | def _cleanup_spare_files_after_format4(self): |
401 | @@ -504,7 +502,15 @@ | |||
402 | 504 | class ConvertBzrDir5To6(Converter): | 502 | class ConvertBzrDir5To6(Converter): |
403 | 505 | """Converts format 5 bzr dirs to format 6.""" | 503 | """Converts format 5 bzr dirs to format 6.""" |
404 | 506 | 504 | ||
406 | 507 | def convert(self, to_convert, pb): | 505 | @classmethod |
407 | 506 | def is_compatible(cls, source_format, target_format): | ||
408 | 507 | if not isinstance(source_format, BzrDirFormat5): | ||
409 | 508 | return False | ||
410 | 509 | if not isinstance(source_format, BzrDirFormat6): | ||
411 | 510 | return False | ||
412 | 511 | return True | ||
413 | 512 | |||
414 | 513 | def convert(self, to_convert, target_format, pb): | ||
415 | 508 | """See Converter.convert().""" | 514 | """See Converter.convert().""" |
416 | 509 | self.controldir = to_convert | 515 | self.controldir = to_convert |
417 | 510 | with ui.ui_factory.nested_progress_bar() as pb: | 516 | with ui.ui_factory.nested_progress_bar() as pb: |
418 | @@ -538,14 +544,22 @@ | |||
419 | 538 | store_transport.move(filename, new_name) | 544 | store_transport.move(filename, new_name) |
420 | 539 | self.controldir.transport.put_bytes( | 545 | self.controldir.transport.put_bytes( |
421 | 540 | 'branch-format', | 546 | 'branch-format', |
423 | 541 | BzrDirFormat6().get_format_string(), | 547 | target_format.get_format_string(), |
424 | 542 | mode=self.controldir._get_file_mode()) | 548 | mode=self.controldir._get_file_mode()) |
425 | 543 | 549 | ||
426 | 544 | 550 | ||
427 | 545 | class ConvertBzrDir6ToMeta(Converter): | 551 | class ConvertBzrDir6ToMeta(Converter): |
428 | 546 | """Converts format 6 bzr dirs to metadirs.""" | 552 | """Converts format 6 bzr dirs to metadirs.""" |
429 | 547 | 553 | ||
431 | 548 | def convert(self, to_convert, pb): | 554 | @classmethod |
432 | 555 | def is_compatible(cls, source_format, target_format): | ||
433 | 556 | if not isinstance(source_format, BzrDirFormat6): | ||
434 | 557 | return False | ||
435 | 558 | if not isinstance(target_format, BzrDirMetaFormat1): | ||
436 | 559 | return False | ||
437 | 560 | return True | ||
438 | 561 | |||
439 | 562 | def convert(self, to_convert, target_format, pb): | ||
440 | 549 | """See Converter.convert().""" | 563 | """See Converter.convert().""" |
441 | 550 | from .repository import RepositoryFormat7 | 564 | from .repository import RepositoryFormat7 |
442 | 551 | from ...bzr.fullhistory import BzrBranchFormat5 | 565 | from ...bzr.fullhistory import BzrBranchFormat5 |
443 | @@ -634,7 +648,7 @@ | |||
444 | 634 | 'checkout/last-revision', last_revision) | 648 | 'checkout/last-revision', last_revision) |
445 | 635 | self.controldir.transport.put_bytes( | 649 | self.controldir.transport.put_bytes( |
446 | 636 | 'branch-format', | 650 | 'branch-format', |
448 | 637 | BzrDirMetaFormat1().get_format_string(), | 651 | target_format.get_format_string(), |
449 | 638 | mode=self.file_mode) | 652 | mode=self.file_mode) |
450 | 639 | self.pb.finished() | 653 | self.pb.finished() |
451 | 640 | return ControlDir.open(self.controldir.user_url) | 654 | return ControlDir.open(self.controldir.user_url) |
452 | @@ -692,11 +706,6 @@ | |||
453 | 692 | """See ControlDirFormat.get_format_description().""" | 706 | """See ControlDirFormat.get_format_description().""" |
454 | 693 | return "All-in-one format 4" | 707 | return "All-in-one format 4" |
455 | 694 | 708 | ||
456 | 695 | def get_converter(self, format=None): | ||
457 | 696 | """See ControlDirFormat.get_converter().""" | ||
458 | 697 | # there is one and only one upgrade path here. | ||
459 | 698 | return ConvertBzrDir4To5() | ||
460 | 699 | |||
461 | 700 | def initialize_on_transport(self, transport): | 709 | def initialize_on_transport(self, transport): |
462 | 701 | """Format 4 branches cannot be created.""" | 710 | """Format 4 branches cannot be created.""" |
463 | 702 | raise errors.UninitializableFormat(self) | 711 | raise errors.UninitializableFormat(self) |
464 | @@ -1000,3 +1009,8 @@ | |||
465 | 1000 | # bzrdir as a whole | 1009 | # bzrdir as a whole |
466 | 1001 | from .workingtree import WorkingTreeFormat2 | 1010 | from .workingtree import WorkingTreeFormat2 |
467 | 1002 | return WorkingTreeFormat2().open(self, _found=True) | 1011 | return WorkingTreeFormat2().open(self, _found=True) |
468 | 1012 | |||
469 | 1013 | |||
470 | 1014 | Converter.register_converter(ConvertBzrDir4To5) | ||
471 | 1015 | Converter.register_converter(ConvertBzrDir5To6) | ||
472 | 1016 | Converter.register_converter(ConvertBzrDir6ToMeta) | ||
473 | 1003 | 1017 | ||
474 | === modified file 'breezy/plugins/weave_fmt/test_bzrdir.py' | |||
475 | --- breezy/plugins/weave_fmt/test_bzrdir.py 2018-11-16 18:33:17 +0000 | |||
476 | +++ breezy/plugins/weave_fmt/test_bzrdir.py 2019-02-04 13:47:49 +0000 | |||
477 | @@ -73,11 +73,6 @@ | |||
478 | 73 | dir = controldir.ControlDir.open(self.get_url()) | 73 | dir = controldir.ControlDir.open(self.get_url()) |
479 | 74 | check_dir_components_use_same_lock(dir) | 74 | check_dir_components_use_same_lock(dir) |
480 | 75 | 75 | ||
481 | 76 | def test_can_convert(self): | ||
482 | 77 | # format 5 dirs are convertable | ||
483 | 78 | dir = BzrDirFormat5().initialize(self.get_url()) | ||
484 | 79 | self.assertTrue(dir.can_convert_format()) | ||
485 | 80 | |||
486 | 81 | def test_needs_conversion(self): | 76 | def test_needs_conversion(self): |
487 | 82 | # format 5 dirs need a conversion if they are not the default, | 77 | # format 5 dirs need a conversion if they are not the default, |
488 | 83 | # and they aren't | 78 | # and they aren't |
489 | @@ -108,11 +103,6 @@ | |||
490 | 108 | dir = controldir.ControlDir.open(self.get_url()) | 103 | dir = controldir.ControlDir.open(self.get_url()) |
491 | 109 | check_dir_components_use_same_lock(dir) | 104 | check_dir_components_use_same_lock(dir) |
492 | 110 | 105 | ||
493 | 111 | def test_can_convert(self): | ||
494 | 112 | # format 6 dirs are convertable | ||
495 | 113 | dir = BzrDirFormat6().initialize(self.get_url()) | ||
496 | 114 | self.assertTrue(dir.can_convert_format()) | ||
497 | 115 | |||
498 | 116 | def test_needs_conversion(self): | 106 | def test_needs_conversion(self): |
499 | 117 | # format 6 dirs need an conversion if they are not the default. | 107 | # format 6 dirs need an conversion if they are not the default. |
500 | 118 | dir = BzrDirFormat6().initialize(self.get_url()) | 108 | dir = BzrDirFormat6().initialize(self.get_url()) |
501 | 119 | 109 | ||
502 | === modified file 'breezy/tests/blackbox/test_upgrade.py' | |||
503 | --- breezy/tests/blackbox/test_upgrade.py 2018-11-11 04:08:32 +0000 | |||
504 | +++ breezy/tests/blackbox/test_upgrade.py 2019-02-04 13:47:49 +0000 | |||
505 | @@ -46,11 +46,15 @@ | |||
506 | 46 | class ConvertOldTestToMeta(controldir.Converter): | 46 | class ConvertOldTestToMeta(controldir.Converter): |
507 | 47 | """A trivial converter, used for testing.""" | 47 | """A trivial converter, used for testing.""" |
508 | 48 | 48 | ||
510 | 49 | def convert(self, to_convert, pb): | 49 | @classmethod |
511 | 50 | def is_compatible(cls, source_format, target_format): | ||
512 | 51 | return True | ||
513 | 52 | |||
514 | 53 | def convert(self, to_convert, target_format, pb): | ||
515 | 50 | ui.ui_factory.note('starting upgrade from old test format to 2a') | 54 | ui.ui_factory.note('starting upgrade from old test format to 2a') |
516 | 51 | to_convert.control_transport.put_bytes( | 55 | to_convert.control_transport.put_bytes( |
517 | 52 | 'branch-format', | 56 | 'branch-format', |
519 | 53 | bzrdir.BzrDirMetaFormat1().get_format_string(), | 57 | target_format.get_format_string(), |
520 | 54 | mode=to_convert._get_file_mode()) | 58 | mode=to_convert._get_file_mode()) |
521 | 55 | return controldir.ControlDir.open(to_convert.user_url) | 59 | return controldir.ControlDir.open(to_convert.user_url) |
522 | 56 | 60 | ||
523 | @@ -59,9 +63,6 @@ | |||
524 | 59 | 63 | ||
525 | 60 | _lock_class = lockable_files.TransportLock | 64 | _lock_class = lockable_files.TransportLock |
526 | 61 | 65 | ||
527 | 62 | def get_converter(self, format=None): | ||
528 | 63 | return ConvertOldTestToMeta() | ||
529 | 64 | |||
530 | 65 | @classmethod | 66 | @classmethod |
531 | 66 | def get_format_string(cls): | 67 | def get_format_string(cls): |
532 | 67 | return b"Ancient Test Format" | 68 | return b"Ancient Test Format" |
533 | @@ -131,6 +132,7 @@ | |||
534 | 131 | 132 | ||
535 | 132 | def test_upgrade_control_dir(self): | 133 | def test_upgrade_control_dir(self): |
536 | 133 | old_format = OldBzrDirFormat() | 134 | old_format = OldBzrDirFormat() |
537 | 135 | self.overrideAttr(controldir.Converter, '_converters', [ConvertOldTestToMeta]) | ||
538 | 134 | self.addCleanup(bzr.BzrProber.formats.remove, | 136 | self.addCleanup(bzr.BzrProber.formats.remove, |
539 | 135 | old_format.get_format_string()) | 137 | old_format.get_format_string()) |
540 | 136 | bzr.BzrProber.formats.register(old_format.get_format_string(), | 138 | bzr.BzrProber.formats.register(old_format.get_format_string(), |
541 | 137 | 139 | ||
542 | === modified file 'breezy/tests/per_controldir/test_controldir.py' | |||
543 | --- breezy/tests/per_controldir/test_controldir.py 2018-11-11 04:08:32 +0000 | |||
544 | +++ breezy/tests/per_controldir/test_controldir.py 2019-02-04 13:47:49 +0000 | |||
545 | @@ -1580,12 +1580,11 @@ | |||
546 | 1580 | def test_can_and_needs_format_conversion(self): | 1580 | def test_can_and_needs_format_conversion(self): |
547 | 1581 | # check that we can ask an instance if its upgradable | 1581 | # check that we can ask an instance if its upgradable |
548 | 1582 | dir = self.make_controldir('.') | 1582 | dir = self.make_controldir('.') |
553 | 1583 | if dir.can_convert_format(): | 1583 | try: |
550 | 1584 | # if its default updatable there must be an updater | ||
551 | 1585 | # (we force the latest known format as downgrades may not be | ||
552 | 1586 | # available | ||
554 | 1587 | self.assertTrue(isinstance(dir._format.get_converter( | 1584 | self.assertTrue(isinstance(dir._format.get_converter( |
555 | 1588 | format=dir._format), controldir.Converter)) | 1585 | format=dir._format), controldir.Converter)) |
556 | 1586 | except errors.BadConversionTarget: | ||
557 | 1587 | pass # No converter available | ||
558 | 1589 | dir.needs_format_conversion( | 1588 | dir.needs_format_conversion( |
559 | 1590 | controldir.ControlDirFormat.get_default_format()) | 1589 | controldir.ControlDirFormat.get_default_format()) |
560 | 1591 | 1590 | ||
561 | @@ -1618,14 +1617,13 @@ | |||
562 | 1618 | dir.create_repository() | 1617 | dir.create_repository() |
563 | 1619 | dir.create_branch() | 1618 | dir.create_branch() |
564 | 1620 | self.createWorkingTreeOrSkip(dir) | 1619 | self.createWorkingTreeOrSkip(dir) |
569 | 1621 | if dir.can_convert_format(): | 1620 | try: |
566 | 1622 | # if its default updatable there must be an updater | ||
567 | 1623 | # (we force the latest known format as downgrades may not be | ||
568 | 1624 | # available | ||
570 | 1625 | with ui.ui_factory.nested_progress_bar() as pb: | 1621 | with ui.ui_factory.nested_progress_bar() as pb: |
572 | 1626 | dir._format.get_converter(format=dir._format).convert(dir, pb) | 1622 | dir._format.get_converter(format=dir._format).convert(dir, dir._format, pb) |
573 | 1627 | # and it should pass 'check' now. | 1623 | # and it should pass 'check' now. |
574 | 1628 | check.check_dwim(self.get_url('.'), False, True, True) | 1624 | check.check_dwim(self.get_url('.'), False, True, True) |
575 | 1625 | except errors.BadConversionTarget: | ||
576 | 1626 | pass # no converter available | ||
577 | 1629 | 1627 | ||
578 | 1630 | def test_format_description(self): | 1628 | def test_format_description(self): |
579 | 1631 | dir = self.make_controldir('.') | 1629 | dir = self.make_controldir('.') |
580 | 1632 | 1630 | ||
581 | === modified file 'breezy/tests/test_bzrdir.py' | |||
582 | --- breezy/tests/test_bzrdir.py 2019-01-04 21:30:02 +0000 | |||
583 | +++ breezy/tests/test_bzrdir.py 2019-02-04 13:47:49 +0000 | |||
584 | @@ -1440,7 +1440,7 @@ | |||
585 | 1440 | format = bzrdir.BzrDirMetaFormat1Colo() | 1440 | format = bzrdir.BzrDirMetaFormat1Colo() |
586 | 1441 | self.assertTrue(tree.controldir.needs_format_conversion(format)) | 1441 | self.assertTrue(tree.controldir.needs_format_conversion(format)) |
587 | 1442 | converter = tree.controldir._format.get_converter(format) | 1442 | converter = tree.controldir._format.get_converter(format) |
589 | 1443 | result = converter.convert(tree.controldir, None) | 1443 | result = converter.convert(tree.controldir, format, None) |
590 | 1444 | self.assertIsInstance(result._format, bzrdir.BzrDirMetaFormat1Colo) | 1444 | self.assertIsInstance(result._format, bzrdir.BzrDirMetaFormat1Colo) |
591 | 1445 | self.assertFalse(result.needs_format_conversion(format)) | 1445 | self.assertFalse(result.needs_format_conversion(format)) |
592 | 1446 | 1446 | ||
593 | @@ -1449,16 +1449,16 @@ | |||
594 | 1449 | format = bzrdir.BzrDirMetaFormat1() | 1449 | format = bzrdir.BzrDirMetaFormat1() |
595 | 1450 | self.assertTrue(tree.controldir.needs_format_conversion(format)) | 1450 | self.assertTrue(tree.controldir.needs_format_conversion(format)) |
596 | 1451 | converter = tree.controldir._format.get_converter(format) | 1451 | converter = tree.controldir._format.get_converter(format) |
598 | 1452 | result = converter.convert(tree.controldir, None) | 1452 | result = converter.convert(tree.controldir, format, None) |
599 | 1453 | self.assertIsInstance(result._format, bzrdir.BzrDirMetaFormat1) | 1453 | self.assertIsInstance(result._format, bzrdir.BzrDirMetaFormat1) |
600 | 1454 | self.assertFalse(result.needs_format_conversion(format)) | 1454 | self.assertFalse(result.needs_format_conversion(format)) |
601 | 1455 | 1455 | ||
602 | 1456 | def test_downgrade_to_2a_too_many_branches(self): | 1456 | def test_downgrade_to_2a_too_many_branches(self): |
603 | 1457 | tree = self.make_branch_and_tree('.', format='development-colo') | 1457 | tree = self.make_branch_and_tree('.', format='development-colo') |
604 | 1458 | tree.controldir.create_branch(name="another-colocated-branch") | 1458 | tree.controldir.create_branch(name="another-colocated-branch") |
608 | 1459 | converter = tree.controldir._format.get_converter( | 1459 | target_format = bzrdir.BzrDirMetaFormat1() |
609 | 1460 | bzrdir.BzrDirMetaFormat1()) | 1460 | converter = tree.controldir._format.get_converter(target_format) |
610 | 1461 | result = converter.convert(tree.controldir, bzrdir.BzrDirMetaFormat1()) | 1461 | result = converter.convert(tree.controldir, target_format, None) |
611 | 1462 | self.assertIsInstance(result._format, bzrdir.BzrDirMetaFormat1) | 1462 | self.assertIsInstance(result._format, bzrdir.BzrDirMetaFormat1) |
612 | 1463 | 1463 | ||
613 | 1464 | def test_nested(self): | 1464 | def test_nested(self): |
614 | 1465 | 1465 | ||
615 | === modified file 'breezy/tests/test_upgrade.py' | |||
616 | --- breezy/tests/test_upgrade.py 2018-11-12 01:41:38 +0000 | |||
617 | +++ breezy/tests/test_upgrade.py 2019-02-04 13:47:49 +0000 | |||
618 | @@ -51,7 +51,7 @@ | |||
619 | 51 | target = controldir.format_registry.make_controldir( | 51 | target = controldir.format_registry.make_controldir( |
620 | 52 | 'dirstate-with-subtree') | 52 | 'dirstate-with-subtree') |
621 | 53 | converter = b.controldir._format.get_converter(target) | 53 | converter = b.controldir._format.get_converter(target) |
623 | 54 | converter.convert(b.controldir, None) | 54 | converter.convert(b.controldir, target, None) |
624 | 55 | new_branch = branch.Branch.open(self.get_url('branch')) | 55 | new_branch = branch.Branch.open(self.get_url('branch')) |
625 | 56 | self.assertIs(new_branch.__class__, bzrbranch.BzrBranch6) | 56 | self.assertIs(new_branch.__class__, bzrbranch.BzrBranch6) |
626 | 57 | self.assertEqual(b'CD', new_branch.last_revision()) | 57 | self.assertEqual(b'CD', new_branch.last_revision()) |
627 | @@ -62,7 +62,7 @@ | |||
628 | 62 | 62 | ||
629 | 63 | b2 = self.make_branch('branch2', format='knit') | 63 | b2 = self.make_branch('branch2', format='knit') |
630 | 64 | converter = b2.controldir._format.get_converter(target) | 64 | converter = b2.controldir._format.get_converter(target) |
632 | 65 | converter.convert(b2.controldir, None) | 65 | converter.convert(b2.controldir, target, None) |
633 | 66 | b2 = branch.Branch.open(self.get_url('branch')) | 66 | b2 = branch.Branch.open(self.get_url('branch')) |
634 | 67 | self.assertIs(b2.__class__, bzrbranch.BzrBranch6) | 67 | self.assertIs(b2.__class__, bzrbranch.BzrBranch6) |
635 | 68 | 68 | ||
636 | @@ -71,7 +71,7 @@ | |||
637 | 71 | target = controldir.format_registry.make_controldir('1.9') | 71 | target = controldir.format_registry.make_controldir('1.9') |
638 | 72 | target.set_branch_format(bzrbranch.BzrBranchFormat8()) | 72 | target.set_branch_format(bzrbranch.BzrBranchFormat8()) |
639 | 73 | converter = b.controldir._format.get_converter(target) | 73 | converter = b.controldir._format.get_converter(target) |
641 | 74 | converter.convert(b.controldir, None) | 74 | converter.convert(b.controldir, target, None) |
642 | 75 | b = branch.Branch.open(self.get_url('branch')) | 75 | b = branch.Branch.open(self.get_url('branch')) |
643 | 76 | self.assertIs(b.__class__, bzrbranch.BzrBranch8) | 76 | self.assertIs(b.__class__, bzrbranch.BzrBranch8) |
644 | 77 | self.assertEqual({}, b._get_all_reference_info()) | 77 | self.assertEqual({}, b._get_all_reference_info()) |
645 | @@ -81,7 +81,7 @@ | |||
646 | 81 | tree = self.make_branch_and_tree('tree', format='knit') | 81 | tree = self.make_branch_and_tree('tree', format='knit') |
647 | 82 | target = controldir.format_registry.make_controldir('dirstate') | 82 | target = controldir.format_registry.make_controldir('dirstate') |
648 | 83 | converter = tree.controldir._format.get_converter(target) | 83 | converter = tree.controldir._format.get_converter(target) |
650 | 84 | converter.convert(tree.controldir, None) | 84 | converter.convert(tree.controldir, target, None) |
651 | 85 | new_tree = workingtree.WorkingTree.open('tree') | 85 | new_tree = workingtree.WorkingTree.open('tree') |
652 | 86 | self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4) | 86 | self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4) |
653 | 87 | self.assertEqual(b'null:', new_tree.last_revision()) | 87 | self.assertEqual(b'null:', new_tree.last_revision()) |
654 | @@ -94,7 +94,7 @@ | |||
655 | 94 | tree.add(['file'], [b'file-id']) | 94 | tree.add(['file'], [b'file-id']) |
656 | 95 | target = controldir.format_registry.make_controldir('dirstate') | 95 | target = controldir.format_registry.make_controldir('dirstate') |
657 | 96 | converter = tree.controldir._format.get_converter(target) | 96 | converter = tree.controldir._format.get_converter(target) |
659 | 97 | converter.convert(tree.controldir, None) | 97 | converter.convert(tree.controldir, target, None) |
660 | 98 | new_tree = workingtree.WorkingTree.open('tree') | 98 | new_tree = workingtree.WorkingTree.open('tree') |
661 | 99 | self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4) | 99 | self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4) |
662 | 100 | self.assertEqual(b'null:', new_tree.last_revision()) | 100 | self.assertEqual(b'null:', new_tree.last_revision()) |
663 | @@ -105,7 +105,7 @@ | |||
664 | 105 | rev_id = tree.commit('first post') | 105 | rev_id = tree.commit('first post') |
665 | 106 | target = controldir.format_registry.make_controldir('dirstate') | 106 | target = controldir.format_registry.make_controldir('dirstate') |
666 | 107 | converter = tree.controldir._format.get_converter(target) | 107 | converter = tree.controldir._format.get_converter(target) |
668 | 108 | converter.convert(tree.controldir, None) | 108 | converter.convert(tree.controldir, target, None) |
669 | 109 | new_tree = workingtree.WorkingTree.open('tree') | 109 | new_tree = workingtree.WorkingTree.open('tree') |
670 | 110 | self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4) | 110 | self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4) |
671 | 111 | self.assertEqual(rev_id, new_tree.last_revision()) | 111 | self.assertEqual(rev_id, new_tree.last_revision()) |
672 | @@ -122,7 +122,7 @@ | |||
673 | 122 | tree.merge_from_branch(merge_tree.branch) | 122 | tree.merge_from_branch(merge_tree.branch) |
674 | 123 | target = controldir.format_registry.make_controldir('dirstate') | 123 | target = controldir.format_registry.make_controldir('dirstate') |
675 | 124 | converter = tree.controldir._format.get_converter(target) | 124 | converter = tree.controldir._format.get_converter(target) |
677 | 125 | converter.convert(tree.controldir, None) | 125 | converter.convert(tree.controldir, target, None) |
678 | 126 | new_tree = workingtree.WorkingTree.open('tree') | 126 | new_tree = workingtree.WorkingTree.open('tree') |
679 | 127 | self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4) | 127 | self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4) |
680 | 128 | self.assertEqual(rev_id2, new_tree.last_revision()) | 128 | self.assertEqual(rev_id2, new_tree.last_revision()) |
681 | 129 | 129 | ||
682 | === modified file 'breezy/upgrade.py' | |||
683 | --- breezy/upgrade.py 2018-11-11 04:08:32 +0000 | |||
684 | +++ breezy/upgrade.py 2019-02-04 13:47:49 +0000 | |||
685 | @@ -32,6 +32,11 @@ | |||
686 | 32 | from .bzr.remote import RemoteBzrDir | 32 | from .bzr.remote import RemoteBzrDir |
687 | 33 | 33 | ||
688 | 34 | 34 | ||
689 | 35 | class UpgradeReadonly(errors.BzrError): | ||
690 | 36 | |||
691 | 37 | _fmt = "Upgrade URL cannot work with readonly URLs." | ||
692 | 38 | |||
693 | 39 | |||
694 | 35 | class Convert(object): | 40 | class Convert(object): |
695 | 36 | 41 | ||
696 | 37 | def __init__(self, url=None, format=None, control_dir=None): | 42 | def __init__(self, url=None, format=None, control_dir=None): |
697 | @@ -60,7 +65,7 @@ | |||
698 | 60 | self.controldir._ensure_real() | 65 | self.controldir._ensure_real() |
699 | 61 | self.controldir = self.controldir._real_bzrdir | 66 | self.controldir = self.controldir._real_bzrdir |
700 | 62 | if self.controldir.root_transport.is_readonly(): | 67 | if self.controldir.root_transport.is_readonly(): |
702 | 63 | raise errors.UpgradeReadonly | 68 | raise UpgradeReadonly |
703 | 64 | self.transport = self.controldir.root_transport | 69 | self.transport = self.controldir.root_transport |
704 | 65 | ui.ui_factory.suppressed_warnings.add(warning_id) | 70 | ui.ui_factory.suppressed_warnings.add(warning_id) |
705 | 66 | try: | 71 | try: |
706 | @@ -96,9 +101,6 @@ | |||
707 | 96 | format = self.format | 101 | format = self.format |
708 | 97 | if not self.controldir.needs_format_conversion(format): | 102 | if not self.controldir.needs_format_conversion(format): |
709 | 98 | raise errors.UpToDateFormat(self.controldir._format) | 103 | raise errors.UpToDateFormat(self.controldir._format) |
710 | 99 | if not self.controldir.can_convert_format(): | ||
711 | 100 | raise errors.BzrError(gettext("cannot upgrade from bzrdir format %s") % | ||
712 | 101 | self.controldir._format) | ||
713 | 102 | self.controldir.check_conversion_target(format) | 104 | self.controldir.check_conversion_target(format) |
714 | 103 | ui.ui_factory.note(gettext('starting upgrade of %s') % | 105 | ui.ui_factory.note(gettext('starting upgrade of %s') % |
715 | 104 | urlutils.unescape_for_display(self.transport.base, 'utf-8')) | 106 | urlutils.unescape_for_display(self.transport.base, 'utf-8')) |
716 | @@ -106,7 +108,7 @@ | |||
717 | 106 | self.backup_oldpath, self.backup_newpath = self.controldir.backup_bzrdir() | 108 | self.backup_oldpath, self.backup_newpath = self.controldir.backup_bzrdir() |
718 | 107 | while self.controldir.needs_format_conversion(format): | 109 | while self.controldir.needs_format_conversion(format): |
719 | 108 | converter = self.controldir._format.get_converter(format) | 110 | converter = self.controldir._format.get_converter(format) |
721 | 109 | self.controldir = converter.convert(self.controldir, None) | 111 | self.controldir = converter.convert(self.controldir, format, None) |
722 | 110 | ui.ui_factory.note(gettext('finished')) | 112 | ui.ui_factory.note(gettext('finished')) |
723 | 111 | 113 | ||
724 | 112 | def clean_up(self): | 114 | def clean_up(self): |
725 | 113 | 115 | ||
726 | === modified file 'tools/prepare_for_latex.py' | |||
727 | --- tools/prepare_for_latex.py 2018-11-17 16:19:11 +0000 | |||
728 | +++ tools/prepare_for_latex.py 2019-02-04 13:47:49 +0000 | |||
729 | @@ -41,6 +41,7 @@ | |||
730 | 41 | DIRECTIVE_ELEMENT_PATTERN = re.compile(u'^\\s+:[^:]+:\\s+') | 41 | DIRECTIVE_ELEMENT_PATTERN = re.compile(u'^\\s+:[^:]+:\\s+') |
731 | 42 | 42 | ||
732 | 43 | class Converter(object): | 43 | class Converter(object): |
733 | 44 | |||
734 | 44 | def __init__(self, srcdir, destdir): | 45 | def __init__(self, srcdir, destdir): |
735 | 45 | self.srcdir = srcdir | 46 | self.srcdir = srcdir |
736 | 46 | self.destdir = destdir | 47 | self.destdir = destdir |
Looks good, thanks!