/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/bzr/__init__.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-11-16 18:59:44 UTC
  • mfrom: (7143.15.15 more-cleanups)
  • Revision ID: breezy.the.bot@gmail.com-20181116185944-biefv1sub37qfybm
Sprinkle some PEP8iness.

Merged from https://code.launchpad.net/~jelmer/brz/more-cleanups/+merge/358611

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
    registry,
25
25
    )
26
26
 
 
27
 
27
28
class BzrProber(controldir.Prober):
28
29
    """Prober for formats that use a .bzr/ control directory."""
29
30
 
38
39
        except errors.NoSuchFile:
39
40
            raise errors.NotBranchError(path=transport.base)
40
41
        try:
41
 
            first_line = format_string[:format_string.index(b"\n")+1]
 
42
            first_line = format_string[:format_string.index(b"\n") + 1]
42
43
        except ValueError:
43
44
            first_line = format_string
44
45
        try:
47
48
            if first_line.endswith(b"\r\n"):
48
49
                raise errors.LineEndingError(file=".bzr/branch-format")
49
50
            else:
50
 
                raise errors.UnknownFormatError(format=first_line, kind='bzrdir')
 
51
                raise errors.UnknownFormatError(
 
52
                    format=first_line, kind='bzrdir')
51
53
        return cls.from_string(format_string)
52
54
 
53
55
    @classmethod
109
111
 
110
112
 
111
113
def register_metadir(registry, key,
112
 
         repository_format, help, native=True, deprecated=False,
113
 
         branch_format=None,
114
 
         tree_format=None,
115
 
         hidden=False,
116
 
         experimental=False,
117
 
         bzrdir_format=None):
 
114
                     repository_format, help, native=True, deprecated=False,
 
115
                     branch_format=None,
 
116
                     tree_format=None,
 
117
                     hidden=False,
 
118
                     experimental=False,
 
119
                     bzrdir_format=None):
118
120
    """Register a metadir subformat.
119
121
 
120
122
    These all use a meta bzrdir, but can be parameterized by the
131
133
        bzrdir_format = 'breezy.bzr.bzrdir.BzrDirMetaFormat1'
132
134
    # This should be expanded to support setting WorkingTree and Branch
133
135
    # formats, once the API supports that.
 
136
 
134
137
    def _load(full_name):
135
138
        mod_name, factory_name = full_name.rsplit('.', 1)
136
139
        try:
139
142
            raise ImportError('failed to load %s: %s' % (full_name, e))
140
143
        except AttributeError:
141
144
            raise AttributeError('no factory %s in module %r'
142
 
                % (full_name, sys.modules[mod_name]))
 
145
                                 % (full_name, sys.modules[mod_name]))
143
146
        return factory()
144
147
 
145
148
    def helper():
152
155
            bd.repository_format = _load(repository_format)
153
156
        return bd
154
157
    registry.register(key, helper, help, native, deprecated, hidden,
155
 
        experimental)
156
 
 
157
 
register_metadir(controldir.format_registry, 'knit',
 
158
                      experimental)
 
159
 
 
160
 
 
161
register_metadir(
 
162
    controldir.format_registry, 'knit',
158
163
    'breezy.bzr.knitrepo.RepositoryFormatKnit1',
159
164
    'Format using knits.  Recommended for interoperation with bzr <= 0.14.',
160
165
    branch_format='breezy.bzr.fullhistory.BzrBranchFormat5',
161
166
    tree_format='breezy.bzr.workingtree_3.WorkingTreeFormat3',
162
167
    hidden=True,
163
168
    deprecated=True)
164
 
register_metadir(controldir.format_registry, 'dirstate',
 
169
register_metadir(
 
170
    controldir.format_registry, 'dirstate',
165
171
    'breezy.bzr.knitrepo.RepositoryFormatKnit1',
166
172
    help='Format using dirstate for working trees. '
167
 
        'Compatible with bzr 0.8 and '
168
 
        'above when accessed over the network. Introduced in bzr 0.15.',
 
173
    'Compatible with bzr 0.8 and '
 
174
    'above when accessed over the network. Introduced in bzr 0.15.',
169
175
    branch_format='breezy.bzr.fullhistory.BzrBranchFormat5',
170
176
    tree_format='breezy.bzr.workingtree_4.WorkingTreeFormat4',
171
177
    hidden=True,
172
178
    deprecated=True)
173
 
register_metadir(controldir.format_registry, 'dirstate-tags',
 
179
register_metadir(
 
180
    controldir.format_registry, 'dirstate-tags',
174
181
    'breezy.bzr.knitrepo.RepositoryFormatKnit1',
175
182
    help='Variant of dirstate with support for tags. '
176
 
        'Introduced in bzr 0.15.',
 
183
    'Introduced in bzr 0.15.',
177
184
    branch_format='breezy.bzr.branch.BzrBranchFormat6',
178
185
    tree_format='breezy.bzr.workingtree_4.WorkingTreeFormat4',
179
186
    hidden=True,
180
187
    deprecated=True)
181
 
register_metadir(controldir.format_registry, 'rich-root',
 
188
register_metadir(
 
189
    controldir.format_registry, 'rich-root',
182
190
    'breezy.bzr.knitrepo.RepositoryFormatKnit4',
183
191
    help='Variant of dirstate with better handling of tree roots. '
184
 
        'Introduced in bzr 1.0',
 
192
    'Introduced in bzr 1.0',
185
193
    branch_format='breezy.bzr.branch.BzrBranchFormat6',
186
194
    tree_format='breezy.bzr.workingtree_4.WorkingTreeFormat4',
187
195
    hidden=True,
188
196
    deprecated=True)
189
 
register_metadir(controldir.format_registry, 'dirstate-with-subtree',
 
197
register_metadir(
 
198
    controldir.format_registry, 'dirstate-with-subtree',
190
199
    'breezy.bzr.knitrepo.RepositoryFormatKnit3',
191
200
    help='Variant of dirstate with support for nested trees. '
192
 
         'Introduced in 0.15.',
 
201
    'Introduced in 0.15.',
193
202
    branch_format='breezy.bzr.branch.BzrBranchFormat6',
194
203
    tree_format='breezy.bzr.workingtree_4.WorkingTreeFormat4',
195
204
    experimental=True,
196
205
    hidden=True,
197
206
    )
198
 
register_metadir(controldir.format_registry, 'pack-0.92',
 
207
register_metadir(
 
208
    controldir.format_registry, 'pack-0.92',
199
209
    'breezy.bzr.knitpack_repo.RepositoryFormatKnitPack1',
200
210
    help='Pack-based format used in 1.x series. Introduced in 0.92. '
201
 
        'Interoperates with bzr repositories before 0.92 but cannot be '
202
 
        'read by bzr < 0.92. '
203
 
        ,
 
211
    'Interoperates with bzr repositories before 0.92 but cannot be '
 
212
    'read by bzr < 0.92. ',
204
213
    branch_format='breezy.bzr.branch.BzrBranchFormat6',
205
214
    tree_format='breezy.bzr.workingtree_4.WorkingTreeFormat4',
206
215
    deprecated=True,
207
216
    hidden=True,
208
217
    )
209
 
register_metadir(controldir.format_registry, 'pack-0.92-subtree',
 
218
register_metadir(
 
219
    controldir.format_registry, 'pack-0.92-subtree',
210
220
    'breezy.bzr.knitpack_repo.RepositoryFormatKnitPack3',
211
221
    help='Pack-based format used in 1.x series, with subtree support. '
212
 
        'Introduced in 0.92. Interoperates with '
213
 
        'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
214
 
        ,
 
222
    'Introduced in 0.92. Interoperates with '
 
223
    'bzr repositories before 0.92 but cannot be read by bzr < 0.92. ',
215
224
    branch_format='breezy.bzr.branch.BzrBranchFormat6',
216
225
    tree_format='breezy.bzr.workingtree_4.WorkingTreeFormat4',
217
226
    hidden=True,
218
227
    deprecated=True,
219
228
    experimental=True,
220
229
    )
221
 
register_metadir(controldir.format_registry, 'rich-root-pack',
 
230
register_metadir(
 
231
    controldir.format_registry, 'rich-root-pack',
222
232
    'breezy.bzr.knitpack_repo.RepositoryFormatKnitPack4',
223
233
    help='A variant of pack-0.92 that supports rich-root data '
224
 
         '(needed for bzr-svn and bzr-git). Introduced in 1.0.',
 
234
    '(needed for bzr-svn and bzr-git). Introduced in 1.0.',
225
235
    branch_format='breezy.bzr.branch.BzrBranchFormat6',
226
236
    tree_format='breezy.bzr.workingtree_4.WorkingTreeFormat4',
227
237
    hidden=True,
228
238
    deprecated=True,
229
239
    )
230
 
register_metadir(controldir.format_registry, '1.6',
 
240
register_metadir(
 
241
    controldir.format_registry, '1.6',
231
242
    'breezy.bzr.knitpack_repo.RepositoryFormatKnitPack5',
232
243
    help='A format that allows a branch to indicate that there is another '
233
 
         '(stacked) repository that should be used to access data that is '
234
 
         'not present locally.',
 
244
    '(stacked) repository that should be used to access data that is '
 
245
    'not present locally.',
235
246
    branch_format='breezy.bzr.branch.BzrBranchFormat7',
236
247
    tree_format='breezy.bzr.workingtree_4.WorkingTreeFormat4',
237
248
    hidden=True,
238
249
    deprecated=True,
239
250
    )
240
 
register_metadir(controldir.format_registry, '1.6.1-rich-root',
 
251
register_metadir(
 
252
    controldir.format_registry, '1.6.1-rich-root',
241
253
    'breezy.bzr.knitpack_repo.RepositoryFormatKnitPack5RichRoot',
242
254
    help='A variant of 1.6 that supports rich-root data '
243
 
         '(needed for bzr-svn and bzr-git).',
 
255
    '(needed for bzr-svn and bzr-git).',
244
256
    branch_format='breezy.bzr.branch.BzrBranchFormat7',
245
257
    tree_format='breezy.bzr.workingtree_4.WorkingTreeFormat4',
246
258
    hidden=True,
247
259
    deprecated=True,
248
260
    )
249
 
register_metadir(controldir.format_registry, '1.9',
 
261
register_metadir(
 
262
    controldir.format_registry, '1.9',
250
263
    'breezy.bzr.knitpack_repo.RepositoryFormatKnitPack6',
251
264
    help='A repository format using B+tree indexes. These indexes '
252
 
         'are smaller in size, have smarter caching and provide faster '
253
 
         'performance for most operations.',
 
265
    'are smaller in size, have smarter caching and provide faster '
 
266
    'performance for most operations.',
254
267
    branch_format='breezy.bzr.branch.BzrBranchFormat7',
255
268
    tree_format='breezy.bzr.workingtree_4.WorkingTreeFormat4',
256
269
    hidden=True,
257
270
    deprecated=True,
258
271
    )
259
 
register_metadir(controldir.format_registry, '1.9-rich-root',
 
272
register_metadir(
 
273
    controldir.format_registry, '1.9-rich-root',
260
274
    'breezy.bzr.knitpack_repo.RepositoryFormatKnitPack6RichRoot',
261
275
    help='A variant of 1.9 that supports rich-root data '
262
 
         '(needed for bzr-svn and bzr-git).',
 
276
    '(needed for bzr-svn and bzr-git).',
263
277
    branch_format='breezy.bzr.branch.BzrBranchFormat7',
264
278
    tree_format='breezy.bzr.workingtree_4.WorkingTreeFormat4',
265
279
    hidden=True,
266
280
    deprecated=True,
267
281
    )
268
 
register_metadir(controldir.format_registry, '1.14',
 
282
register_metadir(
 
283
    controldir.format_registry, '1.14',
269
284
    'breezy.bzr.knitpack_repo.RepositoryFormatKnitPack6',
270
285
    help='A working-tree format that supports content filtering.',
271
286
    branch_format='breezy.bzr.branch.BzrBranchFormat7',
273
288
    hidden=True,
274
289
    deprecated=True,
275
290
    )
276
 
register_metadir(controldir.format_registry, '1.14-rich-root',
 
291
register_metadir(
 
292
    controldir.format_registry, '1.14-rich-root',
277
293
    'breezy.bzr.knitpack_repo.RepositoryFormatKnitPack6RichRoot',
278
294
    help='A variant of 1.14 that supports rich-root data '
279
 
         '(needed for bzr-svn and bzr-git).',
 
295
    '(needed for bzr-svn and bzr-git).',
280
296
    branch_format='breezy.bzr.branch.BzrBranchFormat7',
281
297
    tree_format='breezy.bzr.workingtree_4.WorkingTreeFormat5',
282
298
    hidden=True,
283
299
    deprecated=True,
284
300
    )
285
301
# The following un-numbered 'development' formats should always just be aliases.
286
 
register_metadir(controldir.format_registry, 'development-subtree',
 
302
register_metadir(
 
303
    controldir.format_registry, 'development-subtree',
287
304
    'breezy.bzr.groupcompress_repo.RepositoryFormat2aSubtree',
288
305
    help='Current development format, subtree variant. Can convert data to and '
289
306
        'from pack-0.92-subtree (and anything compatible with '
296
313
    experimental=True,
297
314
    hidden=True,
298
315
    )
299
 
register_metadir(controldir.format_registry, 'development5-subtree',
 
316
register_metadir(
 
317
    controldir.format_registry, 'development5-subtree',
300
318
    'breezy.bzr.knitpack_repo.RepositoryFormatPackDevelopment2Subtree',
301
319
    help='Development format, subtree variant. Can convert data to and '
302
 
        'from pack-0.92-subtree (and anything compatible with '
303
 
        'pack-0.92-subtree) format repositories. Repositories and branches in '
304
 
        'this format can only be read by bzr.dev. Please read '
305
 
        'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
306
 
        'before use.',
 
320
    'from pack-0.92-subtree (and anything compatible with '
 
321
    'pack-0.92-subtree) format repositories. Repositories and branches in '
 
322
    'this format can only be read by bzr.dev. Please read '
 
323
    'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
 
324
    'before use.',
307
325
    branch_format='breezy.bzr.branch.BzrBranchFormat7',
308
326
    tree_format='breezy.bzr.workingtree_4.WorkingTreeFormat6',
309
327
    experimental=True,
310
328
    hidden=True,
311
329
    )
312
330
 
313
 
register_metadir(controldir.format_registry, 'development-colo',
 
331
register_metadir(
 
332
    controldir.format_registry, 'development-colo',
314
333
    'breezy.bzr.groupcompress_repo.RepositoryFormat2a',
315
334
    help='The 2a format with experimental support for colocated branches.\n',
316
335
    branch_format='breezy.bzr.branch.BzrBranchFormat7',
325
344
 
326
345
# Finally, the current format.
327
346
register_metadir(controldir.format_registry, '2a',
328
 
    'breezy.bzr.groupcompress_repo.RepositoryFormat2a',
329
 
    help='Format for the bzr 2.0 series.\n',
330
 
    branch_format='breezy.bzr.branch.BzrBranchFormat7',
331
 
    tree_format='breezy.bzr.workingtree_4.WorkingTreeFormat6',
332
 
    experimental=False,
333
 
    )
 
347
                 'breezy.bzr.groupcompress_repo.RepositoryFormat2a',
 
348
                 help='Format for the bzr 2.0 series.\n',
 
349
                 branch_format='breezy.bzr.branch.BzrBranchFormat7',
 
350
                 tree_format='breezy.bzr.workingtree_4.WorkingTreeFormat6',
 
351
                 experimental=False,
 
352
                 )
334
353
 
335
354
# The following format should be an alias for the rich root equivalent
336
355
# of the default format
337
356
 
338
 
controldir.format_registry.register_alias('default-rich-root', '2a', hidden=True)
 
357
controldir.format_registry.register_alias(
 
358
    'default-rich-root', '2a', hidden=True)
339
359
 
340
360
# The following format should is just an alias for the default bzr format.
341
361
controldir.format_registry.register_alias('bzr', '2a')