~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml5.py

  • Committer: Aaron Bentley
  • Date: 2005-10-04 04:32:32 UTC
  • mfrom: (1185.12.6)
  • mto: (1185.12.13)
  • mto: This revision was merged to the branch mainline in revision 1419.
  • Revision ID: aaron.bentley@utoronto.ca-20051004043231-40302a149769263b
merged my own changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
 
46
46
    def _pack_entry(self, ie):
47
47
        """Convert InventoryEntry to XML element"""
48
 
        assert ie.kind == 'directory' or ie.kind == 'file'
 
48
        assert ie.kind in ('directory', 'file', 'symlink')
49
49
        e = Element(ie.kind)
50
50
        e.set('name', ie.name)
51
51
        e.set('file_id', ie.file_id)
53
53
        if ie.text_size != None:
54
54
            e.set('text_size', '%d' % ie.text_size)
55
55
 
56
 
        for f in ['text_version', 'text_sha1', 'name_version']:
 
56
        for f in ['text_sha1', 'revision', 'symlink_target']:
57
57
            v = getattr(ie, f)
58
58
            if v != None:
59
59
                e.set(f, v)
60
60
 
 
61
        if ie.executable:
 
62
            e.set('executable', 'yes')
 
63
 
61
64
        # to be conservative, we don't externalize the root pointers
62
65
        # for now, leaving them as null in the xml form.  in a future
63
66
        # version it will be implied by nested elements.
114
117
 
115
118
    def _unpack_entry(self, elt):
116
119
        kind = elt.tag
117
 
        assert kind == 'directory' or kind == 'file', \
118
 
            'unsupported entry kind %s' % kind
 
120
        if not kind in ('directory', 'file', 'symlink'):
 
121
            raise AssertionError('unsupported entry kind %s' % kind)
119
122
 
120
123
        parent_id = elt.get('parent_id')
121
124
        if parent_id == None:
125
128
                            elt.get('name'),
126
129
                            kind,
127
130
                            parent_id)
128
 
        ie.text_version = elt.get('text_version')
129
 
        ie.name_version = elt.get('name_version')
 
131
        ie.revision = elt.get('revision')
130
132
        ie.text_sha1 = elt.get('text_sha1')
 
133
        ie.symlink_target = elt.get('symlink_target')
 
134
        if elt.get('executable') == 'yes':
 
135
            ie.executable = True
131
136
        v = elt.get('text_size')
132
137
        ie.text_size = v and int(v)
133
138