~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/testament.py

  • Committer: Robert Collins
  • Date: 2005-10-17 11:56:54 UTC
  • mfrom: (1185.16.59)
  • Revision ID: robertc@robertcollins.net-20051017115654-662239e1587524a8
mergeĀ fromĀ martin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
# TODO: Perhaps these should just be different formats in which inventories/
70
70
# revisions can be serialized.
71
71
 
 
72
from copy import copy
72
73
from cStringIO import StringIO
73
74
import string
74
75
from sha import sha
98
99
        t.message = rev.message
99
100
        t.parent_ids = rev.parent_ids[:]
100
101
        t.inventory = branch.get_inventory(revision_id)
 
102
        t.revprops = copy(rev.properties)
101
103
        assert not contains_whitespace(t.revision_id)
102
104
        assert not contains_linebreaks(t.committer)
103
105
        return t
127
129
        a('inventory:\n')
128
130
        for path, ie in self.inventory.iter_entries():
129
131
            a(self._entry_to_line(path, ie))
 
132
        r.extend(self._revprops_to_lines())
130
133
        if __debug__:
131
134
            for l in r:
132
135
                assert isinstance(l, str), \
165
168
                'sha1: %s\n'
166
169
                % (self.revision_id, s.hexdigest()))
167
170
 
 
171
    def _revprops_to_lines(self):
 
172
        """Pack up revision properties."""
 
173
        if not self.revprops:
 
174
            return []
 
175
        r = ['properties:\n']
 
176
        for name, value in sorted(self.revprops.items()):
 
177
            assert isinstance(name, str)
 
178
            assert not contains_whitespace(name)
 
179
            r.append('  %s:\n' % name)
 
180
            for line in value.splitlines():
 
181
                if not isinstance(line, str):
 
182
                    line = line.encode('utf-8')
 
183
                r.append('    %s\n' % line)
 
184
        return r