~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
import os
21
21
 
22
 
from bzrlib.bundle.serializer import (BundleSerializer, 
23
 
                                      BUNDLE_HEADER, 
 
22
from bzrlib import errors
 
23
from bzrlib.bundle.serializer import (BundleSerializer,
 
24
                                      BUNDLE_HEADER,
24
25
                                      format_highres_date,
25
26
                                      unpack_highres_date,
26
27
                                     )
27
28
from bzrlib.bundle.serializer import binary_diff
28
29
from bzrlib.bundle.bundle_data import (RevisionInfo, BundleInfo, BundleTree)
29
 
from bzrlib.delta import compare_trees
30
30
from bzrlib.diff import internal_diff
31
 
import bzrlib.errors as errors
32
31
from bzrlib.osutils import pathjoin
33
32
from bzrlib.progress import DummyProgress
34
33
from bzrlib.revision import NULL_REVISION
269
268
            else:
270
269
                action.write(self.to_file)
271
270
 
272
 
        delta = compare_trees(old_tree, new_tree, want_unchanged=True)
 
271
        delta = new_tree.changes_from(old_tree, want_unchanged=True)
273
272
        for path, file_id, kind in delta.removed:
274
273
            action = Action('removed', [kind, path]).write(self.to_file)
275
274
 
367
366
            # which does not start with '#'
368
367
            if line is None or line == '\n':
369
368
                break
 
369
            if not line.startswith('#'):
 
370
                continue
370
371
            found_something = True
371
372
            self._handle_next(line)
372
373
        if not found_something:
378
379
        """Read in a key-value pair
379
380
        """
380
381
        if not line.startswith('#'):
381
 
            raise MalformedHeader('Bzr header did not start with #')
 
382
            raise errors.MalformedHeader('Bzr header did not start with #')
382
383
        line = line[1:-1].decode('utf-8') # Remove the '#' and '\n'
383
384
        if line[:indent] == ' '*indent:
384
385
            line = line[indent:]
395
396
            key = line[:-1]
396
397
            value = self._read_many(indent=indent+2)
397
398
        else:
398
 
            raise MalformedHeader('While looking for key: value pairs,'
 
399
            raise errors.MalformedHeader('While looking for key: value pairs,'
399
400
                    ' did not find the colon %r' % (line))
400
401
 
401
402
        key = key.replace(' ', '_')
415
416
            if getattr(revision_info, key) is None:
416
417
                setattr(revision_info, key, value)
417
418
            else:
418
 
                raise MalformedHeader('Duplicated Key: %s' % key)
 
419
                raise errors.MalformedHeader('Duplicated Key: %s' % key)
419
420
        else:
420
421
            # What do we do with a key we don't recognize
421
 
            raise MalformedHeader('Unknown Key: "%s"' % key)
 
422
            raise errors.MalformedHeader('Unknown Key: "%s"' % key)
422
423
    
423
424
    def _read_many(self, indent):
424
425
        """If a line ends with no entry, that means that it should be
455
456
        for line in self._next():
456
457
            if first:
457
458
                if not line.startswith('==='):
458
 
                    raise MalformedPatches('The first line of all patches'
 
459
                    raise errors.MalformedPatches('The first line of all patches'
459
460
                        ' should be a bzr meta line "==="'
460
461
                        ': %r' % line)
461
462
                action = line[4:-1].decode('utf-8')
493
494
        """
494
495
        for line in self._next():
495
496
            self._handle_next(line)
 
497
            if self._next_line is None:
 
498
                break
496
499
            if not self._next_line.startswith('#'):
 
500
                # Consume the trailing \n and stop processing
497
501
                self._next().next()
498
502
                break
499
 
            if self._next_line is None:
500
 
                break