registry.el and gnus-registry.el ERT compatibility fixes, proto-stream.el commit...
authorTed Zlatanov <tzz@lifelogs.com>
Wed, 6 Apr 2011 10:52:28 +0000 (05:52 -0500)
committerTed Zlatanov <tzz@lifelogs.com>
Wed, 6 Apr 2011 10:52:28 +0000 (05:52 -0500)
* proto-stream.el (gnutls-negotiate): Revert inadvertent commit of the
version from the Claudio Bley GnuTLS patch (extra optional parameters
and host name).

* registry.el: Don't use ERT if it's not available.

* gnus-registry.el: Don't use ERT if it's not available.
(gnus-registry-delete-entries): New convenience function.
(gnus-registry-import-eld): Import from old .eld registry.

lisp/ChangeLog
lisp/gnus-registry.el
lisp/proto-stream.el
lisp/registry.el

index 51a8ef3..36e5b8b 100644 (file)
@@ -1,3 +1,15 @@
+2011-04-06  Teodor Zlatanov  <tzz@lifelogs.com>
+
+       * gnus-registry.el: Don't use ERT if it's not available.
+       (gnus-registry-delete-entries): New convenience function.
+       (gnus-registry-import-eld): Import from old .eld registry.
+
+       * registry.el: Don't use ERT if it's not available.
+
+       * proto-stream.el (gnutls-negotiate): Revert inadvertent commit of the
+       version from the Claudio Bley GnuTLS patch (extra optional parameters
+       and host name).
+
 2011-04-05  Teodor Zlatanov  <tzz@lifelogs.com>
 
        * gnus-registry.el (gnus-registry-fixup-registry): New function to
index 3ab8400..511012d 100644 (file)
 
 (eval-when-compile (require 'cl))
 
-(require 'ert)
+(eval-when-compile
+  (when (null (require 'ert nil t))
+    (defmacro* ert-deftest (name () &body docstring-keys-and-body))))
+
 (require 'gnus)
 (require 'gnus-int)
 (require 'gnus-sum)
@@ -807,6 +810,9 @@ only the last one's marks are returned."
 
     (nth 1 (assoc id entries))))
 
+(defun gnus-registry-delete-entries (idlist)
+  (registry-delete gnus-registry-db idlist nil))
+
 (defun gnus-registry-get-id-key (id key)
   (cdr-safe (assq key (gnus-registry-get-or-make-entry id))))
 
@@ -818,6 +824,51 @@ only the last one's marks are returned."
     (registry-insert db id entry)
     entry))
 
+(defun gnus-registry-import-eld (file)
+  (interactive "fOld registry file to import? ")
+  ;; example content:
+  ;;   (setq gnus-registry-alist '(
+  ;; ("<messageID>" ((marks nil)
+  ;;                 (mtime 19365 1776 440496)
+  ;;                 (sender . "root (Cron Daemon)")
+  ;;                 (subject . "Cron"))
+  ;;  "cron" "nnml+private:cron")
+  (load file t)
+  (when (boundp 'gnus-registry-alist)
+    (let* ((old (symbol-value 'gnus-registry-alist))
+           (count 0)
+           (expected (length old))
+           entry)
+      (while (car-safe old)
+        (incf count)
+        ;; don't use progress reporters for backwards compatibility
+        (when (and (< 0 expected)
+                   (= 0 (mod count 100)))
+          (message "importing: %d of %d (%.2f%%)"
+                   count expected (/ (* 100 count) expected)))
+        (setq entry (car-safe old)
+              old (cdr-safe old))
+        (let* ((id (car-safe entry))
+               (new-entry (gnus-registry-get-or-make-entry id))
+               (rest (cdr-safe entry))
+               (groups (loop for p in rest
+                             when (stringp p)
+                             collect p))
+               extra-cell key val)
+          ;; remove all the strings from the entry
+          (delete* nil rest :test (lambda (a b) (stringp b)))
+          (gnus-registry-set-id-key id 'group groups)
+          ;; just use the first extra element
+          (setq rest (car-safe rest))
+          (while (car-safe rest)
+            (setq extra-cell (car-safe rest)
+                  key (car-safe extra-cell)
+                  val (cdr-safe extra-cell)
+                  rest (cdr-safe rest))
+            (when (and val (atom val))
+              (setq val (list val)))
+            (gnus-registry-set-id-key id key val))))
+      (message "Import done, collected %d entries" count))))
 
 (ert-deftest gnus-registry-usage-test ()
   (let* ((n 100)
index f4d438d..45cc974 100644 (file)
@@ -52,8 +52,7 @@
 (require 'starttls)
 
 (declare-function gnutls-negotiate "gnutls"
-                  (proc type host &optional priority-string trustfiles keyfiles
-                        verify-flags verify-error verify-hostname-error))
+                 (proc type &optional priority-string trustfiles keyfiles))
 
 ;;;###autoload
 (defun open-protocol-stream (name buffer host service &rest parameters)
@@ -185,7 +184,7 @@ PARAMETERS should be a sequence of keywords and values:
                          (proto-stream-command stream starttls-command eoc))
        ;; The server said it was OK to begin STARTTLS negotiations.
        (if (fboundp 'open-gnutls-stream)
-           (gnutls-negotiate stream nil host)
+           (gnutls-negotiate stream nil)
          (unless (starttls-negotiate stream)
            (delete-process stream)))
        (if (memq (process-status stream) '(open run))
index 319da8f..cc03b20 100644 (file)
 
 ;;; Code:
 
-(eval-when-compile (require 'ert))
+(eval-when-compile
+  (when (null (require 'ert nil t))
+    (defmacro* ert-deftest (name () &body docstring-keys-and-body))))
+
 (eval-when-compile (require 'cl))
 (eval-and-compile
   (or (ignore-errors (progn