comparison mercurial/dirstate.py @ 47486:523c00383e79

dirstate: add default value to _addpath We want to remove the magic value usage from the higher level, so lets stop passing them explicitely when possible. Differential Revision: https://phab.mercurial-scm.org/D10930
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 02 Jul 2021 02:05:47 +0200
parents 5eb65ec12465
children 1f571077222d
comparison
equal deleted inserted replaced
47485:5eb65ec12465 47486:523c00383e79
436 return self._map.copymap.get(file, None) 436 return self._map.copymap.get(file, None)
437 437
438 def copies(self): 438 def copies(self):
439 return self._map.copymap 439 return self._map.copymap
440 440
441 def _addpath(self, f, state, mode, size, mtime): 441 def _addpath(self, f, state, mode, size=NONNORMAL, mtime=AMBIGUOUS_TIME):
442 oldstate = self[f] 442 oldstate = self[f]
443 if state == b'a' or oldstate == b'r': 443 if state == b'a' or oldstate == b'r':
444 scmutil.checkfilename(f) 444 scmutil.checkfilename(f)
445 if self._map.hastrackeddir(f): 445 if self._map.hastrackeddir(f):
446 msg = _(b'directory %r already in dirstate') 446 msg = _(b'directory %r already in dirstate')
507 if source: 507 if source:
508 self.copy(source, f) 508 self.copy(source, f)
509 return 509 return
510 if entry[0] == b'm' or entry[0] == b'n' and entry[2] == FROM_P2: 510 if entry[0] == b'm' or entry[0] == b'n' and entry[2] == FROM_P2:
511 return 511 return
512 self._addpath(f, b'n', 0, NONNORMAL, AMBIGUOUS_TIME) 512 self._addpath(f, b'n', 0)
513 self._map.copymap.pop(f, None) 513 self._map.copymap.pop(f, None)
514 514
515 def otherparent(self, f): 515 def otherparent(self, f):
516 '''Mark as coming from the other parent, always dirty.''' 516 '''Mark as coming from the other parent, always dirty.'''
517 if self._pl[1] == self._nodeconstants.nullid: 517 if self._pl[1] == self._nodeconstants.nullid:
518 msg = _(b"setting %r to other parent only allowed in merges") % f 518 msg = _(b"setting %r to other parent only allowed in merges") % f
519 raise error.Abort(msg) 519 raise error.Abort(msg)
520 if f in self and self[f] == b'n': 520 if f in self and self[f] == b'n':
521 # merge-like 521 # merge-like
522 self._addpath(f, b'm', 0, FROM_P2, AMBIGUOUS_TIME) 522 self._addpath(f, b'm', 0, FROM_P2)
523 else: 523 else:
524 # add-like 524 # add-like
525 self._addpath(f, b'n', 0, FROM_P2, AMBIGUOUS_TIME) 525 self._addpath(f, b'n', 0, FROM_P2)
526 self._map.copymap.pop(f, None) 526 self._map.copymap.pop(f, None)
527 527
528 def add(self, f): 528 def add(self, f):
529 '''Mark a file added.''' 529 '''Mark a file added.'''
530 self._addpath(f, b'a', 0, NONNORMAL, AMBIGUOUS_TIME) 530 self._addpath(f, b'a', 0)
531 self._map.copymap.pop(f, None) 531 self._map.copymap.pop(f, None)
532 532
533 def remove(self, f): 533 def remove(self, f):
534 '''Mark a file removed.''' 534 '''Mark a file removed.'''
535 self._dirty = True 535 self._dirty = True