/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 bzrlib/bundle/serializer/__init__.py

Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# (C) 2005 Canonical Development Ltd
 
1
# (C) 2005-2006 Canonical Development Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
37
37
 
38
38
 
39
39
def _get_filename(f):
40
 
    if hasattr(f, 'name'):
41
 
        return f.name
42
 
    return '<unknown>'
 
40
    return getattr(f, 'name', '<unknown>')
43
41
 
44
42
 
45
43
def read_bundle(f):
98
96
        source.unlock()
99
97
 
100
98
 
101
 
def write_bundle(repository, revision_id, base_revision_id, out):
 
99
def write_bundle(repository, revision_id, base_revision_id, out, format=None):
102
100
    """"""
103
101
    repository.lock_read()
104
102
    try:
105
 
        return _write_bundle(repository, revision_id, base_revision_id, out)
 
103
        return _write_bundle(repository, revision_id, base_revision_id, out,
 
104
                             format)
106
105
    finally:
107
106
        repository.unlock()
108
107
 
109
108
 
110
 
def _write_bundle(repository, revision_id, base_revision_id, out):
 
109
def _write_bundle(repository, revision_id, base_revision_id, out, format):
 
110
    """Write a bundle of revisions.
 
111
 
 
112
    :param repository: Repository containing revisions to serialize.
 
113
    :param revision_id: Head revision_id of the bundle.
 
114
    :param base_revision_id: Revision assumed to be present in repositories
 
115
         applying the bundle.
 
116
    :param out: Output file.
 
117
    """
111
118
    if base_revision_id is NULL_REVISION:
112
119
        base_revision_id = None
113
120
    base_ancestry = set(repository.get_ancestry(base_revision_id))
114
121
    revision_ids = [r for r in repository.get_ancestry(revision_id) if r
115
122
                    not in base_ancestry]
116
123
    revision_ids = list(reversed(revision_ids))
117
 
    write(repository, revision_ids, out, 
 
124
    write(repository, revision_ids, out, format,
118
125
          forced_bases = {revision_id:base_revision_id})
119
126
    return revision_ids
120
127
 
151
158
    
152
159
    # This has to be formatted for "original" date, so that the
153
160
    # revision XML entry will be reproduced faithfully.
154
 
    if offset == None:
 
161
    if offset is None:
155
162
        offset = 0
156
163
    tt = time.gmtime(t + offset)
157
164
 
290
297
    to_file.write('\n')
291
298
 
292
299
register_lazy('0.8', 'bzrlib.bundle.serializer.v08', 'BundleSerializerV08')
 
300
register_lazy('0.9', 'bzrlib.bundle.serializer.v09', 'BundleSerializerV09')
293
301
register_lazy(None, 'bzrlib.bundle.serializer.v08', 'BundleSerializerV08')
294
302