all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Reviewing versioned backups
@ 2021-03-22 19:21 Philip Kaludercic
  2021-03-22 20:25 ` Jean Louis
                   ` (3 more replies)
  0 siblings, 4 replies; 30+ messages in thread
From: Philip Kaludercic @ 2021-03-22 19:21 UTC (permalink / raw)
  To: help-gnu-emacs


Hey,

I have been using version-control for years now, but have always
wondered if there was a better way to review previous versions besides
just going into your backup directory and manually comparing them. Is
there maybe a vc backend that uses the backup information? Or has
someone written some code to make it easier that they would care to
share?

-- 
	Philip K.




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  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 11:55   ` Philip Kaludercic
  2021-03-26  5:50 ` Robert Thorpe
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 30+ messages in thread
From: Jean Louis @ 2021-03-22 20:25 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: help-gnu-emacs

* Philip Kaludercic <philipk@posteo.net> [2021-03-22 22:48]:
> Hey,
> 
> I have been using version-control for years now, but have always
> wondered if there was a better way to review previous versions besides
> just going into your backup directory and manually comparing them. Is
> there maybe a vc backend that uses the backup information? Or has
> someone written some code to make it easier that they would care to
> share?

I am using RCS and to review some previous version I do: `C-x v ~
VERSION-NUMBER` then I get full file visible in the buffer.

After that you can use `M-x diff-buffer RET` to see differences.

Doesn't the menu item Tools -> Version Control provide enough
functionality for you?

Jean



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  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 11:55   ` Philip Kaludercic
  1 sibling, 1 reply; 30+ messages in thread
From: Eric S Fraga @ 2021-03-23  8:38 UTC (permalink / raw)
  To: help-gnu-emacs

On Monday, 22 Mar 2021 at 23:25, Jean Louis wrote:
> I am using RCS and to review some previous version I do: `C-x v ~
> VERSION-NUMBER` then I get full file visible in the buffer.

I think the OP is using the simple backup file method built-in to Emacs,
not a version control system, i.e. that files are backed up using a
simple numbering scheme.

For the OP: As far as I know the only way to see differences is to
manually do a diff on them.  But ediff and emerge, for instance, are
very good.

-- 
Eric S Fraga via Emacs 28.0.50 & org 9.4.4 on Debian bullseye/sid




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  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  9:56       ` Thibaut Verron
  0 siblings, 2 replies; 30+ messages in thread
From: Jean Louis @ 2021-03-23  9:31 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: help-gnu-emacs

* Eric S Fraga <e.fraga@ucl.ac.uk> [2021-03-23 11:39]:
> On Monday, 22 Mar 2021 at 23:25, Jean Louis wrote:
> > I am using RCS and to review some previous version I do: `C-x v ~
> > VERSION-NUMBER` then I get full file visible in the buffer.
> 
> I think the OP is using the simple backup file method built-in to Emacs,
> not a version control system, i.e. that files are backed up using a
> simple numbering scheme.

How do you do that?

My variable `make-backup-file' is T. But that I think does only a copy
with ~ on the end.

How do you enable backup files with simple numbering scheme from
default? 

Of course it can be done with special customizations, but is there way
to do it with default variables in Emacs?

Jean



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  2021-03-23  9:31     ` Jean Louis
@ 2021-03-23  9:44       ` Eli Zaretskii
  2021-03-23 10:19         ` Jean Louis
  2021-03-23  9:56       ` Thibaut Verron
  1 sibling, 1 reply; 30+ messages in thread
From: Eli Zaretskii @ 2021-03-23  9:44 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Tue, 23 Mar 2021 12:31:10 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: help-gnu-emacs@gnu.org
> 
> * Eric S Fraga <e.fraga@ucl.ac.uk> [2021-03-23 11:39]:
> > On Monday, 22 Mar 2021 at 23:25, Jean Louis wrote:
> > > I am using RCS and to review some previous version I do: `C-x v ~
> > > VERSION-NUMBER` then I get full file visible in the buffer.
> > 
> > I think the OP is using the simple backup file method built-in to Emacs,
> > not a version control system, i.e. that files are backed up using a
> > simple numbering scheme.
> 
> How do you do that?
> 
> My variable `make-backup-file' is T. But that I think does only a copy
> with ~ on the end.
> 
> How do you enable backup files with simple numbering scheme from
> default? 

It's in the manual: see the node "Backup Names".



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  2021-03-23  9:31     ` Jean Louis
  2021-03-23  9:44       ` Eli Zaretskii
@ 2021-03-23  9:56       ` Thibaut Verron
  1 sibling, 0 replies; 30+ messages in thread
From: Thibaut Verron @ 2021-03-23  9:56 UTC (permalink / raw)
  To: Eric S Fraga, help-gnu-emacs

On 3/23/21 10:31 AM, Jean Louis wrote:
> * Eric S Fraga <e.fraga@ucl.ac.uk> [2021-03-23 11:39]:
>> On Monday, 22 Mar 2021 at 23:25, Jean Louis wrote:
>>> I am using RCS and to review some previous version I do: `C-x v ~
>>> VERSION-NUMBER` then I get full file visible in the buffer.
>> I think the OP is using the simple backup file method built-in to Emacs,
>> not a version control system, i.e. that files are backed up using a
>> simple numbering scheme.
> How do you do that?
>
> My variable `make-backup-file' is T. But that I think does only a copy
> with ~ on the end.
>
> How do you enable backup files with simple numbering scheme from
> default?
>
> Of course it can be done with special customizations, but is there way
> to do it with default variables in Emacs?

See: 
https://www.gnu.org/software/emacs/manual/html_node/elisp/Numbered-Backups.html

Maybe the docstring of make-backup-files could point to that 
possibility, to improve discoverability?

Thibaut




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  2021-03-23  9:44       ` Eli Zaretskii
@ 2021-03-23 10:19         ` Jean Louis
  2021-03-23 11:12           ` Eli Zaretskii
  0 siblings, 1 reply; 30+ messages in thread
From: Jean Louis @ 2021-03-23 10:19 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

* Eli Zaretskii <eliz@gnu.org> [2021-03-23 12:59]:
> > Date: Tue, 23 Mar 2021 12:31:10 +0300
> > From: Jean Louis <bugs@gnu.support>

> > How do you enable backup files with simple numbering scheme from
> > default? 
> 
> It's in the manual: see the node "Backup Names".

Thank you. I did not notice it as I was thinking that
`version-control' does not apply to some built-in backup methods. I do
need this feature so much as I used something similar before.




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  2021-03-23 10:19         ` Jean Louis
@ 2021-03-23 11:12           ` Eli Zaretskii
  2021-03-23 15:49             ` [External] : " Drew Adams
  0 siblings, 1 reply; 30+ messages in thread
From: Eli Zaretskii @ 2021-03-23 11:12 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Tue, 23 Mar 2021 13:19:05 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: help-gnu-emacs@gnu.org
> 
> * Eli Zaretskii <eliz@gnu.org> [2021-03-23 12:59]:
> > > Date: Tue, 23 Mar 2021 12:31:10 +0300
> > > From: Jean Louis <bugs@gnu.support>
> 
> > > How do you enable backup files with simple numbering scheme from
> > > default? 
> > 
> > It's in the manual: see the node "Backup Names".
> 
> Thank you. I did not notice it as I was thinking that
> `version-control' does not apply to some built-in backup methods.

You don't need to guess by the name, I didn't remember the name when I
started answering your question, I just remembered that an option to
do that was available.  What I did is this:

  C-h r
  i backup file RET

In the node which that displayed, I found this text:

     At your option, Emacs can keep either a single backup for each file,
  or make a series of numbered backup files for each file that you edit.
  *Note Backup Names::.

So I followed the cross-reference.

IOW, you are well advised to use the manual as a reference, with the
'i' command as the means to quickly find what you are looking for even
if you don't know its name.



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  2021-03-22 20:25 ` Jean Louis
  2021-03-23  8:38   ` Eric S Fraga
@ 2021-03-23 11:55   ` Philip Kaludercic
  2021-03-23 12:36     ` John Yates
  2021-03-23 12:38     ` Eli Zaretskii
  1 sibling, 2 replies; 30+ messages in thread
From: Philip Kaludercic @ 2021-03-23 11:55 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis <bugs@gnu.support> writes:

> * Philip Kaludercic <philipk@posteo.net> [2021-03-22 22:48]:
>> Hey,
>> 
>> I have been using version-control for years now, but have always
>> wondered if there was a better way to review previous versions besides
>> just going into your backup directory and manually comparing them. Is
>> there maybe a vc backend that uses the backup information? Or has
>> someone written some code to make it easier that they would care to
>> share?
>
> I am using RCS and to review some previous version I do: `C-x v ~
> VERSION-NUMBER` then I get full file visible in the buffer.

My first message was confusing, I mean the user option version-control
that generates numeric backups. My goal would be to review the version
history using C-x v l without having to manually commit anything.

-- 
	Philip K.



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  2021-03-23 11:55   ` Philip Kaludercic
@ 2021-03-23 12:36     ` John Yates
  2021-03-23 12:38     ` Eli Zaretskii
  1 sibling, 0 replies; 30+ messages in thread
From: John Yates @ 2021-03-23 12:36 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Help Gnu Emacs mailing list

Not sure if this helps.  I have a bostr package:

    https://github.com/jsyjr/bostr

which does a Backup On Save To Rcs.  It is a straight
ripoff from Benjamin Rutt's and Conor Nash's earlier
Backup Each Save:

    https://github.com/conornash/backup-each-save

An important bostr virtue is that it does not litter my
directories with rcs artifacts.  I would dearly loves a
vc analog of git-timemachine:

    https://github.com/emacsmirror/git-timemachine

Then, when sitting in a backed-up buffer, I could easily
scroll through the previous versions of that file.

/john

On Tue, Mar 23, 2021 at 7:55 AM Philip Kaludercic <philipk@posteo.net> wrote:
>
> Jean Louis <bugs@gnu.support> writes:
>
> > * Philip Kaludercic <philipk@posteo.net> [2021-03-22 22:48]:
> >> Hey,
> >>
> >> I have been using version-control for years now, but have always
> >> wondered if there was a better way to review previous versions besides
> >> just going into your backup directory and manually comparing them. Is
> >> there maybe a vc backend that uses the backup information? Or has
> >> someone written some code to make it easier that they would care to
> >> share?
> >
> > I am using RCS and to review some previous version I do: `C-x v ~
> > VERSION-NUMBER` then I get full file visible in the buffer.
>
> My first message was confusing, I mean the user option version-control
> that generates numeric backups. My goal would be to review the version
> history using C-x v l without having to manually commit anything.
>
> --
>         Philip K.
>


-- 
John Yates
505 Tremont St, #803
Boston, MA 02116



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  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
  1 sibling, 1 reply; 30+ messages in thread
From: Eli Zaretskii @ 2021-03-23 12:38 UTC (permalink / raw)
  To: help-gnu-emacs

> 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.



^ permalink raw reply	[flat|nested] 30+ messages in thread

* RE: [External] : Re: Reviewing versioned backups
  2021-03-23 11:12           ` Eli Zaretskii
@ 2021-03-23 15:49             ` Drew Adams
  0 siblings, 0 replies; 30+ messages in thread
From: Drew Adams @ 2021-03-23 15:49 UTC (permalink / raw)
  To: Eli Zaretskii, help-gnu-emacs@gnu.org

> You don't need to guess by the name, I didn't remember the name when I
> started answering your question, I just remembered that an option to
> do that was available.  What I did is this:
> 
>   C-h r
>   i backup file RET
> 
> In the node which that displayed, I found this text:
> 
>      At your option, Emacs can keep either a single backup for each file,
>   or make a series of numbered backup files for each file that you edit.
>   *Note Backup Names::.
> 
> So I followed the cross-reference.
> 
> IOW, you are well advised to use the manual as a reference, with the
> 'i' command as the means to quickly find what you are looking for even
> if you don't know its name.

+1



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  2021-03-23 12:38     ` Eli Zaretskii
@ 2021-03-24  8:47       ` Jean Louis
  2021-03-24 11:05         ` Jean Louis
  2021-03-24 16:53         ` Eli Zaretskii
  0 siblings, 2 replies; 30+ messages in thread
From: Jean Louis @ 2021-03-24  8:47 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

* 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")



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  2021-03-24  8:47       ` Jean Louis
@ 2021-03-24 11:05         ` Jean Louis
  2021-03-24 16:53         ` Eli Zaretskii
  1 sibling, 0 replies; 30+ messages in thread
From: Jean Louis @ 2021-03-24 11:05 UTC (permalink / raw)
  To: Eli Zaretskii, help-gnu-emacs

To add on the database backed backing of files or recording files as
specific revisions, for myself personally I find it handy for text
files and programming sources or letters. Database can be
automatically locally backed up, encrypted and remotely backed
up. Specific file revisions can be easily extracted, accessed, or
differentiated.

For now I work with functions below related to files. For database
entries it is automatic.

- C-r r - personal key binding to invoke `rcd-vc-revision' and
  inserting the revision into the database. This is similar as
  registration of a file in versioning system if the file was not
  there, otherwise new version is inserted. Nothing much to think
  about.

  Interesting is that if I delete the whole file, revisions are still
  there, even if I delete whole directory as database is
  separate. With a function in future, it could be possible to convert
  the revision system from a database into RCS or Git or some other
  system. But this way, personally, I need not have file based
  versioning system.

  Those `backup.~1~' files are useful, but not as handy to browse or
  review, I will switch that back to this database based backing up,
  it is revision system.

- C-x k - has the hook `rcd-vc-insert-revision-on-kill-buffer' which
  verifies if the file by its file path belonging to the buffer exists
  in the database or not, if it does exists, the file is automatically
  backed up, new revision by its ID is automatically creted -- I could
  as well add versioning of a buffer without file name

I am sure this can be implemented with SQLite for single user, but
when it is implemented with the database user could even have the
database online, or on remote computers and files would get backed
up. Reminders could be sent to associated people, and collaboration
and review of changes and review of files becomes available to a team
including available from any kind of devices, provided there is
software to fetch such entries.

(defvar rcd-vc-ask-for-revision t
  "Global decision to ask user for revision number or use
automatically assigned database ID numbers.")

(defun rcd-vc-insert-revision (filename title &optional description revision)
  "Insert the revised FILENAME with TITLE into the
database. Optional DESCRIPTION and REVISION may be provided."
  (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))))))

(defun rcd-vc-previous-revision (filename)
  "Returns previous available revision number if any by using
FILENAME."
  (let* ((filename (expand-file-name filename))
	 (filename (sql-escape-string filename))
	 (sql (format "SELECT vcfiles_revision FROM vcfiles WHERE vcfiles_filename = %s ORDER BY vcfiles_id DESC LIMIT 1" filename)))
    (rcd-sql-first sql *cf*)))

(defun rcd-vc-previous-revisions-exist-p (filename)
  "Returns T if previous revisions for FILENAME exist in the
`vcfiles' database table."
  (let* ((filename (expand-file-name filename))
	 (filename (sql-escape-string filename))
	 (sql (format "SELECT vcfiles_id FROM vcfiles WHERE vcfiles_filename = %s ORDER BY vcfiles_id DESC LIMIT 1" filename)))
    (rcd-sql-first sql *cf*)))

(defun rcd-vc-revision ()
  "Record RCD Version Control for the current file of the current
buffer into the database."
  (interactive)
  (when (buffer-modified-p)
    (when (y-or-n-p (format "Save %s?" (expand-file-name (buffer-file-name))))
      (save-buffer)))
  (let ((title (read-from-minibuffer "Title: "))
	(description (if (y-or-n-p "Edit description?")
			 (read-from-buffer "" (concat "Description of changes for: "
						      filename))
		       nil))
	(revision (when rcd-vc-ask-for-revision
		    (when (y-or-n-p "Enter revision designation?")
		      (read-from-minibuffer "Revision designation: " (rcd-vc-previous-revision filename)))))
	(filename (expand-file-name (buffer-file-name))))
    (rcd-vc-insert-revision filename title description revision)))
 
;; TODO if user enters revision same as one of previous, need to get a
;; warning that it is same

(defun rcd-vc-insert-revision-on-kill-buffer ()
  (when (buffer-file-name)
    (let* ((filename (expand-file-name (buffer-file-name)))
	   (timestamp (rcd-timestamp))
	   (title (concat "Automatic revision: " timestamp)))
      (when filename
	(when (rcd-vc-previous-revisions-exist-p filename)
	  (rcd-vc-insert-revision filename title))))))

;; This may be added to automatically insert revision on killing of
;; the buffer if the buffer file name already exists in the database.
;; (add-hook 'kill-buffer-hook 'rcd-vc-insert-revision-on-kill-buffer)




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  2021-03-24  8:47       ` Jean Louis
  2021-03-24 11:05         ` Jean Louis
@ 2021-03-24 16:53         ` Eli Zaretskii
  1 sibling, 0 replies; 30+ messages in thread
From: Eli Zaretskii @ 2021-03-24 16:53 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Wed, 24 Mar 2021 11:47:41 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: help-gnu-emacs@gnu.org
> 
> I am using database backed versioning, what would be the method or
> approach to hook it into the standard Emacs versioning system?

You will have to write a VC back-end, by implementing the relevant
operations that make sense for such a "version control".  See
vc-hooks.el and vc.el.

This discussion is better taken to emacs-devel, btw.



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  2021-03-22 19:21 Reviewing versioned backups Philip Kaludercic
  2021-03-22 20:25 ` Jean Louis
@ 2021-03-26  5:50 ` Robert Thorpe
  2021-03-28  0:38 ` Michael Heerdegen
  2021-03-31 13:29 ` Philip Kaludercic
  3 siblings, 0 replies; 30+ messages in thread
From: Robert Thorpe @ 2021-03-26  5:50 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: help-gnu-emacs

Philip Kaludercic <philipk@posteo.net> writes:

> Hey,
>
> I have been using version-control for years now, but have always
> wondered if there was a better way to review previous versions besides
> just going into your backup directory and manually comparing them. Is
> there maybe a vc backend that uses the backup information? Or has
> someone written some code to make it easier that they would care to
> share?

I seem to remember from Emacs Reddit that someone has written a mode to
do this.  I might be imagining it.  I suggest looking on MELPA and
Reddit.

BR,
Robert Thorpe




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  2021-03-22 19:21 Reviewing versioned backups Philip Kaludercic
  2021-03-22 20:25 ` Jean Louis
  2021-03-26  5:50 ` Robert Thorpe
@ 2021-03-28  0:38 ` Michael Heerdegen
  2021-03-28  9:23   ` Philip Kaludercic
  2021-03-31 13:29 ` Philip Kaludercic
  3 siblings, 1 reply; 30+ messages in thread
From: Michael Heerdegen @ 2021-03-28  0:38 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: help-gnu-emacs

Philip Kaludercic <philipk@posteo.net> writes:

> I have been using version-control for years now, but have always
> wondered if there was a better way to review previous versions besides
> just going into your backup directory and manually comparing them. Is
> there maybe a vc backend that uses the backup information? Or has
> someone written some code to make it easier that they would care to
> share?

Magit has the "wip" modes that do more or less exactly that if your VCS
is Git.  Once set up, backups are created automatically before and/or
after each save (or at will).  They are saved in a chain of commits
under a special reference name derived from your current branch's name.

Big advantage: Git handles backups and you can do all the cool things
like adding tags and annotations; Git can use delta compression to avoid
wasting disk space, and all of this stuff.  One disadvantage currently:
When you accidentally wip-commit something you didn't want to (e.g. a
very large file or something containing passwords), you currently need
to repair that accident using lowest-level git commands unless you can
live with resetting the whole history to a prior state.  But apart from
that, it works conveniently, there are log commands for your wip commits
and such things etc.

Michael.



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  2021-03-28  0:38 ` Michael Heerdegen
@ 2021-03-28  9:23   ` Philip Kaludercic
  2021-03-30  0:36     ` Michael Heerdegen
  0 siblings, 1 reply; 30+ messages in thread
From: Philip Kaludercic @ 2021-03-28  9:23 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: help-gnu-emacs

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Philip Kaludercic <philipk@posteo.net> writes:
>
>> I have been using version-control for years now, but have always
>> wondered if there was a better way to review previous versions besides
>> just going into your backup directory and manually comparing them. Is
>> there maybe a vc backend that uses the backup information? Or has
>> someone written some code to make it easier that they would care to
>> share?
>
> Magit has the "wip" modes that do more or less exactly that if your VCS
> is Git.  Once set up, backups are created automatically before and/or
> after each save (or at will).  They are saved in a chain of commits
> under a special reference name derived from your current branch's name.
>
> Big advantage: Git handles backups and you can do all the cool things
> like adding tags and annotations; Git can use delta compression to avoid
> wasting disk space, and all of this stuff.  One disadvantage currently:
> When you accidentally wip-commit something you didn't want to (e.g. a
> very large file or something containing passwords), you currently need
> to repair that accident using lowest-level git commands unless you can
> live with resetting the whole history to a prior state.  But apart from
> that, it works conveniently, there are log commands for your wip commits
> and such things etc.

This is interesting, but doesn't ~git~ fit my use-case, as I don't
always use Git as my VCS and I use a lot of unversioned files. But thank
you for the pointer, it might come in handy at some point in time!

-- 
	Philip K.



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  2021-03-28  9:23   ` Philip Kaludercic
@ 2021-03-30  0:36     ` Michael Heerdegen
  2021-03-30  9:29       ` Philip Kaludercic
  0 siblings, 1 reply; 30+ messages in thread
From: Michael Heerdegen @ 2021-03-30  0:36 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: help-gnu-emacs

Philip Kaludercic <philipk@posteo.net> writes:

> This is interesting, but doesn't ~git~ fit my use-case, as I don't
> always use Git as my VCS and I use a lot of unversioned files.

You could still use Git/Magit it but it would need some setup.  You
could, for example, instruct `backup-directory-alist' to assign backups
a special directory, make it a Git repository, and instruct Emacs to
commit each new backup automatically.

I guess you might be able to use VC instead of Magit and your VCS
instead of Git to get something similar.

Michael.



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  2021-03-30  0:36     ` Michael Heerdegen
@ 2021-03-30  9:29       ` Philip Kaludercic
  2021-03-30  9:39         ` Eli Zaretskii
                           ` (2 more replies)
  0 siblings, 3 replies; 30+ messages in thread
From: Philip Kaludercic @ 2021-03-30  9:29 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: help-gnu-emacs

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Philip Kaludercic <philipk@posteo.net> writes:
>
>> This is interesting, but doesn't ~git~ fit my use-case, as I don't
>> always use Git as my VCS and I use a lot of unversioned files.
>
> You could still use Git/Magit it but it would need some setup.  You
> could, for example, instruct `backup-directory-alist' to assign backups
> a special directory, make it a Git repository, and instruct Emacs to
> commit each new backup automatically.

But this wouldn't give me a direct overview of all backup versions, it
would just version the backups. What I am looking for is making use of
versioned backups, that can easily be reviewed. I was wondering for the
longest time why there is no interface for versioned backups.

> I guess you might be able to use VC instead of Magit and your VCS
> instead of Git to get something similar.
>
> Michael.

-- 
	Philip K.



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  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
  2 siblings, 1 reply; 30+ messages in thread
From: Eli Zaretskii @ 2021-03-30  9:39 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Philip Kaludercic <philipk@posteo.net>
> Date: Tue, 30 Mar 2021 11:29:04 +0200
> Cc: help-gnu-emacs@gnu.org
> 
> What I am looking for is making use of versioned backups, that can
> easily be reviewed. I was wondering for the longest time why there
> is no interface for versioned backups.

We have "M-x diff-backup", is that what you want?



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  2021-03-30  9:39         ` Eli Zaretskii
@ 2021-03-30 10:03           ` Philip Kaludercic
  0 siblings, 0 replies; 30+ messages in thread
From: Philip Kaludercic @ 2021-03-30 10:03 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Philip Kaludercic <philipk@posteo.net>
>> Date: Tue, 30 Mar 2021 11:29:04 +0200
>> Cc: help-gnu-emacs@gnu.org
>> 
>> What I am looking for is making use of versioned backups, that can
>> easily be reviewed. I was wondering for the longest time why there
>> is no interface for versioned backups.
>
> We have "M-x diff-backup", is that what you want?

I do use it, but it only uses the latest numerical backup. I think the
best solution to this would be to actually implement a VC backend, but
I'll have to look into how that can be done.

-- 
	Philip K.



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  2021-03-30  9:29       ` Philip Kaludercic
  2021-03-30  9:39         ` Eli Zaretskii
@ 2021-03-30 10:16         ` Jean Louis
  2021-03-30 23:41         ` Michael Heerdegen
  2 siblings, 0 replies; 30+ messages in thread
From: Jean Louis @ 2021-03-30 10:16 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Michael Heerdegen, help-gnu-emacs

* Philip Kaludercic <philipk@posteo.net> [2021-03-30 12:29]:
> Michael Heerdegen <michael_heerdegen@web.de> writes:
> 
> > Philip Kaludercic <philipk@posteo.net> writes:
> >
> >> This is interesting, but doesn't ~git~ fit my use-case, as I don't
> >> always use Git as my VCS and I use a lot of unversioned files.
> >
> > You could still use Git/Magit it but it would need some setup.  You
> > could, for example, instruct `backup-directory-alist' to assign backups
> > a special directory, make it a Git repository, and instruct Emacs to
> > commit each new backup automatically.
> 
> But this wouldn't give me a direct overview of all backup versions, it
> would just version the backups. What I am looking for is making use of
> versioned backups, that can easily be reviewed. I was wondering for the
> longest time why there is no interface for versioned backups.

Since you mentioned it, I had similar problem, but already had
database based backup system for database entries. Now I have extended
it that I can backup files, buffers and database entries in a single
database table. It is work in progress, not yet ready for public due
to few other files missing. But it can be done when I have time.

Emacs: RCD Version Control system with PostgreSQL backend
https://hyperscope.link/3/6/7/9/6/Emacs-RCD-Version-Control-system-with-PostgreSQL-backend-36796.html


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  2021-03-30  9:29       ` Philip Kaludercic
  2021-03-30  9:39         ` Eli Zaretskii
  2021-03-30 10:16         ` Jean Louis
@ 2021-03-30 23:41         ` Michael Heerdegen
  2021-03-31  1:56           ` Stefan Monnier
  2 siblings, 1 reply; 30+ messages in thread
From: Michael Heerdegen @ 2021-03-30 23:41 UTC (permalink / raw)
  To: help-gnu-emacs

Philip Kaludercic <philipk@posteo.net> writes:

> > You could still use Git/Magit it but it would need some setup.  You
> > could, for example, instruct `backup-directory-alist' to assign backups
> > a special directory, make it a Git repository, and instruct Emacs to
> > commit each new backup automatically.
>
> But this wouldn't give me a direct overview of all backup versions, it
> would just version the backups. What I am looking for is making use of
> versioned backups, that can easily be reviewed.

My idea was that you make Emacs automatically commit these backups after
creation (thus the separate directory, you can set it up as a separate
repository), and then use Magit or VC or whatever to view and diff.

> I was wondering for the longest time why there is no interface for
> versioned backups.

I once tried to live with versioned backups myself but I gave up because
it used too much space.  My .gnu-emacs is nearly 1 MByte, a thousand
saves are reached quickly, and you want to keep versions for a long
time.  After having used up several GBytes in a suprising short period
of time I chose a different approach.  IMO handling this with a VCS is
the better approach.


Regards,

Michael.




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  2021-03-30 23:41         ` Michael Heerdegen
@ 2021-03-31  1:56           ` Stefan Monnier
  2021-03-31  6:24             ` Eli Zaretskii
  0 siblings, 1 reply; 30+ messages in thread
From: Stefan Monnier @ 2021-03-31  1:56 UTC (permalink / raw)
  To: help-gnu-emacs

> I once tried to live with versioned backups myself but I gave up because
> it used too much space.  My .gnu-emacs is nearly 1 MByte, a thousand
> saves are reached quickly, and you want to keep versions for a long
> time.  After having used up several GBytes in a suprising short period
> of time I chose a different approach.  IMO handling this with a VCS is
> the better approach.

Agreed.  I suspect it would make sense to offer something akin to
Magit's `wip` using SRC.


        Stefan


PS: I personally find the behavior of versioned backups unsatisfactory
    also because of the granularity (too coarse for my taste).
    I'd probably want to create new revisions quite frequently (maybe
    not at every save, since I tend to do `C-x C-s` more often than
    needed, but maybe at every save with some grace period between
    revisions).




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  2021-03-31  1:56           ` Stefan Monnier
@ 2021-03-31  6:24             ` Eli Zaretskii
  0 siblings, 0 replies; 30+ messages in thread
From: Eli Zaretskii @ 2021-03-31  6:24 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Tue, 30 Mar 2021 21:56:48 -0400
> 
> > I once tried to live with versioned backups myself but I gave up because
> > it used too much space.  My .gnu-emacs is nearly 1 MByte, a thousand
> > saves are reached quickly, and you want to keep versions for a long
> > time.  After having used up several GBytes in a suprising short period
> > of time I chose a different approach.  IMO handling this with a VCS is
> > the better approach.
> 
> Agreed.  I suspect it would make sense to offer something akin to
> Magit's `wip` using SRC.

Not a very good idea, IMO, as SRC isn't portable enough.



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  2021-03-22 19:21 Reviewing versioned backups Philip Kaludercic
                   ` (2 preceding siblings ...)
  2021-03-28  0:38 ` Michael Heerdegen
@ 2021-03-31 13:29 ` Philip Kaludercic
  2021-03-31 14:00   ` Jean Louis
  2021-04-01 15:52   ` Stefan Monnier
  3 siblings, 2 replies; 30+ messages in thread
From: Philip Kaludercic @ 2021-03-31 13:29 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 664 bytes --]

Philip Kaludercic <philipk@posteo.net> writes:

> Hey,
>
> I have been using version-control for years now, but have always
> wondered if there was a better way to review previous versions besides
> just going into your backup directory and manually comparing them. Is
> there maybe a vc backend that uses the backup information? Or has
> someone written some code to make it easier that they would care to
> share?

I sat down and wrote a sketch for a VC backend that uses version
backups. Find it attached to this message. It's not that mature yet, but
it does the basics. Would there be any interest to add this to Emacs or
as an ELPA package?

-- 
	Philip K.


[-- Attachment #2: vc-backup.el --]
[-- Type: application/emacs-lisp, Size: 8387 bytes --]

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  2021-03-31 13:29 ` Philip Kaludercic
@ 2021-03-31 14:00   ` Jean Louis
  2021-04-01 15:52   ` Stefan Monnier
  1 sibling, 0 replies; 30+ messages in thread
From: Jean Louis @ 2021-03-31 14:00 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: help-gnu-emacs

* Philip Kaludercic <philipk@posteo.net> [2021-03-31 16:30]:
> Philip Kaludercic <philipk@posteo.net> writes:
> 
> > Hey,
> >
> > I have been using version-control for years now, but have always
> > wondered if there was a better way to review previous versions besides
> > just going into your backup directory and manually comparing them. Is
> > there maybe a vc backend that uses the backup information? Or has
> > someone written some code to make it easier that they would care to
> > share?
> 
> I sat down and wrote a sketch for a VC backend that uses version
> backups. Find it attached to this message. It's not that mature yet, but
> it does the basics. Would there be any interest to add this to Emacs or
> as an ELPA package?

I think it is great idea. Go ahead.

Back in time I was making such backups all the time, then due to
changes of configurations and $HOME directories, somehow it got lost,
then I used various version control systems, and finally RCS which I
find one of best for personal version control.

Post your packages, that we can test it.

I am currently using the database backed automated version control
with diff and expansion into files when necessary. I find it very
handy as personal and collaborative tool. I will come soon in
situation to solve merging issues.

That way my version control is out of the file system and if any file
moves anywhere else, it is matter of a second to update its full path.

But if the file moves from one place to other, then I would need to
find it in the database by using similarity function.

I need tool to compare similarity between files. PostgreSQL can do
that, but maybe there is some GNU/Linux tool. I found references to
Spacy (Python) and will look into it.

In PostgreSQL it seems easy to solve similarity by using pg_tgrm
module: https://www.postgresql.org/docs/current/pgtrgm.html

Then query like this:

SELECT vc_id, similarity((SELECT vc_value FROM vc WHERE vc_id = 6514), vc_value) FROM vc WHERE vc_filename ~ '/emacs-lisp/rcd-devel-utilities.el';

gives result like this

 vc_id | similarity 
-------+------------
  6514 |          1
  6486 |  0.9906323
  6507 |  0.9911007
  6508 |  0.9911007
  6509 |  0.9911007
  6550 |  0.9842665
  6611 |  0.9842665
(7 rows)

Maybe there is some similar GNU/Linux tool on command line? I would
like to know if there is some tool that may compare text to text to be
similar?


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  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
  1 sibling, 1 reply; 30+ messages in thread
From: Stefan Monnier @ 2021-04-01 15:52 UTC (permalink / raw)
  To: help-gnu-emacs

> I sat down and wrote a sketch for a VC backend that uses version
> backups.

Looking good.

> Find it attached to this message. It's not that mature yet, but
> it does the basics.

Including the font-locked log seems to go a bit beyond the basics ;-)

> Would there be any interest to add this to Emacs or
> as an ELPA package?

GNU ELPA sounds like a good place for it.


        Stefan




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Reviewing versioned backups
  2021-04-01 15:52   ` Stefan Monnier
@ 2021-04-01 19:44     ` Philip Kaludercic
  0 siblings, 0 replies; 30+ messages in thread
From: Philip Kaludercic @ 2021-04-01 19:44 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> Would there be any interest to add this to Emacs or
>> as an ELPA package?
>
> GNU ELPA sounds like a good place for it.

Ok, I'll try to clean it up then.

-- 
	Philip K.



^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2021-04-01 19:44 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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.