~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/serializer/__init__.py

  • Committer: John Arbash Meinel
  • Author(s): Mark Hammond
  • Date: 2008-09-09 17:02:21 UTC
  • mto: This revision was merged to the branch mainline in revision 3697.
  • Revision ID: john@arbash-meinel.com-20080909170221-svim3jw2mrz0amp3
An updated transparent icon for bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006 Canonical 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
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""Serializer factory for reading and writing bundles.
18
18
"""
19
19
 
20
 
from __future__ import absolute_import
21
 
 
22
20
import base64
23
21
from StringIO import StringIO
24
22
import re
25
23
 
26
 
from bzrlib import (
27
 
    errors,
28
 
    pyutils,
29
 
    )
 
24
import bzrlib.errors as errors
30
25
from bzrlib.diff import internal_diff
31
26
from bzrlib.revision import NULL_REVISION
32
27
# For backwards-compatibility
72
67
        m = CHANGESET_OLD_HEADER_RE.match(line)
73
68
        if m:
74
69
            version = m.group('version')
75
 
            raise errors.BundleNotSupported(version,
 
70
            raise errors.BundleNotSupported(version, 
76
71
                'old format bundles not supported')
77
72
 
78
73
    if version is None:
79
74
        raise errors.NotABundle('Did not find an opening header')
80
75
 
81
 
    # Now we have a version, to figure out how to read the bundle
 
76
    # Now we have a version, to figure out how to read the bundle 
82
77
    if version not in _serializers:
83
 
        raise errors.BundleNotSupported(version,
 
78
        raise errors.BundleNotSupported(version, 
84
79
            'version not listed in known versions')
85
80
 
86
81
    serializer = _serializers[version](version)
156
151
        """
157
152
        raise NotImplementedError
158
153
 
 
154
    def write(self, source, revision_ids, forced_bases, f):
 
155
        """Write the bundle to the supplied file.
 
156
 
 
157
        DEPRECATED: see write_bundle
 
158
        :param source: A source for revision information
 
159
        :param revision_ids: The list of revision ids to serialize
 
160
        :param forced_bases: A dict of revision -> base that overrides default
 
161
        :param f: The file to output to
 
162
        """
 
163
        raise NotImplementedError
 
164
 
159
165
    def _write_bundle(self, repository, revision_id, base_revision_id, out):
160
166
        """Helper function for translating write_bundle to write"""
161
167
        forced_bases = {revision_id:base_revision_id}
162
168
        if base_revision_id is NULL_REVISION:
163
169
            base_revision_id = None
164
 
        graph = repository.get_graph()
165
 
        revision_ids = graph.find_unique_ancestors(revision_id,
166
 
            [base_revision_id])
 
170
        revision_ids = set(repository.get_ancestry(revision_id,
 
171
                           topo_sorted=False))
 
172
        revision_ids.difference_update(repository.get_ancestry(
 
173
            base_revision_id, topo_sorted=False))
167
174
        revision_ids = list(repository.get_graph().iter_topo_order(
168
175
            revision_ids))
169
176
        revision_ids.reverse()
195
202
    :param overwrite: Should this version override a default
196
203
    """
197
204
    def _loader(version):
198
 
        klass = pyutils.get_named_object(module, classname)
 
205
        mod = __import__(module, globals(), locals(), [classname])
 
206
        klass = getattr(mod, classname)
199
207
        return klass(version)
200
208
    register(version, _loader, overwrite=overwrite)
201
209