def _pack_revision(self, rev): """Revision object -> xml tree""" root = Element('revision', committer = rev.committer, timestamp = '%.9f' % rev.timestamp, revision_id = rev.revision_id, inventory_id = rev.inventory_id, inventory_sha1 = rev.inventory_sha1, ) if rev.timezone: root.set('timezone', str(rev.timezone)) root.text = '\n' msg = SubElement(root, 'message') msg.text = rev.message msg.tail = '\n' if rev.parents: pelts = SubElement(root, 'parents') pelts.tail = pelts.text = '\n' for i, parent_id in enumerate(rev.parents): p = SubElement(pelts, 'revision_ref') p.tail = '\n' p.set('revision_id', parent_id) if i < len(rev.parent_sha1s): p.set('revision_sha1', rev.parent_sha1s[i]) return root
def _pack_revision(self, rev): """Revision object -> xml tree""" root = Element( 'revision', committer=rev.committer, timestamp='%.9f' % rev.timestamp, revision_id=rev.revision_id, inventory_id=rev.inventory_id, inventory_sha1=rev.inventory_sha1, ) if rev.timezone: root.set('timezone', str(rev.timezone)) root.text = '\n' msg = SubElement(root, 'message') msg.text = rev.message msg.tail = '\n' if rev.parents: pelts = SubElement(root, 'parents') pelts.tail = pelts.text = '\n' for i, parent_id in enumerate(rev.parents): p = SubElement(pelts, 'revision_ref') p.tail = '\n' p.set('revision_id', parent_id) if i < len(rev.parent_sha1s): p.set('revision_sha1', rev.parent_sha1s[i]) return root
def _pack_revision_properties(self, rev, under_element): top_elt = SubElement(under_element, 'properties') for prop_name, prop_value in sorted(rev.properties.items()): prop_elt = SubElement(top_elt, 'property') prop_elt.set('name', prop_name) prop_elt.text = prop_value prop_elt.tail = '\n' top_elt.tail = '\n'
def _pack_revision(self, rev): """Revision object -> xml tree""" # For the XML format, we need to write them as Unicode rather than as # utf-8 strings. So that cElementTree can handle properly escaping # them. decode_utf8 = cache_utf8.decode revision_id = rev.revision_id if isinstance(revision_id, str): revision_id = decode_utf8(revision_id) format_num = self.format_num if self.revision_format_num is not None: format_num = self.revision_format_num root = Element( 'revision', committer=rev.committer, timestamp='%.3f' % rev.timestamp, revision_id=revision_id, inventory_sha1=rev.inventory_sha1, format=format_num, ) if rev.timezone is not None: root.set('timezone', str(rev.timezone)) root.text = '\n' msg = SubElement(root, 'message') msg.text = rev.message msg.tail = '\n' if rev.parent_ids: pelts = SubElement(root, 'parents') pelts.tail = pelts.text = '\n' for parent_id in rev.parent_ids: _mod_revision.check_not_reserved_id(parent_id) p = SubElement(pelts, 'revision_ref') p.tail = '\n' if isinstance(parent_id, str): parent_id = decode_utf8(parent_id) p.set('revision_id', parent_id) if rev.properties: self._pack_revision_properties(rev, root) return root
def _pack_revision(self, rev): """Revision object -> xml tree""" # For the XML format, we need to write them as Unicode rather than as # utf-8 strings. So that cElementTree can handle properly escaping # them. decode_utf8 = cache_utf8.decode revision_id = rev.revision_id if isinstance(revision_id, str): revision_id = decode_utf8(revision_id) format_num = self.format_num if self.revision_format_num is not None: format_num = self.revision_format_num root = Element('revision', committer = rev.committer, timestamp = '%.3f' % rev.timestamp, revision_id = revision_id, inventory_sha1 = rev.inventory_sha1, format=format_num, ) if rev.timezone is not None: root.set('timezone', str(rev.timezone)) root.text = '\n' msg = SubElement(root, 'message') msg.text = rev.message msg.tail = '\n' if rev.parent_ids: pelts = SubElement(root, 'parents') pelts.tail = pelts.text = '\n' for parent_id in rev.parent_ids: _mod_revision.check_not_reserved_id(parent_id) p = SubElement(pelts, 'revision_ref') p.tail = '\n' if isinstance(parent_id, str): parent_id = decode_utf8(parent_id) p.set('revision_id', parent_id) if rev.properties: self._pack_revision_properties(rev, root) return root