请在 2024 Clojure 现状调查! 分享您的想法。

欢迎!有关此页面如何工作的更多信息,请参阅 关于 页面。

0
tools.namespace
编辑

大家好,

我相信我找到了 clojure.tools.namespace 中 TNS-6 的解决方案。我有一个一致的复现,以及一个由一行补丁形式的解决方案(见补丁以获取更多详细信息)。所有测试仍然通过,尽管我不确定它们是否涵盖了更改。我还使用本地依赖的多个仓库中对解决方案进行了测试,并解决了该问题。

然而,我不是 Clojure 贡献者,所以我不能评论或提交补丁或评论相关的 Jira 项。

From b5a62f894e049a09d5fcf099ac7b4d6591fb4f18 Mon Sep 17 00:00:00 2001
From: zalky <[email protected]>
Date: Mon, 24 May 2021 13:08:30 -0400
Subject: [PATCH] Fix TNS-6: fully remove ns from deps graph

The clojure.tools.namespace.dependency/remove-node fn removes a
namespace's :dependencies set from the graph (outgoing edges), but
does not remove that namespace from the :dependents set of other
namespaces (ingoing edges). If a namespace is removed and one of its
dependencies is changed at the same time, as commonly occurs when
switching branches, then the removed namespace is still in the
:dependents of the changed namespace when it is reloaded. As all the
of the dependents of a changed namespace are also reloaded, this
throws a missing namespace error.

The resolution is to use clojure.tools.namespace.depedency/remove-all
to remove both outgoing (:dependencies) and ingoing (:dependents)
edges in the dependency graph.

However, care must be taken when choosing the point of change, because
clojure.tools.namespace.track/add relies on the partial removal
behaviour of clojure.tools.namespace.track/remove-deps. It uses
remove-deps to wipe the dependencies of a node, and cannot know how to
re-insert dependents if lost. Therefore the point of change should be
in clojure.tools.namespace.track/remove.
---
 src/main/clojure/clojure/tools/namespace/track.cljc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/clojure/clojure/tools/namespace/track.cljc b/src/main/clojure/clojure/tools/namespace/track.cljc
index 683c35d..ce666d5 100644
--- a/src/main/clojure/clojure/tools/namespace/track.cljc
+++ b/src/main/clojure/clojure/tools/namespace/track.cljc
@@ -96,7 +96,7 @@
          :or {load (), unload (), deps (dep/graph)}} tracker
         known (set (dep/nodes deps))
         removed-names (filter known names)
-        new-deps (remove-deps deps removed-names)
+        new-deps (reduce dep/remove-all deps removed-names)
         changed (affected-namespaces deps removed-names)]
     (assoc tracker
       ::deps new-deps
-- 
2.30.1 (Apple Git-130)

在进一步测试后更新了补丁

1 个答案

0

选择
 
最佳答案

你想要成为贡献者并提交补丁吗?如果是这样,请签署贡献协议,并根据https://clojure.org/dev/dev#_becoming_a_contributor提交支持请求以获得 Jira 账户。

如果不是的话,我实际上无法查看你的补丁,但也许你可以描述问题和解法,贡献者可以编写一个干净的补丁。

感谢Alex的回复,以及你提供的贡献者协议链接。我会花更多的时间来验证解决方案,然后再跟进。
...