~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

  • Committer: Martin Pool
  • Date: 2005-03-15 05:19:54 UTC
  • Revision ID: mbp@sourcefrog.net-20050315051954-e4bdd6dfd26f8ecf
witty comment

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
try:
24
24
    from cElementTree import Element, ElementTree, SubElement
25
25
except ImportError:
26
 
    from elementtree import Element, ElementTree, SubElement
 
26
    from elementtree.ElementTree import Element, ElementTree, SubElement
27
27
 
28
28
 
29
29
class Revision(XMLMixin):
50
50
 
51
51
        
52
52
    def to_element(self):
53
 
        root = Element('changeset',
 
53
        root = Element('revision',
54
54
                       committer = self.committer,
55
55
                       timestamp = '%.9f' % self.timestamp,
56
56
                       revision_id = self.revision_id,
66
66
 
67
67
        return root
68
68
 
69
 
    def from_element(cls, root):
70
 
        cs = cls(committer = root.get('committer'),
71
 
                 timestamp = float(root.get('timestamp')),
72
 
                 precursor = root.get('precursor'),
73
 
                 revision_id = root.get('revision_id'),
74
 
                 inventory_id = root.get('inventory_id'))
75
 
 
76
 
        v = root.get('timezone')
 
69
 
 
70
    def from_element(cls, elt):
 
71
        # <changeset> is deprecated...
 
72
        if elt.tag not in ('revision', 'changeset'):
 
73
            bailout("unexpected tag in revision file: %r" % elt)
 
74
 
 
75
        cs = cls(committer = elt.get('committer'),
 
76
                 timestamp = float(elt.get('timestamp')),
 
77
                 precursor = elt.get('precursor'),
 
78
                 revision_id = elt.get('revision_id'),
 
79
                 inventory_id = elt.get('inventory_id'))
 
80
 
 
81
        v = elt.get('timezone')
77
82
        cs.timezone = v and int(v)
78
83
 
79
 
        cs.message = root.findtext('message') # text of <message>
 
84
        cs.message = elt.findtext('message') # text of <message>
80
85
        return cs
81
86
 
82
87
    from_element = classmethod(from_element)