~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/serializer.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-29 22:03:03 UTC
  • mfrom: (5416.2.6 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100929220303-cr95h8iwtggco721
(mbp) Add 'break-lock --force'

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2009 Canonical Ltd
 
1
# Copyright (C) 2009, 2010 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
27
27
    squashes_xml_invalid_characters = False
28
28
 
29
29
    def write_inventory(self, inv, f):
30
 
        """Write inventory to a file"""
 
30
        """Write inventory to a file.
 
31
 
 
32
        Note: this is a *whole inventory* operation, and should only be used
 
33
        sparingly, as it does not scale well with large trees.
 
34
        """
31
35
        raise NotImplementedError(self.write_inventory)
32
36
 
33
37
    def write_inventory_to_string(self, inv):
 
38
        """Produce a simple string representation of an inventory.
 
39
 
 
40
        Note: this is a *whole inventory* operation, and should only be used
 
41
        sparingly, as it does not scale well with large trees.
 
42
 
 
43
        The requirement for the contents of the string is that it can be passed
 
44
        to read_inventory_from_string and the result is an identical inventory
 
45
        in memory.
 
46
 
 
47
        (All serializers as of 2009-07-29 produce XML, but this is not mandated
 
48
        by the interface.)
 
49
        """
34
50
        raise NotImplementedError(self.write_inventory_to_string)
35
51
 
36
52
    def read_inventory_from_string(self, string, revision_id=None,
37
 
                                   entry_cache=None):
 
53
                                   entry_cache=None, return_from_cache=False):
38
54
        """Read string into an inventory object.
39
55
 
40
56
        :param string: The serialized inventory to read.
48
64
        :param entry_cache: An optional cache of InventoryEntry objects. If
49
65
            supplied we will look up entries via (file_id, revision_id) which
50
66
            should map to a valid InventoryEntry (File/Directory/etc) object.
 
67
        :param return_from_cache: Return entries directly from the cache,
 
68
            rather than copying them first. This is only safe if the caller
 
69
            promises not to mutate the returned inventory entries, but it can
 
70
            make some operations significantly faster.
51
71
        """
52
72
        raise NotImplementedError(self.read_inventory_from_string)
53
73
 
54
74
    def read_inventory(self, f, revision_id=None):
 
75
        """See read_inventory_from_string."""
55
76
        raise NotImplementedError(self.read_inventory)
56
77
 
57
78
    def write_revision(self, rev, f):