~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/testament.py

first cut at merge from integration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
114
114
        hashed in that encoding.
115
115
        """
116
116
        r = []
117
 
        a = r.append
 
117
        def a(s):
 
118
            r.append(s)
118
119
        a('bazaar-ng testament version 1\n')
119
120
        a('revision-id: %s\n' % self.revision_id)
120
121
        a('committer: %s\n' % self.committer)
136
137
            for l in r:
137
138
                assert isinstance(l, basestring), \
138
139
                    '%r of type %s is not a plain string' % (l, type(l))
139
 
        return [line.encode('utf-8') for line in r]
 
140
        return r
140
141
 
141
142
    def _escape_path(self, path):
142
143
        assert not contains_linebreaks(path)
156
157
            assert ie.symlink_target
157
158
            l += ' ' + self._escape_path(ie.symlink_target)
158
159
        l += '\n'
159
 
        return l.decode('utf-8')
 
160
        return l
160
161
 
161
162
    def as_text(self):
162
163
        return ''.join(self.as_text_lines())
184
185
                    line = line.encode('utf-8')
185
186
                r.append('    %s\n' % line)
186
187
        return r
187
 
 
188
 
    def as_sha1(self):
189
 
        return sha(self.as_short_text()).hexdigest()
190
 
 
191
 
 
192
 
class StrictTestament(Testament):
193
 
    """This testament format is for use as a checksum in changesets"""
194
 
 
195
 
    def _entry_to_line(self, path, ie):
196
 
        l = ie.revision.decode('utf-8') + ' '
197
 
        l += {True: 'yes', False: 'no'}[ie.executable] + ' '
198
 
        l += Testament._entry_to_line(self, path, ie)
199
 
        return l
200
 
 
201
 
    def as_text_lines(self):
202
 
        lines = ['bazaar-ng testament version 2']
203
 
        lines.extend(Testament.as_text_lines(self)[1:])
204
 
        return lines