emacs-devel
[Top][All Lists]
Advanced

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

avoiding revert-buffer after vc-checkin


From: Dan Nicolaescu
Subject: avoiding revert-buffer after vc-checkin
Date: Tue, 17 Jul 2007 22:47:56 -0700

After a vc-checkin the corresponding buffer is reverted, which is not
so convenient because the undo information is lost. 

One way to avoid the revert is to check if the buffer and the file on
disk are identical. One way to do that is to compare the md5
checksums.

I wrote a patch that does that almost a year ago, I never fully
verified it if it works correctly, and I don't think I'll touch it
again anytime soon. So I thought I'd throw it over the fence and maybe
it will inspire someone to pick it up and solve this problem
properly. Pretty please :-)

Index: vc.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc.el,v
retrieving revision 1.433
diff -c -3 -p -c -r1.433 vc.el
*** vc.el       17 Jul 2007 04:47:57 -0000      1.433
--- vc.el       18 Jul 2007 05:10:40 -0000
*** 1530,1536 ****
    (and (string= buffer-file-name file)
         (if keep
           (progn
!            (vc-revert-buffer1 t noquery)
               ;; TODO: Adjusting view mode might no longer be necessary
               ;; after RMS change to files.el of 1999-08-08.  Investigate
               ;; this when we install the new VC.
--- 1530,1542 ----
    (and (string= buffer-file-name file)
         (if keep
           (progn
!            (if (string=
!                 (substring (shell-command-to-string 
!                             (concat "md5sum " (expand-file-namefile))) 0 32)
!                 (md5 (current-buffer)))
!                (message "not reverting")
!              (message "reverting :-(")
!              (vc-revert-buffer1 t noquery))
               ;; TODO: Adjusting view mode might no longer be necessary
               ;; after RMS change to files.el of 1999-08-08.  Investigate
               ;; this when we install the new VC.


The reason the md5sum command is used is because `md5' cannot take a
file argument.




reply via email to

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