~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/testament.py

  • Committer: Robert Collins
  • Date: 2005-10-17 11:56:54 UTC
  • mfrom: (1185.16.59)
  • Revision ID: robertc@robertcollins.net-20051017115654-662239e1587524a8
mergeĀ fromĀ martin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
    Testaments can be 
83
83
 
84
84
      - produced from a revision
85
 
      - written to a stream
 
85
      - writen to a stream
86
86
      - loaded from a stream
87
87
      - compared to a revision
88
88
    """
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()
93
94
        rev = branch.get_revision(revision_id)
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)
 
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
109
106
 
110
107
    def as_text_lines(self):
111
108
        """Yield text form as a sequence of lines.
135
132
        r.extend(self._revprops_to_lines())
136
133
        if __debug__:
137
134
            for l in r:
138
 
                assert isinstance(l, basestring), \
 
135
                assert isinstance(l, str), \
139
136
                    '%r of type %s is not a plain string' % (l, type(l))
140
137
        return r
141
138