~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
                                     )
28
29
from bzrlib.bundle.bundle_data import (RevisionInfo, BundleInfo, BundleTree)
29
30
from bzrlib.delta import compare_trees
30
31
from bzrlib.diff import internal_diff
31
 
import bzrlib.errors as errors
32
32
from bzrlib.osutils import pathjoin
33
33
from bzrlib.progress import DummyProgress
34
34
from bzrlib.revision import NULL_REVISION
367
367
            # which does not start with '#'
368
368
            if line is None or line == '\n':
369
369
                break
 
370
            if not line.startswith('#'):
 
371
                continue
370
372
            found_something = True
371
373
            self._handle_next(line)
372
374
        if not found_something:
378
380
        """Read in a key-value pair
379
381
        """
380
382
        if not line.startswith('#'):
381
 
            raise MalformedHeader('Bzr header did not start with #')
 
383
            raise errors.MalformedHeader('Bzr header did not start with #')
382
384
        line = line[1:-1].decode('utf-8') # Remove the '#' and '\n'
383
385
        if line[:indent] == ' '*indent:
384
386
            line = line[indent:]
395
397
            key = line[:-1]
396
398
            value = self._read_many(indent=indent+2)
397
399
        else:
398
 
            raise MalformedHeader('While looking for key: value pairs,'
 
400
            raise errors.MalformedHeader('While looking for key: value pairs,'
399
401
                    ' did not find the colon %r' % (line))
400
402
 
401
403
        key = key.replace(' ', '_')
415
417
            if getattr(revision_info, key) is None:
416
418
                setattr(revision_info, key, value)
417
419
            else:
418
 
                raise MalformedHeader('Duplicated Key: %s' % key)
 
420
                raise errors.MalformedHeader('Duplicated Key: %s' % key)
419
421
        else:
420
422
            # What do we do with a key we don't recognize
421
 
            raise MalformedHeader('Unknown Key: "%s"' % key)
 
423
            raise errors.MalformedHeader('Unknown Key: "%s"' % key)
422
424
    
423
425
    def _read_many(self, indent):
424
426
        """If a line ends with no entry, that means that it should be
455
457
        for line in self._next():
456
458
            if first:
457
459
                if not line.startswith('==='):
458
 
                    raise MalformedPatches('The first line of all patches'
 
460
                    raise errors.MalformedPatches('The first line of all patches'
459
461
                        ' should be a bzr meta line "==="'
460
462
                        ': %r' % line)
461
463
                action = line[4:-1].decode('utf-8')
493
495
        """
494
496
        for line in self._next():
495
497
            self._handle_next(line)
 
498
            if self._next_line is None:
 
499
                break
496
500
            if not self._next_line.startswith('#'):
 
501
                # Consume the trailing \n and stop processing
497
502
                self._next().next()
498
503
                break
499
 
            if self._next_line is None:
500
 
                break