Patchwork D7060: rust-dirstate-status: add call to rust-fast path for `dirstate.status`

login
register
mail settings
Submitter phabricator
Date Oct. 11, 2019, 3:44 p.m.
Message ID <differential-rev-PHID-DREV-7apjfimalxyp6huofurc-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/42217/
State Superseded
Headers show

Comments

phabricator - Oct. 11, 2019, 3:44 p.m.
Alphare created this revision.
Herald added subscribers: mercurial-devel, mjpieters.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The reasoning behind this patch is explained in the first patch of the series.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS




To: Alphare, #hg-reviewers
Cc: mjpieters, mercurial-devel
phabricator - Oct. 16, 2019, 9:35 p.m.
This revision is now accepted and ready to land.
martinvonz added inline comments.
martinvonz accepted this revision.

INLINE COMMENTS

> dirstate.py:1120-1127
> +            lookup, modified, added, removed, deleted, unknown, clean = rustmod.status(
> +                dmap._rustmap,
> +                self._rootdir,
> +                match.files(),
> +                bool(listclean),
> +                self._lastnormaltime,
> +                self._checkexec,

contrib/grey.py wants is not happy with the formatting. I'll fix it in flight.

> dirstate.py:1107
> +            use_rust = False
> +        if bool(listunknown):
> +            # Pathauditor does not exist yet in Rust, unknown files

nit: the `bool()` wrapping is probably not necessary (and it's inconsistent with line the check for `listignored` a few lines down)

> dirstate.py:1134-1137
> +            status = scmutil.status(modified=modified, added=added,
> +                                    removed=removed, deleted=deleted,
> +                                    unknown=unknown, ignored=ignored,
> +                                    clean=clean)

same here

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7060/new/

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

To: Alphare, #hg-reviewers, martinvonz
Cc: martinvonz, mjpieters, mercurial-devel

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -24,6 +24,7 @@ 
     policy,
     pycompat,
     scmutil,
+    sparse,
     txnutil,
     util,
 )
@@ -1092,6 +1093,45 @@ 
 
         dmap = self._map
         dmap.preload()
+
+        use_rust = True
+        if rustmod is None:
+            use_rust = False
+        elif subrepos:
+            use_rust = False
+        if bool(listunknown):
+            # Pathauditor does not exist yet in Rust, unknown files
+            # can't be trusted.
+            use_rust = False
+        elif self._ignorefiles() and listignored:
+            # Rust has no ignore mechanism yet, so don't use Rust for
+            # commands that need ignore.
+            use_rust = False
+        elif not match.always():
+            # Matchers have yet to be implemented
+            use_rust = False
+        # We don't yet have a mechanism for extensions
+        elif sparse.enabled:
+            use_rust = False
+        elif not getattr(self, "_fsmonitordisable", True):
+            use_rust = False
+
+        if use_rust:
+            lookup, modified, added, removed, deleted, unknown, clean = rustmod.status(
+                dmap._rustmap,
+                self._rootdir,
+                match.files(),
+                bool(listclean),
+                self._lastnormaltime,
+                self._checkexec,
+            )
+
+            status = scmutil.status(modified=modified, added=added,
+                                    removed=removed, deleted=deleted,
+                                    unknown=unknown, ignored=ignored,
+                                    clean=clean)
+            return (lookup, status)
+
         dcontains = dmap.__contains__
         dget = dmap.__getitem__
         ladd = lookup.append  # aka "unsure"