~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Vincent Ladeuil
  • Date: 2012-02-14 17:22:37 UTC
  • mfrom: (6466 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6468.
  • Revision ID: v.ladeuil+lp@free.fr-20120214172237-7dv7er3n4uy8d5m4
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
575
575
            # ensure that all children are registered with the transaction
576
576
            list(self.iter_tree_children(parent_id))
577
577
 
 
578
    @deprecated_method(deprecated_in((2, 3, 0)))
 
579
    def has_named_child(self, by_parent, parent_id, name):
 
580
        return self._has_named_child(
 
581
            name, parent_id, known_children=by_parent.get(parent_id, []))
 
582
 
578
583
    def _has_named_child(self, name, parent_id, known_children):
579
584
        """Does a parent already have a name child.
580
585
 
2112
2117
        return cur_parent
2113
2118
 
2114
2119
    def path2id(self, path):
2115
 
        if isinstance(path, list):
2116
 
            if path == []:
2117
 
                path = [""]
2118
 
            path = osutils.pathjoin(*path)
2119
2120
        return self._transform.final_file_id(self._path2trans_id(path))
2120
2121
 
2121
2122
    def id2path(self, file_id):
2182
2183
                ordered_ids.append((trans_id, parent_file_id))
2183
2184
        return ordered_ids
2184
2185
 
2185
 
    def iter_child_entries(self, file_id, path=None):
2186
 
        self.id2path(file_id)
2187
 
        trans_id = self._transform.trans_id_file_id(file_id)
2188
 
        todo = [(child_trans_id, trans_id) for child_trans_id in
2189
 
                self._all_children(trans_id)]
2190
 
        for entry, trans_id in self._make_inv_entries(todo):
2191
 
            yield entry
2192
 
 
2193
2186
    def iter_entries_by_dir(self, specific_file_ids=None, yield_parents=False):
2194
2187
        # This may not be a maximally efficient implementation, but it is
2195
2188
        # reasonably straightforward.  An implementation that grafts the
2832
2825
        tt.set_executability(entry.executable, trans_id)
2833
2826
 
2834
2827
 
 
2828
@deprecated_function(deprecated_in((2, 3, 0)))
 
2829
def get_backup_name(entry, by_parent, parent_trans_id, tt):
 
2830
    return _get_backup_name(entry.name, by_parent, parent_trans_id, tt)
 
2831
 
 
2832
 
 
2833
@deprecated_function(deprecated_in((2, 3, 0)))
 
2834
def _get_backup_name(name, by_parent, parent_trans_id, tt):
 
2835
    """Produce a backup-style name that appears to be available"""
 
2836
    def name_gen():
 
2837
        counter = 1
 
2838
        while True:
 
2839
            yield "%s.~%d~" % (name, counter)
 
2840
            counter += 1
 
2841
    for new_name in name_gen():
 
2842
        if not tt.has_named_child(by_parent, parent_trans_id, new_name):
 
2843
            return new_name
 
2844
 
 
2845
 
2835
2846
def revert(working_tree, target_tree, filenames, backups=False,
2836
2847
           pb=None, change_reporter=None):
2837
2848
    """Revert a working tree's contents to those of a target tree."""