all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* avoiding revert-buffer after vc-checkin
@ 2007-07-18  5:47 Dan Nicolaescu
  2007-07-18 18:53 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Nicolaescu @ 2007-07-18  5:47 UTC (permalink / raw)
  To: emacs-devel


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.

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

end of thread, other threads:[~2007-07-19 21:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-18  5:47 avoiding revert-buffer after vc-checkin Dan Nicolaescu
2007-07-18 18:53 ` Stefan Monnier
2007-07-18 21:21   ` David Kastrup
2007-07-19  2:57     ` Stefan Monnier
2007-07-19 21:21   ` Richard Stallman

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.