~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-04-19 01:07:44 UTC
  • mfrom: (5757.7.11 knitpackrepo-6)
  • Revision ID: pqm@pqm.ubuntu.com-20110419010744-ns5qnlw97wrrva7s
(jelmer) Split KnitPackRepository-specific bits out of Packer class into
 KnitPacker. (Jelmer Vernooij)

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
    )
71
76
""")
72
77
 
73
78
from bzrlib import symbol_versioning
1259
1264
        when their last revision is set.
1260
1265
        """
1261
1266
        if _mod_revision.is_null(new_revision):
1262
 
            self.branch.set_last_revision_info(0, new_revision)
 
1267
            self.branch.set_revision_history([])
1263
1268
            return False
1264
1269
        try:
1265
1270
            self.branch.generate_revision_history(new_revision)
1266
1271
        except errors.NoSuchRevision:
1267
1272
            # not present in the repo - dont try to set it deeper than the tip
1268
 
            self.branch._set_revision_history([new_revision])
 
1273
            self.branch.set_revision_history([new_revision])
1269
1274
        return True
1270
1275
 
1271
1276
    @needs_tree_write_lock
2968
2973
    def __init__(self, other_registry=None):
2969
2974
        super(WorkingTreeFormatRegistry, self).__init__(other_registry)
2970
2975
        self._default_format = None
2971
 
        self._default_format_key = None
2972
2976
 
2973
2977
    def get_default(self):
2974
2978
        """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)
2978
2979
        return self._default_format
2979
2980
 
2980
2981
    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
2989
2983
 
2990
2984
 
2991
2985
format_registry = WorkingTreeFormatRegistry()
3021
3015
    """If this format supports missing parent conflicts."""
3022
3016
 
3023
3017
    @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
3033
3018
    def find_format(klass, a_bzrdir):
3034
3019
        """Return the format for the working tree object in a_bzrdir."""
3035
3020
        try:
3036
 
            format_string = klass.find_format_string(a_bzrdir)
 
3021
            transport = a_bzrdir.get_workingtree_transport(None)
 
3022
            format_string = transport.get_bytes("format")
3037
3023
            return format_registry.get(format_string)
 
3024
        except errors.NoSuchFile:
 
3025
            raise errors.NoWorkingTree(base=transport.base)
3038
3026
        except KeyError:
3039
3027
            raise errors.UnknownFormatError(format=format_string,
3040
3028
                                            kind="working tree")
3264
3252
        return self.get_format_string()
3265
3253
 
3266
3254
 
 
3255
__default_format = WorkingTreeFormat6()
3267
3256
format_registry.register_lazy("Bazaar Working Tree Format 4 (bzr 0.15)\n",
3268
3257
    "bzrlib.workingtree_4", "WorkingTreeFormat4")
3269
3258
format_registry.register_lazy("Bazaar Working Tree Format 5 (bzr 1.11)\n",
3271
3260
format_registry.register_lazy("Bazaar Working Tree Format 6 (bzr 1.14)\n",
3272
3261
    "bzrlib.workingtree_4", "WorkingTreeFormat6")
3273
3262
format_registry.register(WorkingTreeFormat3())
3274
 
format_registry.set_default_key("Bazaar Working Tree Format 6 (bzr 1.14)\n")
 
3263
format_registry.set_default(__default_format)