~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-03-06 06:48:25 UTC
  • mfrom: (4070.8.6 debug-config)
  • Revision ID: pqm@pqm.ubuntu.com-20090306064825-kbpwggw21dygeix6
(mbp) debug_flags configuration option

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
from cStringIO import StringIO
18
18
import bz2
27
27
    pack,
28
28
    revision as _mod_revision,
29
29
    trace,
30
 
    serializer,
 
30
    xml_serializer,
31
31
    )
32
 
from bzrlib.bundle import bundle_data, serializer as bundle_serializer
 
32
from bzrlib.bundle import bundle_data, serializer
33
33
from bzrlib.util import bencode
34
34
 
35
35
 
54
54
 
55
55
    def begin(self):
56
56
        """Start writing the bundle"""
57
 
        self._fileobj.write(bundle_serializer._get_bundle_header(
58
 
            bundle_serializer.v4_string))
 
57
        self._fileobj.write(serializer._get_bundle_header(
 
58
            serializer.v4_string))
59
59
        self._fileobj.write('#\n')
60
60
        self._container.begin()
61
61
 
218
218
            yield (bytes, metadata) + self.decode_name(names[0][0])
219
219
 
220
220
 
221
 
class BundleSerializerV4(bundle_serializer.BundleSerializer):
 
221
class BundleSerializerV4(serializer.BundleSerializer):
222
222
    """Implement the high-level bundle interface"""
223
223
 
224
224
    def write(self, repository, revision_ids, forced_bases, fileobj):
250
250
    @staticmethod
251
251
    def get_source_serializer(info):
252
252
        """Retrieve the serializer for a given info object"""
253
 
        return serializer.format_registry.get(info['serializer'])
 
253
        return xml_serializer.format_registry.get(info['serializer'])
254
254
 
255
255
 
256
256
class BundleWriteOperation(object):
270
270
        self.repository = repository
271
271
        bundle = BundleWriter(fileobj)
272
272
        self.bundle = bundle
 
273
        self.base_ancestry = set(repository.get_ancestry(base,
 
274
                                                         topo_sorted=False))
273
275
        if revision_ids is not None:
274
276
            self.revision_ids = revision_ids
275
277
        else:
276
 
            graph = repository.get_graph()
277
 
            revision_ids = graph.find_unique_ancestors(target, [base])
278
 
            # Strip ghosts
279
 
            parents = graph.get_parent_map(revision_ids)
280
 
            self.revision_ids = [r for r in revision_ids if r in parents]
 
278
            revision_ids = set(repository.get_ancestry(target,
 
279
                                                       topo_sorted=False))
 
280
            self.revision_ids = revision_ids.difference(self.base_ancestry)
281
281
        self.revision_keys = set([(revid,) for revid in self.revision_ids])
282
282
 
283
283
    def do_write(self):
322
322
            revision_order.append(self.target)
323
323
        self._add_mp_records_keys('inventory', inv_vf, [(revid,) for revid in revision_order])
324
324
        parent_map = self.repository.get_parent_map(revision_order)
325
 
        revision_to_str = self.repository._serializer.write_revision_to_string
326
 
        revisions = self.repository.get_revisions(revision_order)
327
 
        for revision in revisions:
328
 
            revision_id = revision.revision_id
 
325
        for revision_id in revision_order:
329
326
            parents = parent_map.get(revision_id, None)
330
 
            revision_text = revision_to_str(revision)
 
327
            revision_text = self.repository.get_revision_xml(revision_id)
331
328
            self.bundle.add_fulltext_record(revision_text, parents,
332
329
                                       'revision', revision_id)
333
330
            try: