/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/testament.py

  • Committer: Jelmer Vernooij
  • Date: 2011-04-18 14:27:40 UTC
  • mto: This revision was merged to the branch mainline in revision 5804.
  • Revision ID: jelmer@samba.org-20110418142740-qqga9ggzz8i535q3
Make Testament take a tree rather than a inventory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
 
92
92
    long_header = 'bazaar-ng testament version 1\n'
93
93
    short_header = 'bazaar-ng testament short form 1\n'
 
94
    include_root = False
94
95
 
95
96
    @classmethod
96
97
    def from_revision(cls, repository, revision_id):
97
 
        """Produce a new testament from a historical revision"""
 
98
        """Produce a new testament from a historical revision."""
98
99
        rev = repository.get_revision(revision_id)
99
 
        inventory = repository.get_inventory(revision_id)
100
 
        return cls(rev, inventory)
101
 
 
102
 
    def __init__(self, rev, inventory):
103
 
        """Create a new testament for rev using inventory."""
 
100
        tree = repository.revision_tree(revision_id)
 
101
        return cls(rev, tree)
 
102
 
 
103
    @classmethod
 
104
    def from_revision_tree(cls, tree):
 
105
        """Produce a new testament from a revision tree."""
 
106
        rev = tree._repository.get_revision(tree.get_revision_id())
 
107
        return cls(rev, tree)
 
108
 
 
109
    def __init__(self, rev, tree):
 
110
        """Create a new testament for rev using tree."""
104
111
        self.revision_id = rev.revision_id
105
112
        self.committer = rev.committer
106
113
        self.timezone = rev.timezone or 0
107
114
        self.timestamp = rev.timestamp
108
115
        self.message = rev.message
109
116
        self.parent_ids = rev.parent_ids[:]
110
 
        self.inventory = inventory
 
117
        self.tree = tree
111
118
        self.revprops = copy(rev.properties)
112
119
        if contains_whitespace(self.revision_id):
113
120
            raise ValueError(self.revision_id)
143
150
        return [line.encode('utf-8') for line in r]
144
151
 
145
152
    def _get_entries(self):
146
 
        entries = self.inventory.iter_entries()
147
 
        entries.next()
148
 
        return entries
 
153
        return ((path, ie) for (path, versioned, kind, file_id, ie) in
 
154
                self.tree.list_files(include_root=self.include_root))
149
155
 
150
156
    def _escape_path(self, path):
151
157
        if contains_linebreaks(path):
209
215
 
210
216
    long_header = 'bazaar-ng testament version 2.1\n'
211
217
    short_header = 'bazaar-ng testament short form 2.1\n'
 
218
    include_root = False
212
219
    def _entry_to_line(self, path, ie):
213
220
        l = Testament._entry_to_line(self, path, ie)[:-1]
214
221
        l += ' ' + ie.revision
224
231
 
225
232
    long_header = 'bazaar testament version 3 strict\n'
226
233
    short_header = 'bazaar testament short form 3 strict\n'
227
 
    def _get_entries(self):
228
 
        return self.inventory.iter_entries()
 
234
    include_root = True
229
235
 
230
236
    def _escape_path(self, path):
231
237
        if contains_linebreaks(path):