Hello again! It appears that the contributed Emacs Subversion management mode psvn.el does not handle file EOL encodings well when retrieving old file revisions from the repository. The attached patch tries to fix some problems in this code.
Suppose you have a file foo in a repository which contains CRLF style line endings and does _not_ have the svn:eol-style property set. When checking out a working copy and opening the file, Emacs will automatically switch the coding system to something ending in "-dos" becasue it finds these line ending marks. When using psvn.el to retrieve a specific revision (say, PREV) of the file from the repository (by calling svn-status-get-specific-revision, usually bound to ~ in svn-status mode), the opened buffer does not show the contents correctly. It is downloaded and saved as stored in the repository, by using a call to "svn cat foo". However, the buffer displaying the downloaded file foo.~PREV~ shows all the CR line endings as ^M characters. Closing and re-opening the file fixes this. Emacs does not automatically detect the EOL coding style of the content when psvn.el displays the downloaded revision buffer. This is especially annoying when using ediff to compare to an older revision from within svn-status mode. All lines will have differences because of the different line endings. The attached patch fixes this by calling detect-coding-string on the buffer content and then sets the detected value for saving the file later, thus preserving the actual content. I tested it on GNU Emacs 23.3.1 on Ubuntu and 24.1 on Windows. Please consider committing this to the contrib tree in trunk. If there are any open questions, please don't hesitate to reply. Regards André -- Greetings... From: Andre Colomb <acol...@schickhardt.org>
Index: contrib/client-side/emacs/psvn.el =================================================================== --- contrib/client-side/emacs/psvn.el (revision 1377692) +++ contrib/client-side/emacs/psvn.el (working copy) @@ -4584,11 +4584,15 @@ names are relative to the directory where `svn-sta (find-file file-name-with-revision) (setq buffer-read-only nil) (erase-buffer) ;Widen, because we'll save the whole buffer. - (insert content) - (goto-char (point-min)) - (let ((write-file-functions nil) - (require-final-newline nil)) - (save-buffer)))) + (let ((content-coding (detect-coding-string content t))) + ;; Decode byte content to buffer representation, just like find-file would + (insert (decode-coding-string content content-coding)) + (goto-char (point-min)) + (let ((write-file-functions nil) + (require-final-newline nil)) + (when (fboundp 'set-buffer-file-coding-system) + (set-buffer-file-coding-system content-coding nil)) + (save-buffer))))) (find-file file-name-with-revision))))) ;;(message "default-directory: %s revision-file-info: %S" default-directory svn-status-get-specific-revision-file-info) (nreverse svn-status-get-specific-revision-file-info)))
signature.asc
Description: OpenPGP digital signature