/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 breezy/transform.py

  • Committer: The Breezy Bot
  • Author(s): Jelmer Vernooij
  • Date: 2017-08-27 13:48:59 UTC
  • mfrom: (6652.1.4 link-tree)
  • Revision ID: the_breezy_bot-20170827134859-sevcsvdkjvtdts1q
Import the 'link-tree' command from bzrtools. by jelmer review by gz

Show diffs side-by-side

added added

removed removed

Lines of Context:
3204
3204
        # after apply_deletions, don't reuse _FileMover
3205
3205
        past_renames = None
3206
3206
        pending_deletions = None
 
3207
 
 
3208
 
 
3209
def link_tree(target_tree, source_tree):
 
3210
    """Where possible, hard-link files in a tree to those in another tree.
 
3211
 
 
3212
    :param target_tree: Tree to change
 
3213
    :param source_tree: Tree to hard-link from
 
3214
    """
 
3215
    tt = TreeTransform(target_tree)
 
3216
    try:
 
3217
        for (file_id, paths, changed_content, versioned, parent, name, kind,
 
3218
             executable) in target_tree.iter_changes(source_tree,
 
3219
             include_unchanged=True):
 
3220
            if changed_content:
 
3221
                continue
 
3222
            if kind != ('file', 'file'):
 
3223
                continue
 
3224
            if executable[0] != executable[1]:
 
3225
                continue
 
3226
            trans_id = tt.trans_id_tree_file_id(file_id)
 
3227
            tt.delete_contents(trans_id)
 
3228
            tt.create_hardlink(source_tree.id2abspath(file_id), trans_id)
 
3229
        tt.apply()
 
3230
    finally:
 
3231
        tt.finalize()