~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to read_changeset.py

  • Committer: John Arbash Meinel
  • Date: 2005-07-10 15:14:15 UTC
  • mto: (0.5.85) (1185.82.1 bzr-w-changeset)
  • mto: This revision was merged to the branch mainline in revision 1738.
  • Revision ID: john@arbash-meinel.com-20050710151415-e1eb3a535097e4bc
Applying patch from Robey Pointer to clean up apply_changeset.

Show diffs side-by-side

added added

removed removed

Lines of Context:
325
325
            kind = tree.get_kind(file_id)
326
326
            ie = InventoryEntry(file_id, name, kind, parent_id, text_id=text_id)
327
327
            ie.text_size, ie.text_sha1 = tree.get_size_and_sha1(file_id)
328
 
            if ie.text_size is None:
 
328
            if (ie.text_size is None) and (kind != 'directory'):
329
329
                raise BzrError('Got a text_size of None for file_id %r' % file_id)
330
330
            inv.add(ie)
331
331
        return inv
383
383
        found = False
384
384
        for line in self._next():
385
385
            if found:
 
386
                # not all mailers will keep trailing whitespace
 
387
                if line == '#\n':
 
388
                    line = '# \n'
386
389
                if (line[:2] != '# ' or line[-1:] != '\n'
387
390
                        or line[2:-1] != header[0]):
388
391
                    raise MalformedHeader('Found a header, but it'
852
855
            # If the entry does not have a patch, then the
853
856
            # contents must be the same as in the base_tree
854
857
            ie = self.base_tree.inventory[file_id]
 
858
            if ie.text_size is None:
 
859
                return ie.text_size, ie.text_sha1
855
860
            return int(ie.text_size), ie.text_sha1
856
861
        content = self.get_file(file_id).read()
857
862
        return len(content), sha_string(content)
861
866
    def __iter__(self):
862
867
        for file_id in self._new_id_r.iterkeys():
863
868
            yield file_id
864
 
        for file_id in self.base_tree:
865
 
            if self.id2path(file_id) is None:
 
869
        for path, entry in self.base_tree.inventory.iter_entries():
 
870
            if self.id2path(entry.file_id) is None:
866
871
                continue
867
 
            yield file_id
 
872
            yield entry.file_id
868
873
 
869
874
 
870
875
def patched_file(file_patch, original):