~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/testament.py

  • Committer: Aaron Bentley
  • Date: 2005-10-18 20:19:44 UTC
  • mfrom: (1463) (0.2.1)
  • mto: (1185.25.1)
  • mto: This revision was merged to the branch mainline in revision 1474.
  • Revision ID: abentley@panoramicfeedback.com-20051018201944-42864e79d8e9ad29
Merged more from Robert

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
    @classmethod
91
91
    def from_revision(cls, branch, revision_id):
92
92
        """Produce a new testament from a historical revision"""
93
 
        t = cls()
94
93
        rev = branch.get_revision(revision_id)
95
 
        t.revision_id = str(revision_id)
96
 
        t.committer = rev.committer
97
 
        t.timezone = rev.timezone or 0
98
 
        t.timestamp = rev.timestamp
99
 
        t.message = rev.message
100
 
        t.parent_ids = rev.parent_ids[:]
101
 
        t.inventory = branch.get_inventory(revision_id)
102
 
        t.revprops = copy(rev.properties)
103
 
        assert not contains_whitespace(t.revision_id)
104
 
        assert not contains_linebreaks(t.committer)
105
 
        return t
 
94
        inventory = branch.get_inventory(revision_id)
 
95
        return cls(rev, inventory)
 
96
 
 
97
    def __init__(self, rev, inventory):
 
98
        """Create a new testament for rev using inventory."""
 
99
        self.revision_id = str(rev.revision_id)
 
100
        self.committer = rev.committer
 
101
        self.timezone = rev.timezone or 0
 
102
        self.timestamp = rev.timestamp
 
103
        self.message = rev.message
 
104
        self.parent_ids = rev.parent_ids[:]
 
105
        self.inventory = inventory
 
106
        self.revprops = copy(rev.properties)
 
107
        assert not contains_whitespace(self.revision_id)
 
108
        assert not contains_linebreaks(self.committer)
106
109
 
107
110
    def as_text_lines(self):
108
111
        """Yield text form as a sequence of lines.
132
135
        r.extend(self._revprops_to_lines())
133
136
        if __debug__:
134
137
            for l in r:
135
 
                assert isinstance(l, str), \
 
138
                assert isinstance(l, basestring), \
136
139
                    '%r of type %s is not a plain string' % (l, type(l))
137
140
        return r
138
141