emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r104176: registry.el (registry-full):


From: Katsumi Yamaoka
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r104176: registry.el (registry-full): Add convenience method. Fix logic.
Date: Mon, 09 May 2011 22:27:17 +0000
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 104176
author: Teodor Zlatanov <address@hidden>
committer: Katsumi Yamaoka <address@hidden>
branch nick: trunk
timestamp: Mon 2011-05-09 22:27:17 +0000
message:
  registry.el (registry-full): Add convenience method.  Fix logic.
   (registry-insert): Use it.  Fix logic here too.
  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.
modified:
  lisp/gnus/ChangeLog
  lisp/gnus/gnus-registry.el
  lisp/gnus/registry.el
=== modified file 'lisp/gnus/ChangeLog'
--- a/lisp/gnus/ChangeLog       2011-05-09 19:41:14 +0000
+++ b/lisp/gnus/ChangeLog       2011-05-09 22:27:17 +0000
@@ -2,6 +2,17 @@
 
        * nntp.el (nntp-open-connection): Set TCP keepalive option.
 
+2011-05-09  Teodor Zlatanov  <address@hidden>
+
+       * registry.el (registry-full): Add convenience method.  Fix logic.
+       (registry-insert): Use it.  Fix logic here too.
+
+       * 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  <address@hidden>
 
        * shr.el (shr-link): Make shr-link inherit from link by default.

=== modified file 'lisp/gnus/gnus-registry.el'
--- a/lisp/gnus/gnus-registry.el        2011-04-25 04:32:07 +0000
+++ b/lisp/gnus/gnus-registry.el        2011-05-09 22:27:17 +0000
@@ -383,7 +383,7 @@
     (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,8 +962,8 @@
          (entries (registry-lookup db (list id))))
 
     (when (null entries)
-      (registry-insert db id (list (list 'creation-time (current-time))
-                                   '(group) '(sender) '(subject)))
+      (gnus-registry-insert db id (list (list 'creation-time (current-time))
+                                        '(group) '(sender) '(subject)))
       (setq entries (registry-lookup db (list id))))
 
     (nth 1 (assoc id entries))))
@@ -979,9 +979,17 @@
          (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 @@
     (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)

=== modified file 'lisp/gnus/registry.el'
--- a/lisp/gnus/registry.el     2011-05-04 11:28:46 +0000
+++ b/lisp/gnus/registry.el     2011-05-09 22:27:17 +0000
@@ -261,6 +261,11 @@
          (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 @@
     (assert (not (gethash key (oref db :data))) nil
            "Key already exists in database")
 
-    (assert (< (registry-size db)
-              (oref db :max-hard))
+    (assert (not (registry-full db))
            nil
            "registry max-hard size limit reached")
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]