~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Aaron Bentley
  • Date: 2008-03-01 04:27:02 UTC
  • Revision ID: aaron@aaronbentley.com-20080301042702-h3foyp8n9k68y3pv
Add link-tree command

Show diffs side-by-side

added added

removed removed

Lines of Context:
641
641
                      working_tree=not no_tree)
642
642
 
643
643
 
 
644
class cmd_link_tree(BzrToolsCommand):
 
645
    """Hardlink matching files to another tree.
 
646
 
 
647
    Only files with identical content and execute bit will be linked.
 
648
    """
 
649
    takes_args = ['location']
 
650
 
 
651
    def run(self, location):
 
652
        from bzrlib import workingtree
 
653
        from bzrlib.plugins.bzrtools.link_tree import link_tree
 
654
        target_tree = workingtree.WorkingTree.open_containing(".")[0]
 
655
        source_tree = workingtree.WorkingTree.open(location)
 
656
        target_tree.lock_write()
 
657
        try:
 
658
            source_tree.lock_read()
 
659
            try:
 
660
                link_tree(target_tree, source_tree)
 
661
            finally:
 
662
                source_tree.unlock()
 
663
        finally:
 
664
            target_tree.unlock()
 
665
 
 
666
 
644
667
commands = [
645
668
            cmd_baz_import,
646
669
            cmd_baz_import_branch,
653
676
            cmd_fetch_ghosts,
654
677
            cmd_graph_ancestry,
655
678
            cmd_import,
 
679
            cmd_link_tree,
656
680
            cmd_multi_pull,
657
681
            cmd_patch,
658
682
            cmd_rspush,