/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/git/workingtree.py

  • Committer: Jelmer Vernooij
  • Date: 2019-12-23 01:39:21 UTC
  • mfrom: (7424 work)
  • mto: This revision was merged to the branch mainline in revision 7425.
  • Revision ID: jelmer@jelmer.uk-20191223013921-2kzd0wlcoylgxksk
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
    MutableGitIndexTree,
80
80
    )
81
81
from .mapping import (
82
 
    GitFileIdMap,
83
82
    mode_kind,
84
83
    )
85
84
 
209
208
        else:
210
209
            self.case_sensitive = False
211
210
 
 
211
    def get_transform(self, pb=None):
 
212
        from ..transform import TreeTransform
 
213
        return TreeTransform(self, pb=pb)
 
214
 
212
215
    def merge_modified(self):
213
216
        return {}
214
217
 
350
353
 
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]))
370
372
 
371
373
            for f in files:
372
374
                if f == '':
414
416
        # expand any symlinks in the directory part, while leaving the
415
417
        # filename alone
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))
419
421
 
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
575
576
 
593
594
            raise
594
595
        self._index_dirty = False
595
596
 
596
 
    def has_or_had_id(self, file_id):
597
 
        if self.has_id(file_id):
598
 
            return True
599
 
        if self.had_id(file_id):
600
 
            return True
601
 
        return False
602
 
 
603
 
    def had_id(self, file_id):
604
 
        path = self._basis_fileid_map.lookup_path(file_id)
605
 
        try:
606
 
            head = self.repository._git.head()
607
 
        except KeyError:
608
 
            # Assume no if basis is not accessible
609
 
            return False
610
 
        try:
611
 
            root_tree = self.store[head].tree
612
 
        except KeyError:
613
 
            return False
614
 
        try:
615
 
            tree_lookup_path(self.store.__getitem__,
616
 
                             root_tree, path.encode('utf-8'))
617
 
        except KeyError:
618
 
            return False
619
 
        else:
620
 
            return True
621
 
 
622
597
    def get_file_mtime(self, path):
623
598
        """See Tree.get_file_mtime."""
624
599
        try:
680
655
            raise errors.GhostRevisionUnusableHere(revid)
681
656
 
682
657
    def _reset_data(self):
683
 
        try:
684
 
            head = self.repository._git.head()
685
 
        except KeyError:
686
 
            self._basis_fileid_map = GitFileIdMap({}, self.mapping)
687
 
        else:
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()
 
658
        pass
691
659
 
692
660
    def get_file_verifier(self, path, stat_value=None):
693
661
        with self.lock_read():
743
711
 
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
749
716
            else:
750
717
                (index, subpath) = self._lookup_index(path.encode('utf-8'))
755
722
            return bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode)
756
723
 
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(
761
 
                path, stat_result)
 
725
        if self._supports_executable():
 
726
            return self._is_executable_from_path_and_stat_from_stat(path, stat_result)
762
727
        else:
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()
1049
1014
 
1050
1015
        def add_entry(path, kind):
1051
1016
            if path == b'' or not path.startswith(prefix):
1166
1131
            self.store,
1167
1132
            None
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())
1170
1136
 
1171
1137
    def reset_state(self, revision_ids=None):
1172
1138
        """Reset the state of the working tree.