[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Normalise paths in dsvn on Windows

From: Mattias EngdegÄrd <mattias_at_virtutech.se>
Date: Sun, 6 Sep 2009 11:27:05 +0000 (UTC)

This patch makes dsvn track buffer changes on Windows correctly.
Please apply.

[[[
Translate backslashes to forward slashes, because that is what Emacs
uses internally even on Windows. This is essential for accurate path
comparisons in order to track changed files in the *svn* buffer
reliably.

* svn-normalise-path: New.
* svn-status-filter: Normalise slashes in path.
* svn-status-v-filter: Likewise.
* svn-update-filter: Likewise.
* svn-add-filter: Likewise.
* svn-move-filter: Likewise.
]]]

Index: contrib/client-side/emacs/dsvn.el
===================================================================
--- contrib/client-side/emacs/dsvn.el (revision 38971)
+++ contrib/client-side/emacs/dsvn.el (working copy)
@@ -1036,6 +1036,12 @@
           (svn-update-status-msg (point) "")
           (forward-line))))))
 
+;; Translate backslashes to forward slashes, because that is what
+;; Emacs uses internally even on Windows and it permits us to compare
+;; file name strings.
+(defun svn-normalise-path (path)
+ (replace-regexp-in-string "\\\\" "/" path t t))
+
 (defun svn-status-filter (proc str)
   (save-excursion
     (set-buffer (process-buffer proc))
@@ -1046,7 +1052,7 @@
       (while (cond ((looking-at
                      "\\([ ACDGIMRX?!~][ CM][ L][ +][ S][ KOTB]\\)[ C]? \\([^ ].*\\)\n")
                     (let ((status (match-string 1))
- (filename (match-string 2)))
+ (filename (svn-normalise-path (match-string 2))))
                       (delete-region (match-beginning 0)
                                      (match-end 0))
                       (svn-insert-file filename status))
@@ -1073,7 +1079,7 @@
       (while (looking-at
               "\\([ ACDGIMRX?!~][ CM][ L][ +][ S][ KOTB]\\)[ C]? \\([* ]\\) \\(........\\) \\(........\\) \\(............\\) \\([^ ].*\\)\n")
         (let ((status (match-string 1))
- (filename (match-string 6)))
+ (filename (svn-normalise-path (match-string 6))))
           (delete-region (match-beginning 0)
                          (match-end 0))
           (when (or (not svn-file-filter)
@@ -1172,7 +1178,7 @@
                (let* ((status (match-string 1))
                       (file-status (elt status 0))
                       (prop-status (elt status 1))
- (filename (match-string 2)))
+ (filename (svn-normalise-path (match-string 2))))
                  (delete-region (match-beginning 0)
                                 (match-end 0))
                  (svn-insert-file
@@ -1650,7 +1656,7 @@
               ;; What format is this, really?
               "\\([AD] \\)..... \\(.*\\)\n")
         (let ((status (concat (match-string 1) " "))
- (filename (match-string 2)))
+ (filename (svn-normalise-path (match-string 2))))
           (delete-region (match-beginning 0)
                          (match-end 0))
           (svn-insert-file filename status))))))
@@ -1796,7 +1802,7 @@
       (while (looking-at
               "\\([AD] \\) \\(.*\\)\n")
         (let ((status (match-string 1))
- (filename (match-string 2)))
+ (filename (svn-normalise-path (match-string 2))))
           (if (string= status "A ")
               (setq status "A + "))
           (delete-region (match-beginning 0)

Process svn finished

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2391448
Received on 2009-09-06 13:27:56 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.