all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Eli Zaretskii <eliz@gnu.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Reviewing versioned backups
Date: Wed, 24 Mar 2021 11:47:41 +0300	[thread overview]
Message-ID: <YFr8rd5wSieknf3Y@protected.localdomain> (raw)
In-Reply-To: <8335wm82ps.fsf@gnu.org>

* Eli Zaretskii <eliz@gnu.org> [2021-03-23 15:39]:
> > From: Philip Kaludercic <philipk@posteo.net>
> > Date: Tue, 23 Mar 2021 12:55:25 +0100
> > 
> > My goal would be to review the version history using C-x v l without
> > having to manually commit anything.
> 
> "C-x v l" doesn't work on backup files, only on VCS history.  It
> basically shows you the log of changes returned by a VCS backend, and
> there's no backend for backup files to create and return that
> history.

I am using database backed versioning, what would be the method or
approach to hook it into the standard Emacs versioning system?

Which minimum set of vc functions should I do that I can hook it into
the standard Emacs vc system?

CREATE TABLE vcfiles (
vcfiles_id SERIAL NOT NULL PRIMARY KEY,
vcfiles_datecreated TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
vcfiles_datemodified TIMESTAMP,
vcfiles_usercreated TEXT NOT NULL DEFAULT current_user,
vcfiles_usermodified TEXT NOT NULL DEFAULT current_user,
vcfiles_title TEXT NOT NULL,
vcfiles_description TEXT,
vcfiles_filename TEXT NOT NULL,
vcfiles_filebody TEXT NOT NULL,
vcfiles_revision TEXT
);

COMMENT ON TABLE vcfiles IS 'VC for Files';
COMMENT ON COLUMN vcfiles.vcfiles_id IS 'ID';
COMMENT ON COLUMN vcfiles.vcfiles_datecreated IS 'Date created';
COMMENT ON COLUMN vcfiles.vcfiles_datemodified IS 'Date modified';
COMMENT ON COLUMN vcfiles.vcfiles_usercreated IS 'User created';
COMMENT ON COLUMN vcfiles.vcfiles_usermodified IS 'User modified';
COMMENT ON COLUMN vcfiles.vcfiles_title IS 'Title';
COMMENT ON COLUMN vcfiles.vcfiles_description IS 'Description';
COMMENT ON COLUMN vcfiles.vcfiles_file IS 'File';
COMMENT ON COLUMN vcfiles.vcfiles_filebody IS 'File body';
COMMENT ON COLUMN vcfiles.vcfiles_revision IS 'Revision';

(defun vcfiles-insert-revision (filename title &optional description revision)
  (if (or (file-directory-p filename)
	  (not (file-exists-p filename))
	  (not (file-readable-p filename)))
      (message "Cannot read or access file: %s" filename)
    (let* ((file (expand-file-name filename))
	   (original-file file)
	   (file (sql-escape-string file))
	   (title (sql-escape-string title))
	   (description (if description
			    (sql-escape-string description)
			  "NULL"))
	   (revision (if revision
			 (sql-escape-string revision)
		       "NULL"))
	   (file-body (file-to-string original-file))
	   (file-body (sql-escape-string file-body))
	   (sql (format "INSERT INTO vcfiles (vcfiles_filename, vcfiles_title, vcfiles_description, vcfiles_filebody, vcfiles_revision) VALUES (%s, %s, %s, %s, %s) RETURNING vcfiles_id" file title description file-body revision)))
      (let ((id (rcd-sql-first sql *cf*)))
	(if id
	    (message "File revision ID: %s for %s recorded" id original-file)
	  (error "Could not record revision for: %s" original-file))))))

;; Example:

(vcfiles-insert-revision "~/new.scm" "new.scm testing the SQL version control")



  reply	other threads:[~2021-03-24  8:47 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22 19:21 Reviewing versioned backups Philip Kaludercic
2021-03-22 20:25 ` Jean Louis
2021-03-23  8:38   ` Eric S Fraga
2021-03-23  9:31     ` Jean Louis
2021-03-23  9:44       ` Eli Zaretskii
2021-03-23 10:19         ` Jean Louis
2021-03-23 11:12           ` Eli Zaretskii
2021-03-23 15:49             ` [External] : " Drew Adams
2021-03-23  9:56       ` Thibaut Verron
2021-03-23 11:55   ` Philip Kaludercic
2021-03-23 12:36     ` John Yates
2021-03-23 12:38     ` Eli Zaretskii
2021-03-24  8:47       ` Jean Louis [this message]
2021-03-24 11:05         ` Jean Louis
2021-03-24 16:53         ` Eli Zaretskii
2021-03-26  5:50 ` Robert Thorpe
2021-03-28  0:38 ` Michael Heerdegen
2021-03-28  9:23   ` Philip Kaludercic
2021-03-30  0:36     ` Michael Heerdegen
2021-03-30  9:29       ` Philip Kaludercic
2021-03-30  9:39         ` Eli Zaretskii
2021-03-30 10:03           ` Philip Kaludercic
2021-03-30 10:16         ` Jean Louis
2021-03-30 23:41         ` Michael Heerdegen
2021-03-31  1:56           ` Stefan Monnier
2021-03-31  6:24             ` Eli Zaretskii
2021-03-31 13:29 ` Philip Kaludercic
2021-03-31 14:00   ` Jean Louis
2021-04-01 15:52   ` Stefan Monnier
2021-04-01 19:44     ` Philip Kaludercic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YFr8rd5wSieknf3Y@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=eliz@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.