From 3f4a0d5370ae6c34afe180df96add3b8522f4af1 Mon Sep 17 00:00:00 2001 From: mattkae Date: Wed, 11 May 2022 09:23:58 -0400 Subject: initial commit --- .../req-package-cycles.el | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 elpa/req-package-20180605.1141/req-package-cycles.el (limited to 'elpa/req-package-20180605.1141/req-package-cycles.el') diff --git a/elpa/req-package-20180605.1141/req-package-cycles.el b/elpa/req-package-20180605.1141/req-package-cycles.el new file mode 100644 index 0000000..73d982e --- /dev/null +++ b/elpa/req-package-20180605.1141/req-package-cycles.el @@ -0,0 +1,35 @@ +;;; req-package-cycles.el --- summary: +;;; commentary: +;;; code: + +(require 'dash) + +(defvar req-package-cycles-count 0 + "Number of cycles detected.") + +(defun req-package-cycles-detect-traverse-impl (graph visited cur path) + "Traverse for cycles look up implementation" + (puthash cur t visited) + (if (not (-contains? path cur)) + (-each (gethash cur graph nil) + (lambda (dependent) + (req-package-cycles-detect-traverse-impl graph visited dependent (cons cur path)))) + (progn (setq req-package-cycles-count (+ req-package-cycles-count 1)) + (req-package--log-error "cycle detected: %s" (cons cur path))))) + +(defun req-package-cycles-detect-traverse (graph visited) + "Traverse for cycles look up" + (maphash (lambda (key value) + (if (null (gethash key visited nil)) + (req-package-cycles-detect-traverse-impl graph visited key nil))) + graph) + (if (not (eq 0 req-package-cycles-count)) + (message "%s cycle(s) detected. see M-x req-package--log-open-log" + req-package-cycles-count))) + +(defun req-package-cycles-detect (graph) + (setq req-package-cycles-count 0) + (req-package-cycles-detect-traverse graph (make-hash-table :size 200))) + +(provide 'req-package-cycles) +;;; req-package-cycles ends here -- cgit v1.2.1