Patchwork D10933: dirstate: explicitely deal with the `added` case in `_addpath`

login
register
mail settings
Submitter phabricator
Date July 2, 2021, 3:18 p.m.
Message ID <differential-rev-PHID-DREV-3mj63bombx5npo6k2q4f-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49248/
State Superseded
Headers show

Comments

phabricator - July 2, 2021, 3:18 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This special case is now directly handled, this clarify the possible value for
  the other options.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10933

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -464,17 +464,22 @@ 
                     msg = _(b'file %r in dirstate clashes with %r')
                     msg %= (pycompat.bytestr(d), pycompat.bytestr(f))
                     raise error.Abort(msg)
-        if from_p2:
+        if state == b'a':
+            assert not possibly_dirty
+            assert not from_p2
+            size = NONNORMAL
+            mtime = AMBIGUOUS_TIME
+        elif from_p2:
+            assert not possibly_dirty
             size = FROM_P2
             mtime = AMBIGUOUS_TIME
         elif possibly_dirty:
             mtime = AMBIGUOUS_TIME
         else:
             assert size != FROM_P2
-            if size != NONNORMAL:
-                size = size & _rangemask
-            if mtime != AMBIGUOUS_TIME:
-                mtime = mtime & _rangemask
+            assert size != NONNORMAL
+            size = size & _rangemask
+            mtime = mtime & _rangemask
         self._dirty = True
         self._updatedfiles.add(f)
         self._map.addfile(f, oldstate, state, mode, size, mtime)