~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/changeset/serializer/v07.py

  • Committer: Aaron Bentley
  • Date: 2006-05-20 16:36:30 UTC
  • mto: This revision was merged to the branch mainline in revision 1738.
  • Revision ID: aaron.bentley@utoronto.ca-20060520163630-3125b8397c15da92
Start abstracting action line writing

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
bool_text = {True: 'yes', False: 'no'}
38
38
 
 
39
 
 
40
class Action(object):
 
41
    """Represent an action"""
 
42
 
 
43
    def __init__(self, name, parameters=None, properties=None):
 
44
        self.name = name
 
45
        if parameters is None:
 
46
            self.parameters = []
 
47
        else:
 
48
            self.parameters = parameters
 
49
        if properties is None:
 
50
            self.properties = []
 
51
        else:
 
52
            self.properties = properties
 
53
 
 
54
    def write(self, to_file):
 
55
        """Write action as to a file"""
 
56
        p_texts = ['%s:%s' % v for v in self.properties]
 
57
        text = ['=== ']
 
58
        text.append(' '.join([self.name]+self.parameters))
 
59
        text.append(' // '.join(p_texts))
 
60
        text.append('\n')
 
61
        to_file.write(''.join(text).encode('utf-8'))
 
62
 
 
63
 
39
64
class ChangesetSerializerV07(ChangesetSerializer):
40
65
    def read(self, f):
41
66
        """Read the rest of the changesets from the supplied file.
219
244
            self.to_file.write(text.encode('utf-8'))
220
245
 
221
246
        for path, file_id, kind in delta.removed:
222
 
            self._write_action('removed', [kind, path])
 
247
            Action('removed', [kind, path]).write(self.to_file)
223
248
 
224
249
        for path, file_id, kind in delta.added:
225
250
            w('=== added %s %s // file-id:%s' % (kind, path, file_id))