~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

Factor out _type_equality_funcs to a new function

Show diffs side-by-side

added added

removed removed

Lines of Context:
259
259
        """
260
260
        if path is None:
261
261
            path = osutils.getcwd()
262
 
        control = controldir.ControlDir.open(path, _unsupported)
 
262
        control = bzrdir.BzrDir.open(path, _unsupported)
263
263
        return control.open_workingtree(_unsupported)
264
264
 
265
265
    @staticmethod
277
277
        """
278
278
        if path is None:
279
279
            path = osutils.getcwd()
280
 
        control, relpath = controldir.ControlDir.open_containing(path)
 
280
        control, relpath = bzrdir.BzrDir.open_containing(path)
281
281
        return control.open_workingtree(), relpath
282
282
 
283
283
    @staticmethod
366
366
            else:
367
367
                return True, tree
368
368
        t = transport.get_transport(location)
369
 
        iterator = controldir.ControlDir.find_bzrdirs(t, evaluate=evaluate,
 
369
        iterator = bzrdir.BzrDir.find_bzrdirs(t, evaluate=evaluate,
370
370
                                              list_current=list_current)
371
371
        return [tr for tr in iterator if tr is not None]
372
372
 
494
494
        raise NotImplementedError(self.get_root_id)
495
495
 
496
496
    @needs_read_lock
497
 
    def clone(self, to_controldir, revision_id=None):
 
497
    def clone(self, to_bzrdir, revision_id=None):
498
498
        """Duplicate this working tree into to_bzr, including all state.
499
499
 
500
500
        Specifically modified files are kept as modified, but
501
501
        ignored and unknown files are discarded.
502
502
 
503
 
        If you want to make a new line of development, see ControlDir.sprout()
 
503
        If you want to make a new line of development, see bzrdir.sprout()
504
504
 
505
505
        revision
506
506
            If not None, the cloned tree will have its last revision set to
508
508
            and this one merged in.
509
509
        """
510
510
        # assumes the target bzr dir format is compatible.
511
 
        result = to_controldir.create_workingtree()
 
511
        result = to_bzrdir.create_workingtree()
512
512
        self.copy_content_into(result, revision_id)
513
513
        return result
514
514
 
522
522
            # TODO now merge from tree.last_revision to revision (to preserve
523
523
            # user local changes)
524
524
            merge.transform_tree(tree, self)
525
 
            if revision_id == _mod_revision.NULL_REVISION:
526
 
                new_parents = []
527
 
            else:
528
 
                new_parents = [revision_id]
529
 
            tree.set_parent_ids(new_parents)
 
525
            tree.set_parent_ids([revision_id])
530
526
 
531
527
    def id2abspath(self, file_id):
532
528
        return self.abspath(self.id2path(file_id))
1008
1004
                                show_base=show_base)
1009
1005
                    basis_root_id = basis_tree.get_root_id()
1010
1006
                    new_root_id = new_basis_tree.get_root_id()
1011
 
                    if new_root_id is not None and basis_root_id != new_root_id:
 
1007
                    if basis_root_id != new_root_id:
1012
1008
                        self.set_root_id(new_root_id)
1013
1009
                finally:
1014
1010
                    basis_tree.unlock()
1015
1011
                # TODO - dedup parents list with things merged by pull ?
1016
1012
                # reuse the revisiontree we merged against to set the new
1017
1013
                # tree data.
1018
 
                parent_trees = []
1019
 
                if self.branch.last_revision() != _mod_revision.NULL_REVISION:
1020
 
                    parent_trees.append(
1021
 
                        (self.branch.last_revision(), new_basis_tree))
 
1014
                parent_trees = [(self.branch.last_revision(), new_basis_tree)]
1022
1015
                # we have to pull the merge trees out again, because
1023
1016
                # merge_inner has set the ids. - this corner is not yet
1024
1017
                # layered well enough to prevent double handling.
2141
2134
        """See Tree.get_file_mtime."""
2142
2135
        if not path:
2143
2136
            path = self.inventory.id2path(file_id)
2144
 
        try:
2145
 
            return os.lstat(self.abspath(path)).st_mtime
2146
 
        except OSError, e:
2147
 
            if e.errno == errno.ENOENT:
2148
 
                raise errors.FileTimestampUnavailable(path)
2149
 
            raise
 
2137
        return os.lstat(self.abspath(path)).st_mtime
2150
2138
 
2151
2139
    def _is_executable_from_path_and_stat_from_basis(self, path, stat_result):
2152
2140
        file_id = self.path2id(path)
2989
2977
    supports_versioned_directories = None
2990
2978
 
2991
2979
    @classmethod
2992
 
    def find_format_string(klass, controldir):
2993
 
        """Return format name for the working tree object in controldir."""
 
2980
    def find_format_string(klass, a_bzrdir):
 
2981
        """Return format name for the working tree object in a_bzrdir."""
2994
2982
        try:
2995
 
            transport = controldir.get_workingtree_transport(None)
 
2983
            transport = a_bzrdir.get_workingtree_transport(None)
2996
2984
            return transport.get_bytes("format")
2997
2985
        except errors.NoSuchFile:
2998
2986
            raise errors.NoWorkingTree(base=transport.base)
2999
2987
 
3000
2988
    @classmethod
3001
 
    def find_format(klass, controldir):
3002
 
        """Return the format for the working tree object in controldir."""
 
2989
    def find_format(klass, a_bzrdir):
 
2990
        """Return the format for the working tree object in a_bzrdir."""
3003
2991
        try:
3004
 
            format_string = klass.find_format_string(controldir)
 
2992
            format_string = klass.find_format_string(a_bzrdir)
3005
2993
            return format_registry.get(format_string)
3006
2994
        except KeyError:
3007
2995
            raise errors.UnknownFormatError(format=format_string,
3008
2996
                                            kind="working tree")
3009
2997
 
3010
 
    def initialize(self, controldir, revision_id=None, from_branch=None,
 
2998
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
3011
2999
                   accelerator_tree=None, hardlink=False):
3012
 
        """Initialize a new working tree in controldir.
 
3000
        """Initialize a new working tree in a_bzrdir.
3013
3001
 
3014
 
        :param controldir: ControlDir to initialize the working tree in.
 
3002
        :param a_bzrdir: BzrDir to initialize the working tree in.
3015
3003
        :param revision_id: allows creating a working tree at a different
3016
3004
            revision than the branch is at.
3017
3005
        :param from_branch: Branch to checkout
3098
3086
    def unregister_format(klass, format):
3099
3087
        format_registry.remove(format)
3100
3088
 
3101
 
    def get_controldir_for_branch(self):
3102
 
        """Get the control directory format for creating branches.
3103
 
 
3104
 
        This is to support testing of working tree formats that can not exist
3105
 
        in the same control directory as a branch.
3106
 
        """
3107
 
        return self._matchingbzrdir
3108
 
 
3109
3089
 
3110
3090
format_registry.register_lazy("Bazaar Working Tree Format 4 (bzr 0.15)\n",
3111
3091
    "bzrlib.workingtree_4", "WorkingTreeFormat4")