~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/serializer/v08.py

  • Committer: Robert Collins
  • Date: 2007-04-30 03:48:51 UTC
  • mfrom: (2468 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2470.
  • Revision ID: robertc@robertcollins.net-20070430034851-aik2bzpubf44oyjc
Merge Johns fix for bug 110256.

Show diffs side-by-side

added added

removed removed

Lines of Context:
135
135
        f.write('0.8\n')
136
136
        f.write('#\n')
137
137
 
138
 
    def _write(self, key, value, indent=1):
139
 
        """Write out meta information, with proper indenting, etc"""
 
138
    def _write(self, key, value, indent=1, trailing_space_when_empty=False):
 
139
        """Write out meta information, with proper indenting, etc.
 
140
 
 
141
        :param trailing_space_when_empty: To work around a bug in earlier
 
142
            bundle readers, when writing an empty property, we use "prop: \n"
 
143
            rather than writing "prop:\n".
 
144
            If this parameter is True, and value is the empty string, we will
 
145
            write an extra space.
 
146
        """
140
147
        assert indent > 0, 'indentation must be greater than 0'
141
148
        f = self.to_file
142
149
        f.write('#' + (' ' * indent))
143
150
        f.write(key.encode('utf-8'))
144
151
        if not value:
145
 
            f.write(':\n')
 
152
            if trailing_space_when_empty and value == '':
 
153
                f.write(': \n')
 
154
            else:
 
155
                f.write(':\n')
146
156
        elif isinstance(value, str):
147
157
            f.write(': ')
148
158
            f.write(value)
225
235
            w('base id', base_rev)
226
236
        if rev.properties:
227
237
            self._write('properties', None, indent=1)
228
 
            for name, value in rev.properties.items():
229
 
                self._write(name, value, indent=3)
 
238
            for name, value in sorted(rev.properties.items()):
 
239
                self._write(name, value, indent=3,
 
240
                            trailing_space_when_empty=True)
230
241
        
231
242
        # Add an extra blank space at the end
232
243
        self.to_file.write('\n')