Since the whole need_delay have been removed, we no longer need this.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
( )
Since the whole need_delay have been removed, we no longer need this.
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/dirstate.py (20 lines) | |||
M | mercurial/dirstatemap.py (4 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
8d1a6cfe0219 | f56bff00fde6 | Pierre-Yves David | Nov 18 2021, 9:03 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute |
return self._map.identity | return self._map.identity | ||||
def write(self, tr): | def write(self, tr): | ||||
if not self._dirty: | if not self._dirty: | ||||
return | return | ||||
filename = self._filename | filename = self._filename | ||||
if tr: | if tr: | ||||
# 'dirstate.write()' is not only for writing in-memory | |||||
# changes out, but also for dropping ambiguous timestamp. | |||||
# delayed writing re-raise "ambiguous timestamp issue". | |||||
# See also the wiki page below for detail: | |||||
# https://www.mercurial-scm.org/wiki/DirstateTransactionPlan | |||||
# record when mtime start to be ambiguous | |||||
now = timestamp.get_fs_now(self._opener) | |||||
# delay writing in-memory changes out | # delay writing in-memory changes out | ||||
tr.addfilegenerator( | tr.addfilegenerator( | ||||
b'dirstate', | b'dirstate', | ||||
(self._filename,), | (self._filename,), | ||||
lambda f: self._writedirstate(tr, f, now=now), | lambda f: self._writedirstate(tr, f), | ||||
location=b'plain', | location=b'plain', | ||||
) | ) | ||||
return | return | ||||
st = self._opener(filename, b"w", atomictemp=True, checkambig=True) | st = self._opener(filename, b"w", atomictemp=True, checkambig=True) | ||||
self._writedirstate(tr, st) | self._writedirstate(tr, st) | ||||
def addparentchangecallback(self, category, callback): | def addparentchangecallback(self, category, callback): | ||||
"""add a callback to be called when the wd parents are changed | """add a callback to be called when the wd parents are changed | ||||
Callback will be called with the following arguments: | Callback will be called with the following arguments: | ||||
dirstate, (oldp1, oldp2), (newp1, newp2) | dirstate, (oldp1, oldp2), (newp1, newp2) | ||||
Category is a unique identifier to allow overwriting an old callback | Category is a unique identifier to allow overwriting an old callback | ||||
with a newer callback. | with a newer callback. | ||||
""" | """ | ||||
self._plchangecallbacks[category] = callback | self._plchangecallbacks[category] = callback | ||||
def _writedirstate(self, tr, st, now=None): | def _writedirstate(self, tr, st): | ||||
# notify callbacks about parents change | # notify callbacks about parents change | ||||
if self._origpl is not None and self._origpl != self._pl: | if self._origpl is not None and self._origpl != self._pl: | ||||
for c, callback in sorted( | for c, callback in sorted( | ||||
pycompat.iteritems(self._plchangecallbacks) | pycompat.iteritems(self._plchangecallbacks) | ||||
): | ): | ||||
callback(self, self._origpl, self._pl) | callback(self, self._origpl, self._pl) | ||||
self._origpl = None | self._origpl = None | ||||
if now is None: | self._map.write(tr, st) | ||||
# use the modification time of the newly created temporary file as the | |||||
# filesystem's notion of 'now' | |||||
now = timestamp.mtime_of(util.fstat(st)) | |||||
self._map.write(tr, st, now) | |||||
self._dirty = False | self._dirty = False | ||||
def _dirignore(self, f): | def _dirignore(self, f): | ||||
if self._ignore(f): | if self._ignore(f): | ||||
return True | return True | ||||
for p in pathutil.finddirs(f): | for p in pathutil.finddirs(f): | ||||
if self._ignore(p): | if self._ignore(p): | ||||
return True | return True |
if not self._dirtyparents: | if not self._dirtyparents: | ||||
self.setparents(*p) | self.setparents(*p) | ||||
# Avoid excess attribute lookups by fast pathing certain checks | # Avoid excess attribute lookups by fast pathing certain checks | ||||
self.__contains__ = self._map.__contains__ | self.__contains__ = self._map.__contains__ | ||||
self.__getitem__ = self._map.__getitem__ | self.__getitem__ = self._map.__getitem__ | ||||
self.get = self._map.get | self.get = self._map.get | ||||
def write(self, tr, st, now): | def write(self, tr, st): | ||||
if self._use_dirstate_v2: | if self._use_dirstate_v2: | ||||
packed, meta = v2.pack_dirstate(self._map, self.copymap) | packed, meta = v2.pack_dirstate(self._map, self.copymap) | ||||
self.write_v2_no_append(tr, st, meta, packed) | self.write_v2_no_append(tr, st, meta, packed) | ||||
else: | else: | ||||
packed = parsers.pack_dirstate( | packed = parsers.pack_dirstate( | ||||
self._map, self.copymap, self.parents() | self._map, self.copymap, self.parents() | ||||
) | ) | ||||
st.write(packed) | st.write(packed) | ||||
### disk interaction | ### disk interaction | ||||
@propertycache | @propertycache | ||||
def identity(self): | def identity(self): | ||||
self._map | self._map | ||||
return self.identity | return self.identity | ||||
def write(self, tr, st, now): | def write(self, tr, st): | ||||
if not self._use_dirstate_v2: | if not self._use_dirstate_v2: | ||||
p1, p2 = self.parents() | p1, p2 = self.parents() | ||||
packed = self._map.write_v1(p1, p2) | packed = self._map.write_v1(p1, p2) | ||||
st.write(packed) | st.write(packed) | ||||
st.close() | st.close() | ||||
self._dirtyparents = False | self._dirtyparents = False | ||||
return | return | ||||