21
21
from bzrlib.osutils import local_time_offset, format_date
24
# This contains a map of format id => formatter
25
# None is considered the default formatter
22
from bzrlib import registry
23
from bzrlib.symbol_versioning import (
28
29
def create_date_str(timestamp=None, offset=None):
29
30
"""Just a wrapper around format_date to provide the right format.
48
49
check_for_clean=False,
49
50
include_revision_history=False,
50
51
include_file_revisions=False,
52
53
"""Build up information about the given branch.
53
54
If working_tree is given, it can be checked for changes.
63
64
:param include_file_revisions: The output should
64
65
include the explicit last-changed revision for each file.
66
:param template: Template for the output formatting, not used by
66
69
self._branch = branch
67
70
self._working_tree = working_tree
68
71
self._check = check_for_clean
69
72
self._include_history = include_revision_history
70
73
self._include_file_revs = include_file_revisions
74
self._template = template
73
77
self._file_revisions = {}
169
173
raise NotImplementedError(VersionInfoBuilder.generate)
176
format_registry = registry.Registry()
179
@deprecated_function(one_zero)
173
180
def register_builder(format, module, class_name):
174
181
"""Register a version info format.
180
187
:param class_name: The string name of the class to instantiate
182
if len(_version_formats) == 0:
183
_version_formats[None] = (module, class_name)
184
_version_formats[format] = (module, class_name)
189
format_registry.register_lazy(format, module, class_name)
192
@deprecated_function(one_zero)
187
193
def get_builder(format):
188
194
"""Get a handle to the version info builder class
190
196
:param format: The lookup key supplied to register_builder
191
197
:return: A class, which follows the VersionInfoBuilder api.
193
builder_module, builder_class_name = _version_formats[format]
194
module = __import__(builder_module, globals(), locals(),
195
[builder_class_name])
196
klass = getattr(module, builder_class_name)
199
return format_registry.get(format)
202
@deprecated_function(one_zero)
200
203
def get_builder_formats():
201
204
"""Get the possible list of formats"""
202
formats = _version_formats.keys()
207
register_builder('rio',
208
'bzrlib.version_info_formats.format_rio',
209
'RioVersionInfoBuilder')
210
register_builder('python',
211
'bzrlib.version_info_formats.format_python',
212
'PythonVersionInfoBuilder')
205
return format_registry.keys()
208
format_registry.register_lazy(
210
'bzrlib.version_info_formats.format_rio',
211
'RioVersionInfoBuilder',
212
'Version info in RIO format.')
213
format_registry.default_key = 'rio'
214
format_registry.register_lazy(
216
'bzrlib.version_info_formats.format_python',
217
'PythonVersionInfoBuilder',
218
'Version info in Python format.')
219
format_registry.register_lazy(
221
'bzrlib.version_info_formats.format_custom',
222
'CustomVersionInfoBuilder',
223
'Version info in Custom template-based format.')