Now that we have a Rust implementation, we defer to that accordingly.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
Now that we have a Rust implementation, we defer to that accordingly.
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/dirstatemap.py (96 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
1b460a28ffed | 7b81a6c2fcc4 | Raphaël Gomès | Mar 23 2022, 12:25 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare | ||
Closed | Alphare |
else: | else: | ||||
self._dirs_decr(f, old_entry=entry, remove_variant=not entry.added) | self._dirs_decr(f, old_entry=entry, remove_variant=not entry.added) | ||||
if not entry.p2_info: | if not entry.p2_info: | ||||
self.copymap.pop(f, None) | self.copymap.pop(f, None) | ||||
entry.set_untracked() | entry.set_untracked() | ||||
self._refresh_entry(f, entry) | self._refresh_entry(f, entry) | ||||
return True | return True | ||||
def reset_state( | |||||
self, | |||||
filename, | |||||
wc_tracked=False, | |||||
p1_tracked=False, | |||||
p2_info=False, | |||||
has_meaningful_mtime=True, | |||||
parentfiledata=None, | |||||
): | |||||
"""Set a entry to a given state, diregarding all previous state | |||||
This is to be used by the part of the dirstate API dedicated to | |||||
adjusting the dirstate after a update/merge. | |||||
note: calling this might result to no entry existing at all if the | |||||
dirstate map does not see any point at having one for this file | |||||
anymore. | |||||
""" | |||||
# copy information are now outdated | |||||
# (maybe new information should be in directly passed to this function) | |||||
self.copymap.pop(filename, None) | |||||
if not (p1_tracked or p2_info or wc_tracked): | |||||
old_entry = self._map.get(filename) | |||||
self._drop_entry(filename) | |||||
self._dirs_decr(filename, old_entry=old_entry) | |||||
return | |||||
old_entry = self._map.get(filename) | |||||
self._dirs_incr(filename, old_entry) | |||||
entry = DirstateItem( | |||||
wc_tracked=wc_tracked, | |||||
p1_tracked=p1_tracked, | |||||
p2_info=p2_info, | |||||
has_meaningful_mtime=has_meaningful_mtime, | |||||
parentfiledata=parentfiledata, | |||||
) | |||||
self._insert_entry(filename, entry) | |||||
### disk interaction | ### disk interaction | ||||
def _opendirstatefile(self): | def _opendirstatefile(self): | ||||
fp, mode = txnutil.trypending(self._root, self._opener, self._filename) | fp, mode = txnutil.trypending(self._root, self._opener, self._filename) | ||||
if self._pendingmode is not None and self._pendingmode != mode: | if self._pendingmode is not None and self._pendingmode != mode: | ||||
fp.close() | fp.close() | ||||
raise error.Abort( | raise error.Abort( | ||||
_(b'working directory state may be changed parallelly') | _(b'working directory state may be changed parallelly') | ||||
return pathutil.dirs(self._map, only_tracked=True) | return pathutil.dirs(self._map, only_tracked=True) | ||||
@propertycache | @propertycache | ||||
def _alldirs(self): | def _alldirs(self): | ||||
return pathutil.dirs(self._map) | return pathutil.dirs(self._map) | ||||
### code related to manipulation of entries and copy-sources | ### code related to manipulation of entries and copy-sources | ||||
def reset_state( | |||||
self, | |||||
filename, | |||||
wc_tracked=False, | |||||
p1_tracked=False, | |||||
p2_info=False, | |||||
has_meaningful_mtime=True, | |||||
parentfiledata=None, | |||||
): | |||||
"""Set a entry to a given state, diregarding all previous state | |||||
This is to be used by the part of the dirstate API dedicated to | |||||
adjusting the dirstate after a update/merge. | |||||
note: calling this might result to no entry existing at all if the | |||||
dirstate map does not see any point at having one for this file | |||||
anymore. | |||||
""" | |||||
# copy information are now outdated | |||||
# (maybe new information should be in directly passed to this function) | |||||
self.copymap.pop(filename, None) | |||||
if not (p1_tracked or p2_info or wc_tracked): | |||||
old_entry = self._map.get(filename) | |||||
self._drop_entry(filename) | |||||
self._dirs_decr(filename, old_entry=old_entry) | |||||
return | |||||
old_entry = self._map.get(filename) | |||||
self._dirs_incr(filename, old_entry) | |||||
entry = DirstateItem( | |||||
wc_tracked=wc_tracked, | |||||
p1_tracked=p1_tracked, | |||||
p2_info=p2_info, | |||||
has_meaningful_mtime=has_meaningful_mtime, | |||||
parentfiledata=parentfiledata, | |||||
) | |||||
self._insert_entry(filename, entry) | |||||
def set_tracked(self, filename): | def set_tracked(self, filename): | ||||
new = False | new = False | ||||
entry = self.get(filename) | entry = self.get(filename) | ||||
if entry is None: | if entry is None: | ||||
self._dirs_incr(filename) | self._dirs_incr(filename) | ||||
entry = DirstateItem( | entry = DirstateItem( | ||||
wc_tracked=True, | wc_tracked=True, | ||||
) | ) | ||||
self._map.addfile(f, entry) | self._map.addfile(f, entry) | ||||
def _insert_entry(self, f, entry): | def _insert_entry(self, f, entry): | ||||
self._map.addfile(f, entry) | self._map.addfile(f, entry) | ||||
def set_tracked(self, f): | def set_tracked(self, f): | ||||
return self._map.set_tracked(f) | return self._map.set_tracked(f) | ||||
def reset_state( | |||||
self, | |||||
filename, | |||||
wc_tracked=False, | |||||
p1_tracked=False, | |||||
p2_info=False, | |||||
has_meaningful_mtime=True, | |||||
parentfiledata=None, | |||||
): | |||||
return self._map.reset_state( | |||||
filename, | |||||
wc_tracked, | |||||
p1_tracked, | |||||
p2_info, | |||||
has_meaningful_mtime, | |||||
parentfiledata, | |||||
) | |||||
def _drop_entry(self, f): | def _drop_entry(self, f): | ||||
self._map.drop_item_and_copy_source(f) | self._map.drop_item_and_copy_source(f) | ||||
def __setitem__(self, key, value): | def __setitem__(self, key, value): | ||||
assert isinstance(value, DirstateItem) | assert isinstance(value, DirstateItem) | ||||
self._map.set_dirstate_item(key, value) | self._map.set_dirstate_item(key, value) |