From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: Reviewing versioned backups Date: Wed, 24 Mar 2021 11:47:41 +0300 Message-ID: References: <87a6qvat9v.fsf@posteo.net> <87v99i9j9u.fsf@posteo.net> <8335wm82ps.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34692"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.0.6 (2021-03-06) Cc: help-gnu-emacs@gnu.org To: Eli Zaretskii Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Mar 24 09:49:39 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lOzCt-0008wC-BK for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 24 Mar 2021 09:49:39 +0100 Original-Received: from localhost ([::1]:47486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOzCs-0003MM-86 for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 24 Mar 2021 04:49:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38638) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOzCA-0003KV-Ds for help-gnu-emacs@gnu.org; Wed, 24 Mar 2021 04:48:54 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:44711) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOzC8-0007tx-7e; Wed, 24 Mar 2021 04:48:53 -0400 Original-Received: from localhost ([::ffff:41.202.241.53]) (AUTH: PLAIN securesender, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 000000000001E0AB.00000000605AFCEF.000042F8; Wed, 24 Mar 2021 01:48:46 -0700 Mail-Followup-To: Eli Zaretskii , help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: <8335wm82ps.fsf@gnu.org> Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:128537 Archived-At: * Eli Zaretskii [2021-03-23 15:39]: > > From: Philip Kaludercic > > 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")