[gnus git] branch master updated: n0-17-24-g25ec0bd =1= Try to prune the Gnus registry if it's full.
Ted Zlatanov <[email protected]>
| Newsgroups | gmane.emacs.gnus.cvs |
|---|---|
| Message-ID | <[email protected]> |
via 25ec0bdd5df677f42d9287d44fb917f3b730b522 (commit)
from 2e80acc3d5080e2a714404546a367e95b0ac738e (commit)
- Log -----------------------------------------------------------------
commit 25ec0bdd5df677f42d9287d44fb917f3b730b522
Author: Ted Zlatanov <[email protected]>
Date: Mon May 9 12:48:03 2011 -0500
Try to prune the Gnus registry if it's full.
* gnus-registry.el (gnus-registry-insert): Add wrapper that calls
`registry-prune' if `registry-full' returns t.
(gnus-registry-handle-action)
(gnus-registry-get-or-make-entry, gnus-registry-set-id-key)
(gnus-registry-usage-test): Use it.
* registry.el (registry-full): Add convenience method.
(registry-insert): Use it.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 30c8e54..ae870e3 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
+2011-05-09 Teodor Zlatanov <[email protected]>
+
+ * registry.el (registry-full): Add convenience method.
+ (registry-insert): Use it.
+
+ * gnus-registry.el (gnus-registry-insert): Add wrapper that calls
+ `registry-prune' if `registry-full' returns t.
+ (gnus-registry-handle-action)
+ (gnus-registry-get-or-make-entry, gnus-registry-set-id-key)
+ (gnus-registry-usage-test): Use it.
+
2011-05-07 Julien Danjou <[email protected]>
* shr.el (shr-link): Make shr-link inherit from link by default.
diff --git a/lisp/gnus-registry.el b/lisp/gnus-registry.el
index e6c96ab..02e4ce7 100644
--- a/lisp/gnus-registry.el
+++ b/lisp/gnus-registry.el
@@ -383,7 +383,7 @@ This is not required after changing `gnus-registry-cache-file'."
(gnus-message 10 "Gnus registry: new entry for %s is %S"
id
entry)
- (registry-insert db id entry)))
+ (gnus-registry-insert db id entry)))
;; Function for nn{mail|imap}-split-fancy: look up all references in
;; the cache and if a match is found, return that group.
@@ -962,7 +962,7 @@ only the last one's marks are returned."
(entries (registry-lookup db (list id))))
(when (null entries)
- (registry-insert db id (list (list 'creation-time (current-time))
+ (gnus-registry-insert db id (list (list 'creation-time (current-time))
'(group) '(sender) '(subject)))
(setq entries (registry-lookup db (list id))))
@@ -979,9 +979,17 @@ only the last one's marks are returned."
(entry (gnus-registry-get-or-make-entry id)))
(registry-delete db (list id) nil)
(setq entry (cons (cons key vals) (assq-delete-all key entry)))
- (registry-insert db id entry)
+ (gnus-registry-insert db id entry)
entry))
+(defun gnus-registry-insert (db id entry)
+ "Just like `registry-insert' but tries to prune on error."
+ (when (registry-full db)
+ (message "Trying to prune the registry because it's full")
+ (registry-prune db))
+ (registry-insert db id entry)
+ entry)
+
(defun gnus-registry-import-eld (file)
(interactive "fOld registry file to import? ")
;; example content:
@@ -1075,7 +1083,7 @@ only the last one's marks are returned."
(should (equal (gnus-registry-get-id-key "34" 'group) '("togroup")))
(should (equal (gnus-registry-get-id-key "34" 'subject) '("subject 4")))
(message "Trying to insert a duplicate key")
- (should-error (registry-insert db "55" '()))
+ (should-error (gnus-registry-insert db "55" '()))
(message "Looking up individual keys (gnus-registry-get-or-make-entry)")
(should (gnus-registry-get-or-make-entry "22"))
(message "Saving the Gnus registry to %s" tempfile)
diff --git a/lisp/registry.el b/lisp/registry.el
index 51bfc9c..8a908a8 100644
--- a/lisp/registry.el
+++ b/lisp/registry.el
@@ -261,6 +261,11 @@ With assert non-nil, errors out if the key does not exist already."
(remhash key data)))
keys))
+ (defmethod registry-full ((db registry-db))
+ "Checks if registry-db THIS is full."
+ (< (registry-size db)
+ (oref db :max-hard)))
+
(defmethod registry-insert ((db registry-db) key entry)
"Insert ENTRY under KEY into the registry-db THIS.
Updates the secondary ('tracked') indices as well.
@@ -269,8 +274,7 @@ Errors out if the key exists already."
(assert (not (gethash key (oref db :data))) nil
"Key already exists in database")
- (assert (< (registry-size db)
- (oref db :max-hard))
+ (assert (registry-full db)
nil
"registry max-hard size limit reached")
-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.
Summary of changes:
lisp/ChangeLog | 11 +++++++++++
lisp/gnus-registry.el | 18 +++++++++++++-----
lisp/registry.el | 8 ++++++--
3 files changed, 30 insertions(+), 7 deletions(-)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".
The branch, master has been updated
hooks/post-receive
--
Gnus Project