/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/builtins.py

Merge tree reference fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6723
6723
 
6724
6724
    takes_args = ['path?', 'location?']
6725
6725
    takes_options = [
 
6726
        'directory',
6726
6727
        Option('force-unversioned',
6727
6728
               help='Set reference even if path is not versioned.'),
6728
6729
        ]
6729
6730
 
6730
 
    def run(self, path=None, location=None, force_unversioned=False):
6731
 
        branchdir = '.'
6732
 
        if path is not None:
6733
 
            branchdir = path
 
6731
    def run(self, path=None, directory='.', location=None, force_unversioned=False):
6734
6732
        tree, branch, relpath = (
6735
 
            controldir.ControlDir.open_containing_tree_or_branch(branchdir))
6736
 
        if path is not None:
6737
 
            path = relpath
 
6733
            controldir.ControlDir.open_containing_tree_or_branch(directory))
6738
6734
        if tree is None:
6739
6735
            tree = branch.basis_tree()
6740
6736
        if path is None:
6741
 
            info = viewitems(branch._get_all_reference_info())
6742
 
            self._display_reference_info(tree, branch, info)
 
6737
            with tree.lock_read():
 
6738
                info = [
 
6739
                    (path, tree.get_reference_info(path, branch))
 
6740
                    for path in tree.iter_references()]
 
6741
                self._display_reference_info(tree, branch, info)
6743
6742
        else:
6744
6743
            if not tree.is_versioned(path) and not force_unversioned:
6745
6744
                raise errors.NotVersionedError(path)
6746
6745
            if location is None:
6747
 
                info = [(path, branch.get_reference_info(path))]
 
6746
                info = [(path, tree.get_reference_info(path, branch))]
6748
6747
                self._display_reference_info(tree, branch, info)
6749
6748
            else:
6750
 
                branch.set_reference_info(
6751
 
                    path, location, file_id=tree.path2id(path))
 
6749
                tree.set_reference_info(path, location)
6752
6750
 
6753
6751
    def _display_reference_info(self, tree, branch, info):
6754
6752
        ref_list = []
6755
 
        for path, (location, file_id) in info:
 
6753
        for path, location in info:
6756
6754
            ref_list.append((path, location))
6757
6755
        for path, location in sorted(ref_list):
6758
6756
            self.outf.write('%s %s\n' % (path, location))