large-files: also open the context in the subdirstate
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 20 Feb 2023 17:16:52 +0100
changeset 50142 308aff0243ae
parent 50141 42288fa03322
child 50143 ec3631290eb7
large-files: also open the context in the subdirstate
hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py	Wed Feb 22 00:23:06 2023 +0100
+++ b/hgext/largefiles/overrides.py	Mon Feb 20 17:16:52 2023 +0100
@@ -334,6 +334,27 @@
         self._sub_dirstate = pre
 
 
+@eh.wrapfunction(dirstate.dirstate, b'running_status')
+@contextlib.contextmanager
+def running_status(orig, self, repo):
+    pre = sub_dirstate = getattr(self, '_sub_dirstate', None)
+    try:
+        lfd = getattr(self, '_large_file_dirstate', False)
+        if sub_dirstate is None and not lfd:
+            sub_dirstate = lfutil.openlfdirstate(repo.ui, repo)
+            self._sub_dirstate = sub_dirstate
+        if not lfd:
+            assert self._sub_dirstate is not None
+        with orig(self, repo):
+            if sub_dirstate is None:
+                yield
+            else:
+                with sub_dirstate.running_status(repo):
+                    yield
+    finally:
+        self._sub_dirstate = pre
+
+
 @eh.wrapfunction(subrepo.hgsubrepo, b'status')
 def overridestatusfn(orig, repo, rev2, **opts):
     with lfstatus(repo._repo):