~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-09-29 23:51:44 UTC
  • mfrom: (3363.17.14 merge-into)
  • Revision ID: pqm@pqm.ubuntu.com-20080929235144-2jweo1007kh31723
Enable merging into PreviewTrees

Show diffs side-by-side

added added

removed removed

Lines of Context:
281
281
            raise ValueError('None is not a valid file id')
282
282
        if file_id in self._r_new_id and self._r_new_id[file_id] is not None:
283
283
            return self._r_new_id[file_id]
284
 
        elif file_id in self._tree.inventory:
285
 
            return self.trans_id_tree_file_id(file_id)
286
 
        elif file_id in self._non_present_ids:
287
 
            return self._non_present_ids[file_id]
288
284
        else:
289
 
            trans_id = self._assign_id()
290
 
            self._non_present_ids[file_id] = trans_id
291
 
            return trans_id
 
285
            try:
 
286
                self._tree.iter_entries_by_dir([file_id]).next()
 
287
            except StopIteration:
 
288
                if file_id in self._non_present_ids:
 
289
                    return self._non_present_ids[file_id]
 
290
                else:
 
291
                    trans_id = self._assign_id()
 
292
                    self._non_present_ids[file_id] = trans_id
 
293
                    return trans_id
 
294
            else:
 
295
                return self.trans_id_tree_file_id(file_id)
292
296
 
293
297
    def canonical_path(self, path):
294
298
        """Get the canonical tree-relative path"""
550
554
        # the file is old; the old id is still valid
551
555
        if self._new_root == trans_id:
552
556
            return self._tree.get_root_id()
553
 
        return self._tree.inventory.path2id(path)
 
557
        return self._tree.path2id(path)
554
558
 
555
559
    def final_file_id(self, trans_id):
556
560
        """Determine the file id after any changes are applied, or None.
1007
1011
        from_path = self._tree_id_paths.get(from_trans_id)
1008
1012
        if from_versioned:
1009
1013
            # get data from working tree if versioned
1010
 
            from_entry = self._tree.inventory[file_id]
 
1014
            from_entry = self._tree.iter_entries_by_dir([file_id]).next()[1]
1011
1015
            from_name = from_entry.name
1012
1016
            from_parent = from_entry.parent_id
1013
1017
        else:
1439
1443
        file_id = self.tree_file_id(parent_id)
1440
1444
        if file_id is None:
1441
1445
            return
1442
 
        children = getattr(self._tree.inventory[file_id], 'children', {})
 
1446
        entry = self._tree.iter_entries_by_dir([file_id]).next()[1]
 
1447
        children = getattr(entry, 'children', {})
1443
1448
        for child in children:
1444
1449
            childpath = joinpath(path, child)
1445
1450
            yield self.trans_id_tree_path(childpath)