help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reviewing versioned backups


From: Jean Louis
Subject: Re: Reviewing versioned backups
Date: Wed, 24 Mar 2021 11:47:41 +0300
User-agent: Mutt/2.0.6 (2021-03-06)

* 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 via email to

[Prev in Thread] Current Thread [Next in Thread]