~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Martin Pool
  • Date: 2011-07-04 21:10:37 UTC
  • mto: (6034.1.1 filter-tree)
  • mto: This revision was merged to the branch mainline in revision 6035.
  • Revision ID: mbp@canonical.com-20110704211037-ro3417imj3oqnqxp
Support exporting tarballs from ContentFilterTree

Show diffs side-by-side

added added

removed removed

Lines of Context:
231
231
        new_roots = [k for k, v in self._new_parent.iteritems() if v is
232
232
                     ROOT_PARENT]
233
233
        if len(new_roots) < 1:
 
234
            if self.final_kind(self.root) is None:
 
235
                self.cancel_deletion(self.root)
 
236
            if self.final_file_id(self.root) is None:
 
237
                self.version_file(self.tree_file_id(self.root),
 
238
                                     self.root)
234
239
            return
235
240
        if len(new_roots) != 1:
236
241
            raise ValueError('A tree cannot have two roots!')
238
243
            self._new_root = new_roots[0]
239
244
            return
240
245
        old_new_root = new_roots[0]
 
246
        # TODO: What to do if a old_new_root is present, but self._new_root is
 
247
        #       not listed as being removed? This code explicitly unversions
 
248
        #       the old root and versions it with the new file_id. Though that
 
249
        #       seems like an incomplete delta
 
250
 
241
251
        # unversion the new root's directory.
242
 
        if self.final_kind(self._new_root) is None:
243
 
            file_id = self.final_file_id(old_new_root)
244
 
        else:
245
 
            file_id = self.final_file_id(self._new_root)
 
252
        file_id = self.final_file_id(old_new_root)
246
253
        if old_new_root in self._new_id:
247
254
            self.cancel_versioning(old_new_root)
248
255
        else:
1748
1755
                mover.apply_deletions()
1749
1756
        finally:
1750
1757
            child_pb.finished()
1751
 
        if self.final_file_id(self.root) is None:
1752
 
            inventory_delta = [e for e in inventory_delta if e[0] != '']
1753
1758
        self._tree.apply_inventory_delta(inventory_delta)
1754
1759
        self._apply_observed_sha1s()
1755
1760
        self._done = True
2258
2263
        else:
2259
2264
            return None
2260
2265
 
2261
 
    def get_file_verifier(self, file_id, path=None, stat_value=None):
2262
 
        trans_id = self._transform.trans_id_file_id(file_id)
2263
 
        kind = self._transform._new_contents.get(trans_id)
2264
 
        if kind is None:
2265
 
            return self._transform._tree.get_file_verifier(file_id)
2266
 
        if kind == 'file':
2267
 
            fileobj = self.get_file(file_id)
2268
 
            try:
2269
 
                return ("SHA1", sha_file(fileobj))
2270
 
            finally:
2271
 
                fileobj.close()
2272
 
 
2273
2266
    def get_file_sha1(self, file_id, path=None, stat_value=None):
2274
2267
        trans_id = self._transform.trans_id_file_id(file_id)
2275
2268
        kind = self._transform._new_contents.get(trans_id)