210
209
self.case_sensitive = False
211
def get_transform(self, pb=None):
212
from ..transform import TreeTransform
213
return TreeTransform(self, pb=pb)
212
215
def merge_modified(self):
351
354
# Bail out if we are going to delete files we shouldn't
352
355
if not keep_files and not force:
353
for (file_id, path, content_change, versioned, parent_id, name,
354
kind, executable) in self.iter_changes(
355
self.basis_tree(), include_unchanged=True,
356
require_versioned=False, want_unversioned=True,
357
specific_files=files):
358
if versioned[0] is False:
356
for change in self.iter_changes(
357
self.basis_tree(), include_unchanged=True,
358
require_versioned=False, want_unversioned=True,
359
specific_files=files):
360
if change.versioned[0] is False:
359
361
# The record is unknown or newly added
360
files_to_backup.append(path[1])
362
files_to_backup.append(change.path[1])
361
363
files_to_backup.extend(
362
osutils.parent_directories(path[1]))
363
elif (content_change and (kind[1] is not None)
364
and osutils.is_inside_any(files, path[1])):
364
osutils.parent_directories(change.path[1]))
365
elif (change.changed_content and (change.kind[1] is not None)
366
and osutils.is_inside_any(files, change.path[1])):
365
367
# Versioned and changed, but not deleted, and still
366
368
# in one of the dirs to be deleted.
367
files_to_backup.append(path[1])
369
files_to_backup.append(change.path[1])
368
370
files_to_backup.extend(
369
osutils.parent_directories(path[1]))
371
osutils.parent_directories(change.path[1]))
414
416
# expand any symlinks in the directory part, while leaving the
416
418
# only expanding if symlinks are supported avoids windows path bugs
417
if osutils.has_symlinks():
419
if self.supports_symlinks():
418
420
file_list = list(map(osutils.normalizepath, file_list))
420
422
conflicts_related = set()
568
570
except OSError as e:
569
571
if e.errno == errno.ENOENT:
570
572
raise errors.NoSuchFile(fullpath)
571
if (kind == 'directory' and f != '' and
572
os.path.exists(os.path.join(fullpath, '.git'))):
573
if f != '' and self._directory_is_tree_reference(f):
573
574
kind = 'tree-reference'
574
575
kinds[pos] = kind
594
595
self._index_dirty = False
596
def has_or_had_id(self, file_id):
597
if self.has_id(file_id):
599
if self.had_id(file_id):
603
def had_id(self, file_id):
604
path = self._basis_fileid_map.lookup_path(file_id)
606
head = self.repository._git.head()
608
# Assume no if basis is not accessible
611
root_tree = self.store[head].tree
615
tree_lookup_path(self.store.__getitem__,
616
root_tree, path.encode('utf-8'))
622
597
def get_file_mtime(self, path):
623
598
"""See Tree.get_file_mtime."""
680
655
raise errors.GhostRevisionUnusableHere(revid)
682
657
def _reset_data(self):
684
head = self.repository._git.head()
686
self._basis_fileid_map = GitFileIdMap({}, self.mapping)
688
self._basis_fileid_map = self.mapping.get_fileid_map(
689
self.store.__getitem__, self.store[head].tree)
690
self._fileid_map = self._basis_fileid_map.copy()
692
660
def get_file_verifier(self, path, stat_value=None):
693
661
with self.lock_read():
744
712
def is_executable(self, path):
745
713
with self.lock_read():
746
if getattr(self, "_supports_executable",
747
osutils.supports_executable)():
714
if self._supports_executable():
748
715
mode = self._lstat(path).st_mode
750
717
(index, subpath) = self._lookup_index(path.encode('utf-8'))
755
722
return bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode)
757
724
def _is_executable_from_path_and_stat(self, path, stat_result):
758
if getattr(self, "_supports_executable",
759
osutils.supports_executable)():
760
return self._is_executable_from_path_and_stat_from_stat(
725
if self._supports_executable():
726
return self._is_executable_from_path_and_stat_from_stat(path, stat_result)
763
728
return self._is_executable_from_path_and_stat_from_basis(
764
729
path, stat_result)
1045
1010
prefix = prefix.encode('utf-8')
1046
1011
per_dir = defaultdict(set)
1047
1012
if prefix == b"":
1048
per_dir[(u'', self.get_root_id())] = set()
1013
per_dir[(u'', self.path2id(''))] = set()
1050
1015
def add_entry(path, kind):
1051
1016
if path == b'' or not path.startswith(prefix):
1168
1133
if self.branch.head is None
1169
else self.store[self.branch.head].tree)
1134
else self.store[self.branch.head].tree,
1135
honor_filemode=self._supports_executable())
1171
1137
def reset_state(self, revision_ids=None):
1172
1138
"""Reset the state of the working tree.