• R/O
  • SSH
  • HTTPS

fsvn: 提交


Commit MetaInfo

修訂323 (tree)
時間2015-11-10 19:00:53
作者mhayashi1120

Log Message

improve mainly for cygwin svn 1.9.x
some doc fix

Change Summary

差異

--- trunk/fsvn-deps.el (revision 322)
+++ trunk/fsvn-deps.el (revision 323)
@@ -328,6 +328,28 @@
328328
329329
330330
331+(defun fsvn-deps--guess-physical-path-converter (svn admin)
332+ (let* ((dir (fsvn-make-temp-directory))
333+ (rep (expand-file-name "rep" dir))
334+ (wc (expand-file-name "wc" dir)))
335+ (unwind-protect
336+ (with-temp-buffer
337+ (fsvn-deps-process-environment
338+ (unless (= (process-file admin nil t nil "create" rep) 0)
339+ (error "Unknown error while create repository")))
340+ (catch 'found
341+ (dolist (c '(nil fsvn-cygwin-ensure-physical-path))
342+ (let* ((converter (lambda (x) (if (fboundp c)
343+ (funcall c x)
344+ x)))
345+ (url (fsvn-directory-name-as-repository (funcall converter rep)))
346+ (physical (funcall converter wc)))
347+ (when (= (process-file svn nil t nil "checkout" url physical) 0)
348+ (throw 'found c))))))
349+ (fsvn-delete-directory dir))))
350+
351+
352+
331353 ;; set bottom of fsvn.el
332354 (defvar fsvn-svn-version nil)
333355 (defvar fsvn-svn-subcommand-completion-alist nil)
@@ -345,9 +367,9 @@
345367 ))
346368
347369 (defvar fsvn-svn-command-alist nil
348- "key-value pair of svn command. Sort ascendant by version.
370+ "Alist of svn command. Sort ascendant by version.
349371 key: version
350-value: command")
372+value: command ensure-physical-function")
351373
352374 (defun fsvn-svn-proper-command (&optional flat-args)
353375 (cond
@@ -393,9 +415,14 @@
393415 (catch 'found
394416 (unless format-version
395417 (throw 'found fsvn-svn-command-internal))
396- (let ((pair (assoc format-version fsvn-svn-command-alist)))
397- (when pair
398- (throw 'found (cdr pair))))
418+ (let ((vers (if (stringp format-version)
419+ (list format-version)
420+ format-version)))
421+ (while vers
422+ (let ((pair (assoc (car vers) fsvn-svn-command-alist)))
423+ (when pair
424+ (let ((command (nth 1 pair)))
425+ (throw 'found command))))))
399426 ;; default
400427 fsvn-svn-command-internal))
401428
@@ -420,29 +447,47 @@
420447 ver))
421448
422449 (defun fsvn-set-command-information ()
450+ ;; FIXME modified this variables value by `start-process' on windows NTEmacs 24.5
451+ ;; (setq my-echo (locate-file-internal "echo.exe" exec-path))
452+ ;; (start-process "TEST" (current-buffer) my-echo "1")
453+ ;; my-echo
423454 (unless (setq fsvn-svn-command-internal
424455 (executable-find fsvn-svn-command))
425- (error "No executable \"%s\" in `exec-path'" fsvn-svn-command))
456+ (error "No executable \"%s\"" fsvn-svn-command))
426457 (unless (setq fsvn-svnadmin-command-internal
427458 (executable-find fsvn-svnadmin-command))
428- (error "No executable \"%s\" in `exec-path'" fsvn-svnadmin-command))
429- (fsvn-add-command-location fsvn-svn-command-internal)
459+ (error "No executable \"%s\"" fsvn-svnadmin-command))
460+ (fsvn-add-command-location fsvn-svn-command-internal
461+ fsvn-svnadmin-command-internal)
430462 (let ((ver (fsvn-get-ensure-version fsvn-svn-command-internal)))
431463 (setq fsvn-svn-version ver)))
432464
433-(defun fsvn-add-command-location (svn-command)
465+(defun fsvn-add-command-location (svn-command &optional admin-command)
434466 (let ((bin (executable-find svn-command)))
435467 (unless bin
436- (error "Not a executable"))
468+ (error "Not a svn executable"))
469+ (unless admin-command
470+ (let ((regexp (concat "\\`\\(.+?\\)" (regexp-opt exec-suffixes t) "?\\'")))
471+ (unless (string-match regexp bin)
472+ (error "Filename not matched (assert)"))
473+ (let ((base (match-string 1 bin))
474+ (suffix (match-string 2 bin)))
475+ (setq admin-command (concat base "admin" suffix)))))
476+ (unless (executable-find admin-command)
477+ (error "Not found a svnadmin executable"))
478+ ;; detect command behavior
437479 (let* ((ver (fsvn-get-ensure-version svn-command))
480+ ;; key is Major.Minor version
438481 (key (and (string-match "\\`[0-9]+\\.[0-9]+" ver)
439482 (match-string 0 ver)))
483+ (converter (fsvn-deps--guess-physical-path-converter
484+ svn-command admin-command))
440485 (alist fsvn-svn-command-alist)
441486 target)
442487 (unless (setq target (assoc key alist))
443488 (setq target (cons key nil))
444489 (setq alist (cons target alist)))
445- (setcdr target bin)
490+ (setcdr target (list bin converter))
446491 (setq fsvn-svn-command-alist alist)
447492 ver)))
448493
@@ -815,7 +860,9 @@
815860 ;; file: subversion/libsvn_wc/upgrade.c
816861 ;; function: version_string_from_format
817862 ;; ref: `fsvn-svn-command-alist'
818-(defun fsvn-file-wc-svn-version (file)
863+(defun fsvn-file-wc-svn-version (file &optional higher)
864+ ;; This function may return multiple values which is supported by current version. (DESC)
865+ ;; non-nil HIGHER indicate that only first value.
819866 (let ((format (fsvn-file-wc-version file)))
820867 (cond
821868 ((null format)
@@ -826,8 +873,11 @@
826873 ((eq format 10) "1.6")
827874 ((and format (<= 12 format) (<= format 29))
828875 "1.7")
829- ((and format (<= 30 format)) ;TODO FIXME
830- "1.8")
876+ ((and format (<= 30 format))
877+ ;; seems 1.8 accept 31 either
878+ (if higher
879+ "1.9"
880+ (list "1.9" "1.8")))
831881 (t (error "Not a supported format")))))
832882
833883 (defun fsvn-file-wc-version (file)
@@ -1176,6 +1226,42 @@
11761226
11771227
11781228
1229+(defun fsvn-svn-fetch-physical-path-function (command)
1230+ ;; canonicalize
1231+ (setq command (expand-file-name command))
1232+ (catch 'found
1233+ (let ((lis fsvn-svn-command-alist))
1234+ (while lis
1235+ (let ((pair (car lis)))
1236+ (when (string= (nth 1 pair) command)
1237+ (throw 'found (nth 2 pair)))
1238+ (setq lis (cdr lis)))))))
1239+
1240+;; cygwin version svn accept only "/" started filename not emacs path
1241+;; e.g.
1242+;; x c:/hoge/windows
1243+;; o /cygdrive/c/hoge/windows
1244+(defun fsvn-command-args-to-physical-args (command args)
1245+ (let ((ensurer (fsvn-svn-fetch-physical-path-function command)))
1246+ (if (null ensurer)
1247+ args
1248+ (mapcar
1249+ (lambda (x)
1250+ (cond
1251+ ((fsvn-url-local-p x)
1252+ (funcall ensurer x))
1253+ ((string-match "\\`\\(--[^=]+\\)=\\(.*\\)" x)
1254+ (let ((option (match-string 1 x))
1255+ (path (match-string 2 x)))
1256+ (if (fsvn-url-local-p path)
1257+ (format "%s=%s" option (funcall ensurer path))
1258+ x)))
1259+ (t
1260+ x)))
1261+ args))))
1262+
1263+
1264+
11791265 (provide 'fsvn-deps)
11801266
11811267 ;;; fsvn-deps.el ends here
--- trunk/fsvn-win.el (revision 322)
+++ trunk/fsvn-win.el (revision 323)
@@ -239,6 +239,27 @@
239239 (t
240240 path))))
241241
242+(defun fsvn-cygwin-ensure-physical-path (path)
243+ (cond
244+ ((string-match "\\`[a-zA-Z]:" path)
245+ (fsvn-cygwin-expand-path path))
246+ (t
247+ path)))
248+
249+(defun fsvn-win-expand-file (name &optional dir)
250+ (cond
251+ ;; convert cygwin filename to emacs-path
252+ ;; on windows, start with "/" mean ahhh TODO tramp filename...
253+ ((string-match "\\`/" name)
254+ (fsvn-cygwin-to-emacs-path name))
255+ (t
256+ ;; todo expand-file-name bug?
257+ (replace-regexp-in-string
258+ "\\\\" "/"
259+ (expand-file-name name dir)))))
260+
261+(setq fsvn-url-filename-expand-function 'fsvn-win-expand-file)
262+
242263 ;; cygwin svn `--targets' arg accept only cygpath
243264 (defun fsvn-win-targets-file-converter (x)
244265 (fsvn-cygwin-expand-path x))
--- trunk/fsvn-url.el (revision 322)
+++ trunk/fsvn-url.el (revision 323)
@@ -278,12 +278,11 @@
278278 (setq i (1+ i)))
279279 tmp))
280280
281+(defvar fsvn-url-filename-expand-function nil)
281282 (defun fsvn-expand-file (name &optional dir)
282- (let ((ret (expand-file-name name dir)))
283- (if (eq system-type 'windows-nt)
284- ;; todo expand-file-name bug?
285- (replace-regexp-in-string "\\\\" "/" ret)
286- ret)))
283+ (funcall (or fsvn-url-filename-expand-function
284+ 'expand-file-name)
285+ name dir))
287286
288287 (defun fsvn-file-relative (name &optional dir)
289288 ;;todo remove copy-sequence..
--- trunk/ChangeLog (revision 322)
+++ trunk/ChangeLog (revision 323)
@@ -1,3 +1,12 @@
1+2015-11-10 Masahiro Hayashi (林 雅博) <mhayashi1120@gmail.com>
2+
3+ * Fix: select higher version of svn if registered multiple versions.
4+ * Improve: Fix testing environment
5+
6+2015-11-09 Masahiro Hayashi (林 雅博) <mhayashi1120@gmail.com>
7+
8+ * Fix: I don't know when, Cygwin svn accept only cygwin path does not Emacs/Windows path.
9+
110 2015-07-01 Masahiro Hayashi (林 雅博) <mhayashi1120@gmail.com>
211
312 * Fix: fancy icon misunderstand ignored status.
--- trunk/fsvn-pub.el (revision 322)
+++ trunk/fsvn-pub.el (revision 323)
@@ -447,7 +447,7 @@
447447 (list file url args)))
448448
449449 (defun fsvn-cmd-read-upgrade-args ()
450- (let* ((current (fsvn-file-wc-svn-version default-directory))
450+ (let* ((current (fsvn-file-wc-svn-version default-directory t))
451451 (svn-ver fsvn-svn-version)
452452 (prompt (format "Upgrade directory (%s -> %s): "
453453 current svn-ver))
--- trunk/fsvn.el (revision 322)
+++ trunk/fsvn.el (revision 323)
@@ -25,7 +25,7 @@
2525
2626 ;; fsvn supports
2727 ;; * GNU Emacs 23.x or later.
28-;; * Subversion from 1.6.x to 1.7.x. (1.8.x, 1.9.x is testing)
28+;; * Subversion 1.6.x, 1.7.x, 1.8.x, 1.9.x
2929
3030 ;; fsvn has TortoiseSVN like user interface by using `svn' command.
3131 ;; Have following advantages of other Emacs svn client.
@@ -42,9 +42,9 @@
4242 ;; * A little user help.
4343
4444 ;; This package is tested on following environment.
45-;; NTEmacs (based Emacs 23.3) on Windows. svn 1.6.x - 1.7.x
46-;; Emacs (24.4) on GNU/Linux (Debian). svn svn 1.6.x - 1.8.x
47-;; Emacs current (25.0.50) on GNU/Linux (Debian). svn 1.6.x - 1.8.x
45+;; NTEmacs (based Emacs 24.5) on Windows. cygwin svn 1.9.x
46+;; Emacs (24.5) on GNU/Linux (Debian). svn svn 1.6.x - 1.9.x
47+;; Emacs current (25.0.50) on GNU/Linux (Debian). svn 1.6.x - 1.9.x
4848
4949 ;;; Code:
5050
--- trunk/fsvn-proc.el (revision 322)
+++ trunk/fsvn-proc.el (revision 323)
@@ -39,10 +39,11 @@
3939 (defun fsvn-start-process (buffer &rest args)
4040 (let* ((real-args (fsvn-command-args-canonicalize args))
4141 (coding-system-for-read (fsvn-process-coding-system real-args))
42- (command (fsvn-svn-proper-command real-args)))
43- (fsvn-debug real-args)
42+ (command (fsvn-svn-proper-command real-args))
43+ (true-args (fsvn-command-args-to-physical-args command real-args)))
44+ (fsvn-debug true-args)
4445 (fsvn-process-environment
45- (apply 'start-file-process "fsvn" buffer command real-args))))
46+ (apply 'start-file-process "fsvn" buffer command true-args))))
4647
4748 (defun fsvn-start-command (subcommand buffer &rest args)
4849 (apply 'fsvn-start-process buffer subcommand args))
@@ -61,14 +62,15 @@
6162 "
6263 (let* ((real-args (fsvn-command-args-canonicalize args))
6364 (coding-system-for-read (fsvn-process-coding-system real-args))
64- (command (fsvn-svn-proper-command real-args)))
65+ (command (fsvn-svn-proper-command real-args))
66+ (true-args (fsvn-command-args-to-physical-args command real-args)))
6567 (when (and (bufferp buffer) (> (buffer-size buffer) 0))
6668 (with-current-buffer buffer
6769 (goto-char (point-max))))
68- (fsvn-debug real-args)
70+ (fsvn-debug true-args)
6971 (prog1
7072 (fsvn-process-environment
71- (apply 'process-file command nil buffer nil real-args))
73+ (apply 'process-file command nil buffer nil true-args))
7274 (fsvn-debug buffer))))
7375
7476 (defun fsvn-call-command (subcommand buffer &rest args)
@@ -312,13 +314,14 @@
312314 (defun fsvn-build-command-string (subcommand &rest args)
313315 (let* ((real-subcmd-args (fsvn-command-args-canonicalize args))
314316 (real-args (cons subcommand real-subcmd-args))
315- (command (fsvn-svn-proper-command real-args)))
317+ (command (fsvn-svn-proper-command real-args))
318+ (true-args (fsvn-command-args-to-physical-args command real-args)))
316319 (mapconcat
317320 (lambda (x)
318321 (if (or (string= "" x) (string-match " " x))
319322 (concat "\"" x "\"")
320323 x))
321- `(,command ,subcommand ,@real-subcmd-args)
324+ `(,command ,@true-args)
322325 " ")))
323326
324327 (defun fsvn-guess-file-contents-coding-system (flatten-args)
Show on old repository browser