/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 workingtree.py

  • Committer: Jelmer Vernooij
  • Date: 2018-03-20 03:30:26 UTC
  • mto: (0.200.1871 work)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180320033026-lpx6abu40wobhe4i
Implement WorkingTree.reset_state().

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    )
32
32
from dulwich.index import (
33
33
    Index,
 
34
    build_index_from_tree,
34
35
    changes_from_tree,
35
36
    cleanup_mode,
36
37
    commit_tree,
112
113
        self._rules_searcher = None
113
114
        self._detect_case_handling()
114
115
        self._reset_data()
115
 
        self._fileid_map = self._basis_fileid_map.copy()
116
116
 
117
117
    def supports_tree_reference(self):
118
118
        return False
626
626
        else:
627
627
            self._basis_fileid_map = self.mapping.get_fileid_map(
628
628
                self.store.__getitem__, self.store[head].tree)
 
629
        self._fileid_map = self._basis_fileid_map.copy()
629
630
 
630
631
    def get_file_verifier(self, path, file_id=None, stat_value=None):
631
632
        with self.lock_read():
1069
1070
    def _rename_one(self, from_rel, to_rel):
1070
1071
        os.rename(self.abspath(from_rel), self.abspath(to_rel))
1071
1072
 
 
1073
    def reset_state(self, revision_ids=None):
 
1074
        """Reset the state of the working tree.
 
1075
 
 
1076
        This does a hard-reset to a last-known-good state. This is a way to
 
1077
        fix if something got corrupted (like the .git/index file)
 
1078
        """
 
1079
        with self.lock_tree_write():
 
1080
            if revision_ids is not None:
 
1081
                self.set_parent_ids(revision_ids)
 
1082
            build_index_from_tree(
 
1083
                self.user_transport.local_abspath('.'),
 
1084
                self.control_transport.local_abspath("index"),
 
1085
                self.store,
 
1086
                None if self.branch.head is None else self.store[self.branch.head].tree)
 
1087
            self._fileid_map = self._basis_fileid_map.copy()
 
1088
 
1072
1089
 
1073
1090
class GitWorkingTreeFormat(workingtree.WorkingTreeFormat):
1074
1091