diff mercurial/dirstatemap.py @ 48066:98c0408324e6

dirstate: Pass the final DirstateItem to _rustmap.addfile() Now that the Python DirstateItem class wraps a Rust DirstateEntry value, use that value directly instead of converting through v1 data + 5 booleans. Also remove propogating the return value. None of the callers look at it, and it is always None. Differential Revision: https://phab.mercurial-scm.org/D11494
author Simon Sapin <simon.sapin@octobus.net>
date Thu, 23 Sep 2021 18:29:40 +0200
parents 2ac0e6b23222
children d07d38ef6362
line wrap: on
line diff
--- a/mercurial/dirstatemap.py	Thu Sep 23 15:36:43 2021 +0200
+++ b/mercurial/dirstatemap.py	Thu Sep 23 18:29:40 2021 +0200
@@ -561,19 +561,26 @@
             from_p2=False,
             possibly_dirty=False,
         ):
-            ret = self._rustmap.addfile(
-                f,
-                mode,
-                size,
-                mtime,
-                added,
-                merged,
-                from_p2,
-                possibly_dirty,
-            )
+            if added:
+                assert not possibly_dirty
+                assert not from_p2
+                item = DirstateItem.new_added()
+            elif merged:
+                assert not possibly_dirty
+                assert not from_p2
+                item = DirstateItem.new_merged()
+            elif from_p2:
+                assert not possibly_dirty
+                item = DirstateItem.new_from_p2()
+            elif possibly_dirty:
+                item = DirstateItem.new_possibly_dirty()
+            else:
+                size = size & rangemask
+                mtime = mtime & rangemask
+                item = DirstateItem.new_normal(mode, size, mtime)
+            self._rustmap.addfile(f, item)
             if added:
                 self.copymap.pop(f, None)
-            return ret
 
         def reset_state(
             self,