[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dtache c8a99aed35 123/158: Add version to the dtache da
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dtache c8a99aed35 123/158: Add version to the dtache database |
Date: |
Wed, 19 Jan 2022 18:58:04 -0500 (EST) |
branch: externals/dtache
commit c8a99aed35f3dc744fd9d3c9d1357a6b75946161
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>
Add version to the dtache database
This patch adds a header to the dtache.db file. This header allows
dtache to read the dtache-session version of the sessions stored in
the database.
If the version is not matching the databasee content is
discarded. The version should be increase when an update has been made
to the dtache-session object, which breaks backwards compatibility.
---
CHANELOG.org | 1 +
dtache.el | 21 ++++++++++++++++++---
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/CHANELOG.org b/CHANELOG.org
index 88e100b015..955f392015 100644
--- a/CHANELOG.org
+++ b/CHANELOG.org
@@ -4,6 +4,7 @@
* Development
+- Add version for =dtache-session= objects. This makes dtache not break
whenever non-backwards compatible changes are made to the dtache-session object.
- The commands for launching sessions are now renamed to resemble the non
dtache commands. The commands are =dtache-shell-command=,
=dtache-shell-send-input=, =dtache-eshell-send-input=, =dtache-compile=.
- Add action value to a session. This value is set to dtache-session-action
which is a property list optionally specifying attach, view and run properties.
These properties are then used in dwim commands to improve their functionality.
- Add a generic detach command, =dtache-detach-dwim=. This command is supposed
to be used to detach from sessions in all supported modes.
diff --git a/dtache.el b/dtache.el
index 15bbf3b73a..8f14c00054 100644
--- a/dtache.el
+++ b/dtache.el
@@ -143,6 +143,9 @@ Valid values are: create, new and attach")
(defvar dtache-metadata-annotators-alist nil
"An alist of annotators for metadata.")
+(defconst dtache-session-version 1
+ "The version of `dtache-session'.")
+
(defvar dtache-action-map
(let ((map (make-sparse-keymap)))
(define-key map "c" #'dtache-post-compile-session)
@@ -941,13 +944,24 @@ Optionally make the path LOCAL to host."
(defun dtache--db-initialize ()
"Return all sessions stored in database."
- (let ((db (expand-file-name "dtache.db" dtache-db-directory)))
+ (let ((db (expand-file-name "dtache.db" dtache-db-directory))
+ (session-version))
(when (file-exists-p db)
(with-temp-buffer
(insert-file-contents db)
(cl-assert (eq (point) (point-min)))
- (setq dtache--sessions
- (read (current-buffer)))))))
+ (goto-char (point-min))
+ (when (= (dtache--db-session-version) dtache-session-version)
+ (setq dtache--sessions
+ (read (current-buffer))))))))
+
+(defun dtache--db-session-version ()
+ "Return `dtache-session-version' from database."
+ (let ((header (thing-at-point 'line))
+ (regexp (rx "Dtache Session Version: " (group (one-or-more digit)))))
+ (string-match regexp header)
+ (string-to-number
+ (match-string 1 header))))
(defun dtache--db-insert-entry (session)
"Insert SESSION into `dtache--sessions' and update database."
@@ -981,6 +995,7 @@ Optionally make the path LOCAL to host."
"Write `dtache--sessions' to database."
(let ((db (expand-file-name "dtache.db" dtache-db-directory)))
(with-temp-file db
+ (insert (format ";; Dtache Session Version: %d\n\n"
dtache-session-version))
(prin1 dtache--sessions (current-buffer)))))
;;;;; Other
- [elpa] externals/dtache 2e5a097da4 080/158: Implement dtache-compile-open, (continued)
- [elpa] externals/dtache 2e5a097da4 080/158: Implement dtache-compile-open, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache c09328ca1e 081/158: Add actions to a session, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 82e5859d5a 098/158: Improve dtache-detach-session, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache f73aa7ef98 089/158: Cleanup dtache-shell, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 71966f0d2f 099/158: Add run as an action property, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 5831137cf7 101/158: Rename dtache-initialize to dtache-setup, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 9746f4713c 106/158: Rename session-directory to log-directory, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache c6aece77d2 113/158: Enhance dtache-detach-dwim command, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache bf71be0eae 118/158: Change output-size to log-size, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache f77c57f608 120/158: Update duration part 2, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache c8a99aed35 123/158: Add version to the dtache database,
ELPA Syncer <=
- [elpa] externals/dtache 4fa1c9e8a2 134/158: Simplify call to dtache--dtach-arg, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 3942dc6326 135/158: Remove unnecessary checks for dtache-session-mode, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 3aa5babca5 139/158: Update table formatting, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache ee8f3efa26 144/158: Version 0.3, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache d0ec7b9777 156/158: Add support for filenotify on macOS, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache aca73c1e60 152/158: Address issues from melpazoid in melpa/melpa7867, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 81d7fbcdca 082/158: Integrate dtache with start-process, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 125f100b20 087/158: Regroup variable section, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 5f12c82fed 090/158: Revert back dtache-eshell, ELPA Syncer, 2022/01/19
- [elpa] externals/dtache 914daabbb8 092/158: Fix regression for shell-command and compile, ELPA Syncer, 2022/01/19