mercurial/dirstate.py
changeset 47521 abed645b8e96
parent 47517 28632eb3ca3e
child 47522 587bb99ea311
equal deleted inserted replaced
47520:5decb7a49bb6 47521:abed645b8e96
    41 
    41 
    42 SUPPORTS_DIRSTATE_V2 = rustmod is not None
    42 SUPPORTS_DIRSTATE_V2 = rustmod is not None
    43 
    43 
    44 propertycache = util.propertycache
    44 propertycache = util.propertycache
    45 filecache = scmutil.filecache
    45 filecache = scmutil.filecache
    46 _rangemask = 0x7FFFFFFF
    46 _rangemask = dirstatemap.rangemask
    47 
    47 
    48 dirstatetuple = parsers.dirstatetuple
    48 dirstatetuple = parsers.dirstatetuple
    49 
       
    50 
    49 
    51 # a special value used internally for `size` if the file come from the other parent
    50 # a special value used internally for `size` if the file come from the other parent
    52 FROM_P2 = dirstatemap.FROM_P2
    51 FROM_P2 = dirstatemap.FROM_P2
    53 
    52 
    54 # a special value used internally for `size` if the file is modified/merged/added
    53 # a special value used internally for `size` if the file is modified/merged/added
   453     def _addpath(
   452     def _addpath(
   454         self,
   453         self,
   455         f,
   454         f,
   456         state,
   455         state,
   457         mode,
   456         mode,
   458         size=NONNORMAL,
   457         size=None,
   459         mtime=AMBIGUOUS_TIME,
   458         mtime=None,
   460         from_p2=False,
   459         from_p2=False,
   461         possibly_dirty=False,
   460         possibly_dirty=False,
   462     ):
   461     ):
   463         oldstate = self[f]
   462         oldstate = self[f]
   464         if state == b'a' or oldstate == b'r':
   463         if state == b'a' or oldstate == b'r':
   474                 entry = self._map.get(d)
   473                 entry = self._map.get(d)
   475                 if entry is not None and not entry.removed:
   474                 if entry is not None and not entry.removed:
   476                     msg = _(b'file %r in dirstate clashes with %r')
   475                     msg = _(b'file %r in dirstate clashes with %r')
   477                     msg %= (pycompat.bytestr(d), pycompat.bytestr(f))
   476                     msg %= (pycompat.bytestr(d), pycompat.bytestr(f))
   478                     raise error.Abort(msg)
   477                     raise error.Abort(msg)
   479         if state == b'a':
       
   480             assert not possibly_dirty
       
   481             assert not from_p2
       
   482             size = NONNORMAL
       
   483             mtime = AMBIGUOUS_TIME
       
   484         elif from_p2:
       
   485             assert not possibly_dirty
       
   486             size = FROM_P2
       
   487             mtime = AMBIGUOUS_TIME
       
   488         elif possibly_dirty:
       
   489             mtime = AMBIGUOUS_TIME
       
   490         else:
       
   491             assert size != FROM_P2
       
   492             assert size != NONNORMAL
       
   493             size = size & _rangemask
       
   494             mtime = mtime & _rangemask
       
   495         self._dirty = True
   478         self._dirty = True
   496         self._updatedfiles.add(f)
   479         self._updatedfiles.add(f)
   497         self._map.addfile(f, oldstate, state, mode, size, mtime)
   480         self._map.addfile(
       
   481             f,
       
   482             oldstate,
       
   483             state=state,
       
   484             mode=mode,
       
   485             size=size,
       
   486             mtime=mtime,
       
   487             from_p2=from_p2,
       
   488             possibly_dirty=possibly_dirty,
       
   489         )
   498 
   490 
   499     def normal(self, f, parentfiledata=None):
   491     def normal(self, f, parentfiledata=None):
   500         """Mark a file normal and clean.
   492         """Mark a file normal and clean.
   501 
   493 
   502         parentfiledata: (mode, size, mtime) of the clean file
   494         parentfiledata: (mode, size, mtime) of the clean file