563
564
# set our support for tree references from the repository in
565
566
self._repo_supports_tree_reference = getattr(
566
self.branch.repository._format, "support_tree_reference",
567
self.branch.repository._format, "supports_tree_reference",
569
570
self._control_files.unlock()
583
584
# set our support for tree references from the repository in
585
586
self._repo_supports_tree_reference = getattr(
586
self.branch.repository._format, "support_tree_reference",
587
self.branch.repository._format, "supports_tree_reference",
589
590
self._control_files.unlock()
1202
1203
for file_id in file_ids:
1203
1204
self._inventory.remove_recursive_id(file_id)
1207
def _validate(self):
1208
self._dirstate._validate()
1205
1210
@needs_tree_write_lock
1206
1211
def _write_inventory(self, inv):
1207
1212
"""Write inventory as the current inventory."""
1225
1230
- uses a LockDir to guard access to it.
1233
upgrade_recommended = False
1228
1235
def get_format_string(self):
1229
1236
"""See WorkingTreeFormat.get_format_string()."""
1230
1237
return "Bazaar Working Tree Format 4 (bzr 0.15)\n"
1239
1246
:param revision_id: allows creating a working tree at a different
1240
1247
revision than the branch is at.
1242
These trees get an initial random root id.
1249
These trees get an initial random root id, if their repository supports
1250
rich root data, TREE_ROOT otherwise.
1244
1252
revision_id = osutils.safe_revision_id(revision_id)
1245
1253
if not isinstance(a_bzrdir.transport, LocalTransport):
1263
1272
_control_files=control_files)
1265
1274
wt.lock_tree_write()
1275
wt.current_dirstate()._validate()
1268
1277
if revision_id in (None, NULL_REVISION):
1269
wt._set_root_id(generate_ids.gen_root_id())
1278
if branch.repository.supports_rich_root():
1279
wt._set_root_id(generate_ids.gen_root_id())
1281
wt._set_root_id(ROOT_ID)
1271
1283
wt.current_dirstate()._validate()
1272
1284
wt.set_last_revision(revision_id)
2075
2087
# python 2.5 has e.errno == EINVAL,
2076
2088
# and e.winerror == ERROR_DIRECTORY
2077
2089
e_winerror = getattr(e, 'winerror', None)
2090
win_errors = (ERROR_DIRECTORY, ERROR_PATH_NOT_FOUND)
2078
2091
# there may be directories in the inventory even though
2079
2092
# this path is not a file on disk: so mark it as end of
2081
2094
if e.errno in (errno.ENOENT, errno.ENOTDIR, errno.EINVAL):
2082
2095
current_dir_info = None
2083
2096
elif (sys.platform == 'win32'
2084
and ERROR_DIRECTORY in (e.errno, e_winerror)):
2097
and (e.errno in win_errors
2098
or e_winerror in win_errors)):
2085
2099
current_dir_info = None
2107
2121
# this has two possibilities:
2108
2122
# A) it is versioned but empty, so there is no block for it
2109
2123
# B) it is not versioned.
2110
# in either case it was processed by the containing directories walk:
2111
# if it is root/foo, when we walked root we emitted it,
2112
# or if we ere given root/foo to walk specifically, we
2113
# emitted it when checking the walk-root entries
2114
# advance the iterator and loop - we dont need to emit it.
2125
# if (A) then we need to recurse into it to check for
2126
# new unknown files or directories.
2127
# if (B) then we should ignore it, because we don't
2128
# recurse into unknown directories.
2129
if want_unversioned:
2131
while path_index < len(current_dir_info[1]):
2132
current_path_info = current_dir_info[1][path_index]
2133
if current_path_info[2] == 'directory':
2134
if self.target._directory_is_tree_reference(
2135
current_path_info[0].decode('utf8')):
2136
current_path_info = current_path_info[:2] + \
2137
('tree-reference',) + current_path_info[3:]
2138
new_executable = bool(
2139
stat.S_ISREG(current_path_info[3].st_mode)
2140
and stat.S_IEXEC & current_path_info[3].st_mode)
2142
(None, utf8_decode_or_none(current_path_info[0])),
2146
(None, utf8_decode_or_none(current_path_info[1])),
2147
(None, current_path_info[2]),
2148
(None, new_executable))
2149
# dont descend into this unversioned path if it is
2151
if current_path_info[2] in ('directory',
2153
del current_dir_info[1][path_index]
2157
# This dir info has been handled, go to the next
2116
2159
current_dir_info = dir_iterator.next()
2117
2160
except StopIteration:
2280
2323
new_executable = bool(
2281
2324
stat.S_ISREG(current_path_info[3].st_mode)
2282
2325
and stat.S_IEXEC & current_path_info[3].st_mode)
2283
if want_unversioned:
2285
(None, utf8_decode_or_none(current_path_info[0])),
2289
(None, utf8_decode_or_none(current_path_info[1])),
2290
(None, current_path_info[2]),
2291
(None, new_executable))
2327
(None, utf8_decode_or_none(current_path_info[0])),
2331
(None, utf8_decode_or_none(current_path_info[1])),
2332
(None, current_path_info[2]),
2333
(None, new_executable))
2292
2334
# dont descend into this unversioned path if it is
2294
2336
if current_path_info[2] in ('directory'):