mercurial/dirstate.py
changeset 48393 1a8a70b4b0ad
parent 48392 434de12918fd
child 48413 c6d00759dc2b
equal deleted inserted replaced
48392:434de12918fd 48393:1a8a70b4b0ad
   731         if not self._dirty:
   731         if not self._dirty:
   732             return
   732             return
   733 
   733 
   734         filename = self._filename
   734         filename = self._filename
   735         if tr:
   735         if tr:
   736             # 'dirstate.write()' is not only for writing in-memory
       
   737             # changes out, but also for dropping ambiguous timestamp.
       
   738             # delayed writing re-raise "ambiguous timestamp issue".
       
   739             # See also the wiki page below for detail:
       
   740             # https://www.mercurial-scm.org/wiki/DirstateTransactionPlan
       
   741 
       
   742             # record when mtime start to be ambiguous
       
   743             now = timestamp.get_fs_now(self._opener)
       
   744 
       
   745             # delay writing in-memory changes out
   736             # delay writing in-memory changes out
   746             tr.addfilegenerator(
   737             tr.addfilegenerator(
   747                 b'dirstate',
   738                 b'dirstate',
   748                 (self._filename,),
   739                 (self._filename,),
   749                 lambda f: self._writedirstate(tr, f, now=now),
   740                 lambda f: self._writedirstate(tr, f),
   750                 location=b'plain',
   741                 location=b'plain',
   751             )
   742             )
   752             return
   743             return
   753 
   744 
   754         st = self._opener(filename, b"w", atomictemp=True, checkambig=True)
   745         st = self._opener(filename, b"w", atomictemp=True, checkambig=True)
   763         Category is a unique identifier to allow overwriting an old callback
   754         Category is a unique identifier to allow overwriting an old callback
   764         with a newer callback.
   755         with a newer callback.
   765         """
   756         """
   766         self._plchangecallbacks[category] = callback
   757         self._plchangecallbacks[category] = callback
   767 
   758 
   768     def _writedirstate(self, tr, st, now=None):
   759     def _writedirstate(self, tr, st):
   769         # notify callbacks about parents change
   760         # notify callbacks about parents change
   770         if self._origpl is not None and self._origpl != self._pl:
   761         if self._origpl is not None and self._origpl != self._pl:
   771             for c, callback in sorted(
   762             for c, callback in sorted(
   772                 pycompat.iteritems(self._plchangecallbacks)
   763                 pycompat.iteritems(self._plchangecallbacks)
   773             ):
   764             ):
   774                 callback(self, self._origpl, self._pl)
   765                 callback(self, self._origpl, self._pl)
   775             self._origpl = None
   766             self._origpl = None
   776 
   767 
   777         if now is None:
   768         self._map.write(tr, st)
   778             # use the modification time of the newly created temporary file as the
       
   779             # filesystem's notion of 'now'
       
   780             now = timestamp.mtime_of(util.fstat(st))
       
   781 
       
   782         self._map.write(tr, st, now)
       
   783         self._dirty = False
   769         self._dirty = False
   784 
   770 
   785     def _dirignore(self, f):
   771     def _dirignore(self, f):
   786         if self._ignore(f):
   772         if self._ignore(f):
   787             return True
   773             return True