~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: INADA Naoki
  • Date: 2011-05-14 14:59:06 UTC
  • mto: This revision was merged to the branch mainline in revision 5874.
  • Revision ID: songofacandy@gmail.com-20110514145906-xj3xa06jihd4wapq
Notify when test_textwrap is skipped.

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
    xml5,
69
69
    xml7,
70
70
    )
71
 
from bzrlib.workingtree_4 import (
72
 
    WorkingTreeFormat4,
73
 
    WorkingTreeFormat5,
74
 
    WorkingTreeFormat6,
75
 
    )
76
71
""")
77
72
 
78
73
from bzrlib import symbol_versioning
1264
1259
        when their last revision is set.
1265
1260
        """
1266
1261
        if _mod_revision.is_null(new_revision):
1267
 
            self.branch.set_revision_history([])
 
1262
            self.branch.set_last_revision_info(0, new_revision)
1268
1263
            return False
1269
1264
        try:
1270
1265
            self.branch.generate_revision_history(new_revision)
1271
1266
        except errors.NoSuchRevision:
1272
1267
            # not present in the repo - dont try to set it deeper than the tip
1273
 
            self.branch.set_revision_history([new_revision])
 
1268
            self.branch._set_revision_history([new_revision])
1274
1269
        return True
1275
1270
 
1276
1271
    @needs_tree_write_lock
2183
2178
                    # dont use the repository revision_tree api because we want
2184
2179
                    # to supply the inventory.
2185
2180
                    if inv.revision_id == revision_id:
2186
 
                        return revisiontree.RevisionTree(self.branch.repository,
2187
 
                            inv, revision_id)
 
2181
                        return revisiontree.InventoryRevisionTree(
 
2182
                            self.branch.repository, inv, revision_id)
2188
2183
                except errors.BadInventoryFormat:
2189
2184
                    pass
2190
2185
        # raise if there was no inventory, or if we read the wrong inventory.
2973
2968
    def __init__(self, other_registry=None):
2974
2969
        super(WorkingTreeFormatRegistry, self).__init__(other_registry)
2975
2970
        self._default_format = None
 
2971
        self._default_format_key = None
2976
2972
 
2977
2973
    def get_default(self):
2978
2974
        """Return the current default format."""
 
2975
        if (self._default_format_key is not None and
 
2976
            self._default_format is None):
 
2977
            self._default_format = self.get(self._default_format_key)
2979
2978
        return self._default_format
2980
2979
 
2981
2980
    def set_default(self, format):
 
2981
        """Set the default format."""
2982
2982
        self._default_format = format
 
2983
        self._default_format_key = None
 
2984
 
 
2985
    def set_default_key(self, format_string):
 
2986
        """Set the default format by its format string."""
 
2987
        self._default_format_key = format_string
 
2988
        self._default_format = None
2983
2989
 
2984
2990
 
2985
2991
format_registry = WorkingTreeFormatRegistry()
3015
3021
    """If this format supports missing parent conflicts."""
3016
3022
 
3017
3023
    @classmethod
 
3024
    def find_format_string(klass, a_bzrdir):
 
3025
        """Return format name for the working tree object in a_bzrdir."""
 
3026
        try:
 
3027
            transport = a_bzrdir.get_workingtree_transport(None)
 
3028
            return transport.get_bytes("format")
 
3029
        except errors.NoSuchFile:
 
3030
            raise errors.NoWorkingTree(base=transport.base)
 
3031
 
 
3032
    @classmethod
3018
3033
    def find_format(klass, a_bzrdir):
3019
3034
        """Return the format for the working tree object in a_bzrdir."""
3020
3035
        try:
3021
 
            transport = a_bzrdir.get_workingtree_transport(None)
3022
 
            format_string = transport.get_bytes("format")
 
3036
            format_string = klass.find_format_string(a_bzrdir)
3023
3037
            return format_registry.get(format_string)
3024
 
        except errors.NoSuchFile:
3025
 
            raise errors.NoWorkingTree(base=transport.base)
3026
3038
        except KeyError:
3027
3039
            raise errors.UnknownFormatError(format=format_string,
3028
3040
                                            kind="working tree")
3252
3264
        return self.get_format_string()
3253
3265
 
3254
3266
 
3255
 
__default_format = WorkingTreeFormat6()
3256
3267
format_registry.register_lazy("Bazaar Working Tree Format 4 (bzr 0.15)\n",
3257
3268
    "bzrlib.workingtree_4", "WorkingTreeFormat4")
3258
3269
format_registry.register_lazy("Bazaar Working Tree Format 5 (bzr 1.11)\n",
3260
3271
format_registry.register_lazy("Bazaar Working Tree Format 6 (bzr 1.14)\n",
3261
3272
    "bzrlib.workingtree_4", "WorkingTreeFormat6")
3262
3273
format_registry.register(WorkingTreeFormat3())
3263
 
format_registry.set_default(__default_format)
 
3274
format_registry.set_default_key("Bazaar Working Tree Format 6 (bzr 1.14)\n")