Subject: bug#20558: 24.4; vc-revert on deleted file (git and svn should be more consistent)

From: Ed Avis <[email-masked]>
Date: Tue, 12 May 2015 15:13:44 +0000

Visit a file in a git or svn checkout.  Unknown to emacs, delete that
file.  Then do vc-revert to get back the original contents from version
control.

When vc-mode is used with a Subversion working copy, reverting a file
which has vanished on disk (but where the buffer is not marked as
modified) will just get a fresh copy and put it in the buffer.  That is
perhaps not ideal because it loses local changes.

When vc-mode is used with git, on reverting a file which no longer exists
on disk (where the buffer is not marked as modified), a diff is shown between the
empty file and the current contents in version control.  That is not a
particularly helpful diff to show the user.

If the file no longer exists on disk, then I suggest vc-revert
should act as follows:

- If the buffer is marked as modified, offer to save it, and after
  saving show diffs and prompt to revert as usual.

- If the buffer is not marked as modified, a diff should still be shown
  between the current buffer contents and what would be fetched from the
  version control system to replace it.  If that diff is empty, then
  just go ahead and revert.

Or alternatively, vc-revert should just automatically save-buffer first
if the underlying file no longer exists on disk.

In GNU Emacs 24.4.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.10.9)
 of 2014-11-03 on wcl-linux04.wcl.local
Configured using:
 `configure --build=x86_64-redhat-linux-gnu
 --host=x86_64-redhat-linux-gnu --program-prefix=
 --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr
 --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc
 --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64
 --libexecdir=/usr/libexec --localstatedir=/var
 --sharedstatedir=/var/lib --mandir=/usr/share/man
 --infodir=/usr/share/info --with-dbus --with-gif --with-jpeg --with-png
 --with-rsvg --with-tiff --with-xft --with-xpm --with-x-toolkit=gtk3
 --with-gpm=no build_alias=x86_64-redhat-linux-gnu
 host_alias=x86_64-redhat-linux-gnu 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g
 -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
 -fstack-protector-strong --param=ssp-buffer-size=4
 -grecord-gcc-switches -m64 -mtune=generic' 'LDFLAGS=-Wl,-z,relro ''

Important settings:
  value of $LC_COLLATE: C
  value of $LC_CTYPE: en_GB.UTF-8
  value of $LC_MESSAGES: en_GB.UTF-8
  value of $LC_MONETARY: en_GB.UTF-8
  value of $LC_NUMERIC: en_GB.UTF-8
  value of $LC_TIME: en_GB.UTF-8
  value of $LANG: en_GB.UTF-8
  locale-coding-system: utf-8-unix

Major mode: nXML

Minor modes in effect:
  diff-auto-refine-mode: t
  shell-dirtrack-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
e e C-n C-n C-p C-x e e C-n C-n C-p C-x e e e C-n C-x 
e C-n C-x e e e C-n C-n C-n C-n C-x e C-x v u y e s 
DEL DEL y e s RET C-f C-f C-f C-f C-f C-f C-f C-f C-f 
C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f 
C-f C-f C-f C-f C-d C-d C-d C-d C-d C-d C-d C-d C-d 
C-d C-a C-x C-s C-x v = C-x v v ESC p DEL DEL DEL DEL 
N Z . C-c C-c C-x o C-p C-p C-p C-p C-p C-p C-p C-p 
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p 
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p 
C-x e e e e C-n C-x e e e C-n C-n C-n C-p C-x e e C-n 
C-n C-x e e C-n C-x e e C-n C-x e e e C-n C-x e C-n 
C-x e e e C-n C-n C-n C-n C-x e C-n C-x e C-n C-x e 
C-n C-x e e e e e e e e C-a C-x C-s ESC ! ESC p RET 
C-x o q ESC < C-s m s c i l o c a l C-a ESC ! m v SPC 
b u TAB . TAB DEL b u TAB DEL . i n _ p r o g r e s 
s SPC v DEL - v i RET C-x v u C-g ESC x e w p DEL DEL 
DEL r e p C-g C-h k C-x v u C-x o C-x o ESC x r e DEL 
DEL e DEL r e p o r t SPC e m SPC a DEL b SPC RET

Recent messages:
(Type e to repeat macro) [26 times]
Saving file /home/eda/git_working/repos/wwwroot/WaniSystems/Configuration/MarketSampler/jobs/build.trend.signals.xml...
Wrote /home/eda/git_working/repos/wwwroot/WaniSystems/Configuration/MarketSampler/jobs/build.trend.signals.xml
(Shell command succeeded with no output)
Mark set
Mark saved where search started
'build.trend.signals.xml' -> 'build.trend.signals.xml.in_progress'
Finding changes in /home/eda/git_working/repos/wwwroot/WaniSystems/Configuration/MarketSampler/jobs/build.trend.signals.xml...
Quit [2 times]
Type C-x 1 to delete the help window.

Load-path shadows:
None found.

Features:
(shadow sort emacsbug sendmail eieio-opt speedbar sb-image ezimage
dframe find-func sgml-mode warnings dired-aux nroff-mode macros etags
pcmpl-gnu sh-script smie executable pcmpl-rpm mule-util ispell conf-mode
rect python json smerge-mode network-stream starttls tls sql view dired
mail-extr edmacro kmacro vc-bzr vc-sccs vc-svn vc-cvs vc-rcs tabify
imenu man pcmpl-x diff-mode log-view vc vc-dispatcher cus-edit wid-edit
cus-start cus-load perl-mode help-mode dabbrev misearch multi-isearch
vc-git nxml-uchnm rng-xsd xsd-regexp rng-cmpct rng-nxml rng-valid
rng-loc rng-uri rng-parse nxml-parse rng-match rng-dt rng-util rng-pttrn
nxml-ns nxml-mode nxml-outln nxml-rap nxml-util nxml-glyph nxml-enc
xmltok ffap thingatpt url-parse auth-source eieio eieio-core gnus-util
password-cache url-vars pcmpl-unix xterm time-date log-edit easy-mmode
message format-spec rfc822 mml mml-sec mm-decode mm-bodies mm-encode
mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mm-util mail-prsvr
mailabbrev mail-utils gmm-utils mailheader pcvs-util add-log server
csharp-mode advice help-fns byte-opt bytecomp byte-compile cconv
cc-langs cc-mode cc-fonts easymenu cc-guess cc-menus cc-cmds cc-styles
cc-align cc-engine cc-vars cc-defs zoom-frm frame-cmds frame-fns cl-macs
avoid cl gv cl-loaddefs cl-lib compile shell pcomplete comint ring
ansi-color tooltip electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment lisp-mode prog-mode register page menu-bar
rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax
facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak
czech european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer nadvice loaddefs button
faces cus-face macroexp files text-properties overlay sha1 md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind gfilenotify dynamic-setting
system-font-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty emacs)

Memory information:
((conses 16 2740808 222760)
 (symbols 48 31871 0)
 (miscs 40 1470 9493)
 (strings 32 94693 49984)
 (string-bytes 1 3524974)
 (vectors 16 44630)
 (vector-slots 8 1843880 104132)
 (floats 8 1680 1157)
 (intervals 56 396602 1450)
 (buffers 960 263)
 (heap 1024 118762 5547))

-- 
Ed Avis <[email-masked]>
Please ignore autogenerated disclaimer below this line.

This email is intended only for the person to whom it is addressed and may contain confidential information. Any retransmission, copying, disclosure or other use of, this information by persons other than the intended recipient is prohibited. If you received this email in error, please contact the sender and delete the material. This email is for information only and is not intended as an offer or solicitation for the purchase or sale of any financial instrument. Wadhwani Asset Management LLP is a Limited Liability Partnership registered in England (OC303168) with registered office at 40 Berkeley Square, 3rd Floor, London, W1J 5AL. It is authorised and regulated by the Financial Conduct Authority.