~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_3.py

  • Committer: Tarmac
  • Author(s): Vincent Ladeuil
  • Date: 2017-01-30 14:42:05 UTC
  • mfrom: (6620.1.1 trunk)
  • Revision ID: tarmac-20170130144205-r8fh2xpmiuxyozpv
Merge  2.7 into trunk including fix for bug #1657238 [r=vila]

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
"""
20
20
 
 
21
from __future__ import absolute_import
 
22
 
21
23
import errno
22
24
 
23
25
from bzrlib import (
34
36
    )
35
37
from bzrlib.lockable_files import LockableFiles
36
38
from bzrlib.lockdir import LockDir
 
39
from bzrlib.mutabletree import MutableTree
37
40
from bzrlib.transport.local import LocalTransport
38
41
from bzrlib.workingtree import (
39
42
    InventoryWorkingTree,
40
 
    WorkingTreeFormat,
 
43
    WorkingTreeFormatMetaDir,
41
44
    )
42
45
 
43
46
 
136
139
            self.branch.unlock()
137
140
 
138
141
 
139
 
class WorkingTreeFormat3(WorkingTreeFormat):
 
142
class WorkingTreeFormat3(WorkingTreeFormatMetaDir):
140
143
    """The second working tree format updated to record a format marker.
141
144
 
142
145
    This format:
143
146
        - exists within a metadir controlling .bzr
144
147
        - includes an explicit version marker for the workingtree control
145
 
          files, separate from the BzrDir format
 
148
          files, separate from the ControlDir format
146
149
        - modifies the hash cache format
147
150
        - is new in bzr 0.8
148
151
        - uses a LockDir to guard access for writes.
154
157
 
155
158
    supports_versioned_directories = True
156
159
 
157
 
    def get_format_string(self):
 
160
    @classmethod
 
161
    def get_format_string(cls):
158
162
        """See WorkingTreeFormat.get_format_string()."""
159
163
        return "Bazaar-NG Working Tree format 3"
160
164
 
192
196
        control_files = self._open_control_files(a_bzrdir)
193
197
        control_files.create_lock()
194
198
        control_files.lock_write()
195
 
        transport.put_bytes('format', self.get_format_string(),
 
199
        transport.put_bytes('format', self.as_string(),
196
200
            mode=a_bzrdir._get_file_mode())
197
201
        if from_branch is not None:
198
202
            branch = from_branch
217
221
        try:
218
222
            basis_tree = branch.repository.revision_tree(revision_id)
219
223
            # only set an explicit root id if there is one to set.
220
 
            if basis_tree.inventory.root is not None:
 
224
            if basis_tree.get_root_id() is not None:
221
225
                wt.set_root_id(basis_tree.get_root_id())
222
226
            if revision_id == _mod_revision.NULL_REVISION:
223
227
                wt.set_parent_trees([])
224
228
            else:
225
229
                wt.set_parent_trees([(revision_id, basis_tree)])
226
230
            transform.build_tree(basis_tree, wt)
 
231
            for hook in MutableTree.hooks['post_build_tree']:
 
232
                hook(wt)
227
233
        finally:
228
234
            # Unlock in this order so that the unlock-triggers-flush in
229
235
            # WorkingTree is given a chance to fire.
259
265
                                _format=self,
260
266
                                _bzrdir=a_bzrdir,
261
267
                                _control_files=control_files)
262
 
 
263
 
    def __str__(self):
264
 
        return self.get_format_string()