/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: John Arbash Meinel
  • Date: 2009-04-21 23:54:16 UTC
  • mto: (4300.1.7 groupcompress_info)
  • mto: This revision was merged to the branch mainline in revision 4301.
  • Revision ID: john@arbash-meinel.com-20090421235416-f0cz6ilf5cufbugi
Fix bug #364900, properly remove the 64kB that was just encoded in the copy.
Also, stop supporting None as a copy length in 'encode_copy_instruction'.
It was only used by the test suite, and it is good to pull that sort of thing out of
production code. (Besides, setting the copy to 64kB has the same effect.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2008 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
28
28
    Element,
29
29
    SubElement,
30
30
    XMLSerializer,
31
 
    escape_invalid_chars,
32
31
    )
33
 
from bzrlib.inventory import InventoryEntry
 
32
from bzrlib.inventory import ROOT_ID, Inventory, InventoryEntry
34
33
from bzrlib.revision import Revision
35
34
from bzrlib.errors import BzrError
36
35
 
168
167
        :raises: AssertionError if an error has occurred.
169
168
        """
170
169
        if inv.revision_id is None:
171
 
            raise AssertionError("inv.revision_id is None")
 
170
            raise AssertionError()
172
171
        if inv.root.revision is None:
173
 
            raise AssertionError("inv.root.revision is None")
 
172
            raise AssertionError()
174
173
 
175
174
    def _check_cache_size(self, inv_size, entry_cache):
176
175
        """Check that the entry_cache is large enough.
346
345
            root.set('timezone', str(rev.timezone))
347
346
        root.text = '\n'
348
347
        msg = SubElement(root, 'message')
349
 
        msg.text = escape_invalid_chars(rev.message)[0]
 
348
        msg.text = rev.message
350
349
        msg.tail = '\n'
351
350
        if rev.parent_ids:
352
351
            pelts = SubElement(root, 'parents')
371
370
            prop_elt.tail = '\n'
372
371
        top_elt.tail = '\n'
373
372
 
374
 
    def _unpack_inventory(self, elt, revision_id=None, entry_cache=None,
375
 
                          return_from_cache=False):
 
373
    def _unpack_inventory(self, elt, revision_id=None, entry_cache=None):
376
374
        """Construct from XML Element"""
377
375
        if elt.tag != 'inventory':
378
376
            raise errors.UnexpectedInventoryFormat('Root tag is %r' % elt.tag)
385
383
            revision_id = cache_utf8.encode(revision_id)
386
384
        inv = inventory.Inventory(root_id=None, revision_id=revision_id)
387
385
        for e in elt:
388
 
            ie = self._unpack_entry(e, entry_cache=entry_cache,
389
 
                                    return_from_cache=return_from_cache)
 
386
            ie = self._unpack_entry(e, entry_cache=entry_cache)
390
387
            inv.add(ie)
391
388
        self._check_cache_size(len(inv), entry_cache)
392
389
        return inv
393
390
 
394
 
    def _unpack_entry(self, elt, entry_cache=None, return_from_cache=False):
 
391
    def _unpack_entry(self, elt, entry_cache=None):
395
392
        elt_get = elt.get
396
393
        file_id = elt_get('file_id')
397
394
        revision = elt_get('revision')
435
432
                pass
436
433
            else:
437
434
                # Only copying directory entries drops us 2.85s => 2.35s
438
 
                if return_from_cache:
439
 
                    if cached_ie.kind == 'directory':
440
 
                        return cached_ie.copy()
441
 
                    return cached_ie
 
435
                # if cached_ie.kind == 'directory':
 
436
                #     return cached_ie.copy()
 
437
                # return cached_ie
442
438
                return cached_ie.copy()
443
439
 
444
440
        kind = elt.tag