Subject: bug#3298: vc-revert-buffer sets file time-stamp into the past.

From: Sergei Organov <[email-masked]>
Date: Fri, 15 May 2009 22:43:18 +0400

Hello,

When I have a file under version control (CVS), make some changes to the
file, save it, and then call vc-revert-buffer (bound to C-x v u), the
resulting reverted file has time-stamp in the past. To see the problem
one needs to wait a little after checking out the file(s) before
modifying/saving the testing file, because it's at this moment the
backup of the file is being created with the time-stamp of initial file,
and it's that backup file will later be copied to create reverted file.

That's how it goes:

Before change/save:

file.cc (old time)

After change/save:

file.cc (new time)
file.cc.~1.3~ (old time)

After revert:

file.cc (old time)

This badly affects make, is inconsistent with the way revert is
performed by PCL-CVS, and is inconsistent with manual revert of a file
using CVS command-line:

$ rm FILE; cvs update FILE

The offending code is in the "vc.el" `vc-revert-file' function:

       (copy-file backup-file file 'ok-if-already-exists 'keep-date)

It's `keep-date' that leads to the old time-stamp being assigned to the
reverted file.

In GNU Emacs 22.2.1 (i486-pc-linux-gnu, GTK+ Version 2.12.11)
 of 2008-11-10 on raven, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.10402000
configured using `configure  '--build=i486-linux-gnu' '--host=i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs22:/etc/emacs:/usr/local/share/emacs/22.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/22.2/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/22.2/leim' '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g' 'CPPFLAGS=''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8
  default-enable-multibyte-characters: t