/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/bundle/serializer/v08.py

Merge from 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
276
275
            else:
277
276
                action.write(self.to_file)
278
277
 
279
 
        delta = compare_trees(old_tree, new_tree, want_unchanged=True,
280
 
                              include_root=True)
 
278
        delta = new_tree.changes_from(old_tree, want_unchanged=True)
281
279
        for path, file_id, kind in delta.removed:
282
280
            action = Action('removed', [kind, path]).write(self.to_file)
283
281
 
378
376
            # which does not start with '#'
379
377
            if line is None or line == '\n':
380
378
                break
 
379
            if not line.startswith('#'):
 
380
                continue
381
381
            found_something = True
382
382
            self._handle_next(line)
383
383
        if not found_something:
389
389
        """Read in a key-value pair
390
390
        """
391
391
        if not line.startswith('#'):
392
 
            raise MalformedHeader('Bzr header did not start with #')
 
392
            raise errors.MalformedHeader('Bzr header did not start with #')
393
393
        line = line[1:-1].decode('utf-8') # Remove the '#' and '\n'
394
394
        if line[:indent] == ' '*indent:
395
395
            line = line[indent:]
406
406
            key = line[:-1]
407
407
            value = self._read_many(indent=indent+2)
408
408
        else:
409
 
            raise MalformedHeader('While looking for key: value pairs,'
 
409
            raise errors.MalformedHeader('While looking for key: value pairs,'
410
410
                    ' did not find the colon %r' % (line))
411
411
 
412
412
        key = key.replace(' ', '_')
426
426
            if getattr(revision_info, key) is None:
427
427
                setattr(revision_info, key, value)
428
428
            else:
429
 
                raise MalformedHeader('Duplicated Key: %s' % key)
 
429
                raise errors.MalformedHeader('Duplicated Key: %s' % key)
430
430
        else:
431
431
            # What do we do with a key we don't recognize
432
 
            raise MalformedHeader('Unknown Key: "%s"' % key)
 
432
            raise errors.MalformedHeader('Unknown Key: "%s"' % key)
433
433
    
434
434
    def _read_many(self, indent):
435
435
        """If a line ends with no entry, that means that it should be
466
466
        for line in self._next():
467
467
            if first:
468
468
                if not line.startswith('==='):
469
 
                    raise MalformedPatches('The first line of all patches'
 
469
                    raise errors.MalformedPatches('The first line of all patches'
470
470
                        ' should be a bzr meta line "==="'
471
471
                        ': %r' % line)
472
472
                action = line[4:-1].decode('utf-8')
504
504
        """
505
505
        for line in self._next():
506
506
            self._handle_next(line)
 
507
            if self._next_line is None:
 
508
                break
507
509
            if not self._next_line.startswith('#'):
 
510
                # Consume the trailing \n and stop processing
508
511
                self._next().next()
509
512
                break
510
 
            if self._next_line is None:
511
 
                break