/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/xml8.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
from __future__ import absolute_import
18
18
 
19
 
from .. import (
 
19
import cStringIO
 
20
 
 
21
from bzrlib import (
20
22
    cache_utf8,
21
23
    lazy_regex,
22
24
    revision as _mod_revision,
23
25
    trace,
24
26
    )
25
 
from ..sixish import (
26
 
    BytesIO,
27
 
    )
28
 
from .xml_serializer import (
 
27
from bzrlib.xml_serializer import (
29
28
    Element,
30
29
    SubElement,
31
30
    XMLSerializer,
36
35
    unpack_inventory_entry,
37
36
    unpack_inventory_flat,
38
37
    )
39
 
from ..revision import Revision
40
 
from ..errors import BzrError
 
38
from bzrlib.revision import Revision
 
39
from bzrlib.errors import BzrError
41
40
 
42
41
 
43
42
_xml_unescape_map = {
59
58
        return unichr(int(code[1:])).encode('utf8')
60
59
 
61
60
 
62
 
_unescape_re = lazy_regex.lazy_compile('\\&([^;]*);')
 
61
_unescape_re = lazy_regex.lazy_compile('\&([^;]*);')
63
62
 
64
63
def _unescape_xml(data):
65
64
    """Unescape predefined XML entities in a string of data."""
79
78
    # This format supports the altered-by hack that reads file ids directly out
80
79
    # of the versionedfile, without doing XML parsing.
81
80
 
82
 
    supported_kinds = {'file', 'directory', 'symlink'}
 
81
    supported_kinds = set(['file', 'directory', 'symlink'])
83
82
    format_num = '8'
84
83
    revision_format_num = None
85
84
 
134
133
        return self.write_inventory(inv, None)
135
134
 
136
135
    def write_inventory_to_string(self, inv, working=False):
137
 
        """Just call write_inventory with a BytesIO and return the value.
 
136
        """Just call write_inventory with a StringIO and return the value.
138
137
 
139
138
        :param working: If True skip history data - text_sha1, text_size,
140
139
            reference_revision, symlink_target.
141
140
        """
142
 
        sio = BytesIO()
 
141
        sio = cStringIO.StringIO()
143
142
        self.write_inventory(inv, sio, working)
144
143
        return sio.getvalue()
145
144
 
168
167
    def _append_inventory_root(self, append, inv):
169
168
        """Append the inventory root to output."""
170
169
        if inv.revision_id is not None:
171
 
            revid1 = b' revision_id="'
 
170
            revid1 = ' revision_id="'
172
171
            revid2 = encode_and_escape(inv.revision_id)
173
172
        else:
174
 
            revid1 = b""
175
 
            revid2 = b""
176
 
        append(b'<inventory format="%s"%s%s>\n' % (
 
173
            revid1 = ""
 
174
            revid2 = ""
 
175
        append('<inventory format="%s"%s%s>\n' % (
177
176
            self.format_num, revid1, revid2))
178
 
        append(b'<directory file_id="%s name="%s revision="%s />\n' % (
 
177
        append('<directory file_id="%s name="%s revision="%s />\n' % (
179
178
            encode_and_escape(inv.root.file_id),
180
179
            encode_and_escape(inv.root.name),
181
180
            encode_and_escape(inv.root.revision)))