211
"""Construct a WorkingTree for basedir.
211
"""Construct a WorkingTree instance. This is not a public API.
213
If the branch is not supplied, it is opened automatically.
214
If the branch is supplied, it must be the branch for this basedir.
215
(branch.base is not cross checked, because for remote branches that
216
would be meaningless).
213
:param branch: A branch to override probing for the branch.
218
215
self._format = _format
219
216
self.bzrdir = _bzrdir
220
217
if not _internal:
221
# not created via open etc.
222
warnings.warn("WorkingTree() is deprecated as of bzr version 0.8. "
223
"Please use bzrdir.open_workingtree or WorkingTree.open().",
226
wt = WorkingTree.open(basedir)
227
self._branch = wt.branch
228
self.basedir = wt.basedir
229
self._control_files = wt._control_files
230
self._hashcache = wt._hashcache
231
self._set_inventory(wt._inventory, dirty=False)
232
self._format = wt._format
233
self.bzrdir = wt.bzrdir
218
raise errors.BzrError("Please use bzrdir.open_workingtree or "
219
"WorkingTree.open() to obtain a WorkingTree.")
234
220
assert isinstance(basedir, basestring), \
235
221
"base directory %r is not a string" % basedir
236
222
basedir = safe_unicode(basedir)
237
223
mutter("opening working tree %r", basedir)
238
224
if deprecated_passed(branch):
240
warnings.warn("WorkingTree(..., branch=XXX) is deprecated"
241
" as of bzr 0.8. Please use bzrdir.open_workingtree() or"
242
" WorkingTree.open().",
246
225
self._branch = branch
248
227
self._branch = self.bzrdir.open_branch()