;ELC ;;; Compiled by proclus@darwintel on Tue Jan 1 13:53:26 2008 ;;; from file /mnt/gmirror/ports/databases/bbdb/work/bbdb-2.34/lisp/bbdb-migrate.el ;;; in Emacs version 21.2.1 ;;; with bytecomp version 1.1.1.4 ;;; with all optimizations. ;;; This file uses dynamic docstrings, first added in Emacs 19.29. (if (and (boundp 'emacs-version) (< (aref emacs-version (1- (length emacs-version))) ?A) (or (and (boundp 'epoch::version) epoch::version) (string-lessp emacs-version "19.29"))) (error "`bbdb-migrate.el' was compiled for Emacs 19.29 or later")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (byte-code "\302\303!\210\301B\304\302\207" [current-load-list bbdb-migration-features require bbdb ((3 . "* Date format for `creation-date' and `timestamp' has changed,\n from \"dd mmm yy\" (ex: 25 Sep 97) to \"yyyy-mm-dd\" (ex: 1997-09-25).") (4 . "* Country field added.") (5 . "* More flexible street address.") (6 . "* Zip codes are stored as plain strings."))] 2) #@160 Ask if the database is to be migrated. ONDISK is the version number of the database as currently stored on disk. Returns the version for the saved database. (defalias 'bbdb-migration-query #[(ondisk) "\212\306 \307\310!\311\312\211 q\210\313 \210eb\210\314\315\316\211#!\210\f\203^\f\211@@)V\203W\314 \203?\312\211\202@\317\320\315\321\f\211@@)\"\322\f\211@A)\260!\210\fA\211\204'\323 !\324\n!\210\325\326\315\321\"\327Q!\330\n!\210\331 !\210\332!\210 \203\207\202\211.\207" [bbdb-migration-features update win first newfeatures buf current-window-configuration get-buffer-create "*BBDB Migration Info*" t nil erase-buffer insert-string format "BBDB new data version notice:\n=============================\n\nYour BBDB data is stored in an older format (version %d). At this point,\nyou have the option of either upgrading or continuing to save your data\nin your current format. Please note that if you elect the latter option,\nany changes made to your data using features intended for the newer\nversions will be lost. For your convenience, a list of file format\nchanges introduced after version %d is shown below:\n\n" "\n\n" "New features in database version " "%d" ":\n\n" display-buffer shrink-window-if-larger-than-buffer y-or-n-p "Upgrade BBDB to version " "? " delete-window kill-buffer set-window-configuration wc ondisk x bbdb-file-format] 7 (#$ . 1016)]) #@133 Migrate the BBDB from the version on disk (the car of `bbdb-file-format-migration') to the current version (in `bbdb-file-format'). (defalias 'bbdb-migrate #[(records) "\302\303@! \"\210 \207" [bbdb-file-format-migration records mapc bbdb-migrate-versions-lambda] 3 (#$ . 2436)]) #@152 Reverse-migrate a single record from the current version (in `bbdb-file-format') to the version to be saved (the cdr of `bbdb-file-format-migration'). (defalias 'bbdb-unmigrate-record #[(record) "\303 @\"\n!\210\n\207" [bbdb-file-format bbdb-file-format-migration record bbdb-migrate-versions-lambda] 3 (#$ . 2724)]) #@93 The alist of (version . migration-spec-list). See `bbdb-migrate-record-lambda' for details. (defconst bbdb-migration-spec '((2 (bbdb-record-raw-notes bbdb-record-set-raw-notes bbdb-migrate-change-dates)) (3 (bbdb-record-addresses bbdb-record-set-addresses bbdb-migrate-add-country-field)) (4 (bbdb-record-addresses bbdb-record-set-addresses bbdb-migrate-streets-to-list)) (5 (bbdb-record-addresses bbdb-record-set-addresses bbdb-migrate-zip-codes-to-strings))) (#$ . 3048)) #@93 The alist of (version . migration-spec-list). See `bbdb-migrate-record-lambda' for details. (defconst bbdb-unmigration-spec '((2 (bbdb-record-raw-notes bbdb-record-set-raw-notes bbdb-unmigrate-change-dates)) (3 (bbdb-record-addresses bbdb-record-set-addresses bbdb-unmigrate-add-country-field)) (4 (bbdb-record-addresses bbdb-record-set-addresses bbdb-unmigrate-streets-to-list)) (5 (bbdb-record-addresses bbdb-record-set-addresses bbdb-unmigrate-zip-codes-to-strings))) (#$ . 3528)) #@381 Return a function which will migrate a single record. CHANGES is a `migration-spec-list' containing entries of the form (GET SET FUNCTION) where GET is the function to be used to retrieve the field to be modified, and SET is the function to be used to set the field to be modified. FUNCTION will be applied to the result of GET, and its results will be saved with SET. (defalias 'bbdb-migrate-record-lambda #[(changes) "\301\302\303\304\305\306\"\307\"BB!\207" [changes byte-compile lambda (rec) append mapcar #[(ch) "\211A@)\302\211AA)@@\303BDE\207" [ch x rec (rec)] 6] (rec)] 7 (#$ . 4019)]) #@82 Return the function to migrate from V0 to V1. V1 defaults to `bbdb-file-format'. (defalias 'bbdb-migrate-versions-lambda #[(v0 &optional v1) "\206 \n\306\211U\204+\307 \310\f \"A\"\nW\203$\fT\202&\fS\211\202 \311 !*\207" [v1 bbdb-file-format v0 spec vv bbdb-migration-spec nil append assoc bbdb-migrate-record-lambda] 6 (#$ . 4636)]) #@98 Make all zip codes plain strings. This uses the code that used to be in bbdb-address-zip-string. (defalias 'bbdb-migrate-zip-codes-to-strings #[(addrs) "\301\302\"\207" [addrs mapcar #[(addr) "\302H;\203 \302H\202\320\302H:\203\270\302H@;\203L\302HA@;\203L\303\304\302HA@\"\203>\302H@\305\302HA@Q\202\320\302H@\306\302HA@Q\202\320\302H@;\203\211\302HA@:\203\211\302HA@@\250\203\211\302HA@A@\250\203\211\307\310\302H@\302HA@@\302HA@A@$\202\320\302H@\250\203\251\302HA@\250\203\251\307\311\302H@\302HA@#\202\320\307\312\302H@\302HA@#\202\320\302H\313=\204\306\302H\204\312\314\202\320\307\315\302H\"\302 I\210)\207" [addr zip 4 string-match "^[0-9][0-9][0-9][0-9]" "-" " " format "%s-%d %d" "%05d-%04d" "%s-%d" 0 "" "%d"] 6]] 3 (#$ . 4990)]) #@113 Make zip code string into zip code datastructures. This uses the code that used to be in bbdb-parse-zip-string. (defalias 'bbdb-unmigrate-zip-codes-to-strings #[(addrs) "\301\302\"\207" [addrs mapcar #[(addr) "\303H\304\305 \"\203\306\202\204\304\307 \"\203\310 !\202\204\304\311 \"\2037\310 \312\224\312\225O!\310 \313\224\313\225O!D\202\204\304\314 \"\203N \312\224\312\225O \313\224\313\225OD\202\204\304\315 \"\203e \312\224\312\225O \313\224\313\225OD\202\204\304\316 \"\205\204 \312\224\312\225O\310 \313\224\313\225O!\310 \317\224\317\225O!DD\303\nI\210*\207" [addr string zip 4 string-match "^[ \n]*$" 0 "^[ \n]*[0-9][0-9]?[0-9]?[0-9]?[0-9]?[0-9]?[ \n]*$" string-to-int "^[ \n]*\\([0-9][0-9][0-9][0-9][0-9]\\)[ \n]*-?[ \n]*\\([0-9][0-9][0-9][0-9]?\\)[ \n]*$" 1 2 "^[ \n]*\\([A-Za-z0-9]+\\)[ \n]+\\([A-Za-z0-9]+\\)[ \n]*$" "^[ \n]*\\([A-Z]+\\)[ \n]*-?[ \n]*\\([0-9]+ ?[A-Z]*\\)[ \n]*$" "^[ \n]*\\([A-Z]+\\)[ \n]*-?[ \n]*\\([0-9]+\\)[ \n]+\\([0-9]+\\)[ \n]*$" 3] 6]] 3 (#$ . 5787)]) #@142 Change date formats in timestamp and creation-date fields from "dd mmm yy" to "yyyy-mm-dd". Assumes the notes are passed in as an argument. (defalias 'bbdb-migrate-change-dates #[(rec) "\301\302\"\210\207" [rec mapc #[(rr) "@\301>\205\n\302!\207" [rr (creation-date timestamp) bbdb-migrate-change-dates-change-field] 2]] 3 (#$ . 6821)]) #@77 Migrate the date field (the cdr of FIELD) from "dd mmm yy" to "yyyy-mm-dd". (defalias 'bbdb-migrate-change-dates-change-field #[(field) "A\304\305\n\306P!\211\307\232\203\210\305\n!\211\310\232\203\210\311\312\n\"\203S\313\314\315\316\n\"!\314\315\317\n\"!\314\315\320\n\"!#\321\322@A\323\324 \316H \"@\227! \317H \325H&\210\202\210\311\326\n\"\203\210\313\314\315\320\n\"!\314\315\316\n\"!\314\315\317\n\"!#\321\322@A\323\324 \316H \"@\227! \317H \325H&\210 \325H;\203\230 \325\314 \325H!I\210 \316H;\203\250 \316\314 \316H!I\210 \317H;\203\270 \317\314 \317H!I\210\325 \325HW\203\372\325 \316HW\203\372\327 \316HY\203\372\325 \317HW\203\372\330 \316H \325H\" \317HY\203\372\331\332 \325H \316H \317H$\241\210\202\377\333\334\n#*\207" [field parsed date timezone-months-assoc nil timezone-parse-date " 00:00:00" ["0" "0" "0" "0" nil] ["0" "0" "0" "0" nil] string-match "^\\([0-9]\\{4\\}\\)[-/]\\([ 0-9]?[0-9]\\)[-/]\\([ 0-9]?[0-9]\\)" vector string-to-int match-string 1 2 3 bbdb-warn "BBDB is treating %s field value %s as %s %d %d" upcase-initials rassoc 0 "^\\([ 0-9]?[0-9]\\)[-/]\\([ 0-9]?[0-9]\\)[-/]\\([0-9]\\{4\\}\\)" 12 timezone-last-day-of-month format "%04d-%02d-%02d" error "BBDB cannot parse %s header value %S for upgrade"] 8 (#$ . 7170)]) #@146 Change date formats is timestamp and creation-date fields from "yyyy-mm-dd" to "dd mmm yy". Assumes the notes list is passed in as an argument. (defalias 'bbdb-unmigrate-change-dates #[(rec) "\301\302\"\210\207" [rec mapc #[(rr) "@\301>\205\n\302!\207" [rr (creation-date timestamp) bbdb-unmigrate-change-dates-change-field] 2]] 3 (#$ . 8461)]) #@80 Unmigrate the date field (the cdr of FIELD) from "yyyy-mm-dd" to "yyyy-mm-dd". (defalias 'bbdb-unmigrate-change-dates-change-field #[(field) "@\301A\302\"B\207" [field bbdb-time-convert "%e %b %y"] 4 (#$ . 8818)]) #@58 Add a country field to each address in the address list. (defalias 'bbdb-migrate-add-country-field #[(addrl) "\301\302\"\207" [addrl mapcar #[(addr) "\301\302\"\207" [addr vconcat [""]] 3]] 3 (#$ . 9040)]) #@65 Remove the country field from each address in the address list. (defalias 'bbdb-unmigrate-add-country-field #[(addrl) "\301\302\"\207" [addrl mapcar #[(addr) "GS\304 \305\"\306\306 W\205\n  HI\210 T\211\202\f+\207" [addr len new-addr ii make-vector nil 0] 5]] 3 (#$ . 9254)]) #@32 Convert the streets to a list. (defalias 'bbdb-migrate-streets-to-list #[(addrl) "\301\302\"\207" [addrl mapcar #[(addr) "\301\302H\303\304\303\305\306H\307H\310HE\"\"\311H\312H\313H\314H&\207" [addr vector 0 delete nil "" 1 2 3 4 5 6 7] 10]] 3 (#$ . 9546)]) #@52 Convert the street list to the street[1-3] format. (defalias 'bbdb-unmigrate-streets-to-list #[(addrl) "\301\302\"\207" [addrl mapcar #[(addr) "\303H\304\305H @\206\306 A@\206\306\307\310 \211AA)\311#\312H\313H\314H\315H&)\207" [addr streets x 1 vector 0 "" mapconcat identity ", " 2 3 4 5] 11]] 3 (#$ . 9821)]) #@251 Rewrite each and every record in the bbdb file; this is necessary if we are updating an old file format. MESSAGE-P says whether to sound off for each record converted. If RECORDS is non-nil, its value will be used as the list of records to update. (defalias 'bbdb-migrate-rewrite-all #[(message-p &optional records) "\204\303 \304\205/\305@\306\"\210\n\203'\307\310 T\211@\304H@\311H$\210A\211\204 \306)\207" [records i message-p bbdb-records 0 bbdb-overwrite-record-internal nil message "Updating %d: %s %s" 1] 7 (#$ . 10154)]) (defalias 'bbdb-dry-heaves 'bbdb-migrate-rewrite-all) #@75 Change the `file-version' string from the OLD version to the NEW version. (defalias 'bbdb-migrate-update-file-version #[(old new) "eb\210\303\304\305\"\306\307#\203\310\304\311 \"!\207\312\304\313\n #!\207" [old new bbdb-file re-search-forward format "^;;; file-version: %d$" nil t replace-match ";;; file-version: %d" error "Can't find file-version string in %s buffer for v%d migration"] 5 (#$ . 10760)]) (provide 'bbdb-migrate)