aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2003-05-09 16:41:19 +0000
committerStefan Monnier2003-05-09 16:41:19 +0000
commit7ffc77d367eff5e8bc16a36a7cfaacf67ddde6e1 (patch)
tree218a328bec798ffbf36d997606c207fcc98c2475
parenta36319a462218494e4c81fc8fbe629fb34caccbb (diff)
downloademacs-7ffc77d367eff5e8bc16a36a7cfaacf67ddde6e1.tar.gz
emacs-7ffc77d367eff5e8bc16a36a7cfaacf67ddde6e1.zip
(vc-svn-rename-file): New fun.
(vc-svn-diff): Correctly check svn's return status. (vc-svn-state, vc-svn-dir-state, vc-svn-print-log, vc-svn-diff) (vc-svn-diff-tree): Use vc-stay-local-p. (vc-svn-register-switches, vc-svn-diff-switches, vc-svn-header) (vc-svn-use-edit): Fix the :version property. (vc-svn-stay-local): Remove unused var. (vc-svn-mode-line-string): Remove, use the default instead. (vc-svn-repository-hostname): New fun taken from vc-svn-stay-local-p. (vc-svn-stay-local-p): Remove.
-rw-r--r--lisp/vc-svn.el130
1 files changed, 22 insertions, 108 deletions
diff --git a/lisp/vc-svn.el b/lisp/vc-svn.el
index eadea67d2e9..aeea2ff5b2e 100644
--- a/lisp/vc-svn.el
+++ b/lisp/vc-svn.el
@@ -62,7 +62,7 @@ A string or list of strings passed to the checkin program by
62 (repeat :tag "Argument List" 62 (repeat :tag "Argument List"
63 :value ("") 63 :value ("")
64 string)) 64 string))
65 :version "21.1" 65 :version "21.4"
66 :group 'vc) 66 :group 'vc)
67 67
68(defcustom vc-svn-diff-switches nil 68(defcustom vc-svn-diff-switches nil
@@ -72,12 +72,12 @@ A string or list of strings passed to the checkin program by
72 (repeat :tag "Argument List" 72 (repeat :tag "Argument List"
73 :value ("") 73 :value ("")
74 string)) 74 string))
75 :version "21.1" 75 :version "21.4"
76 :group 'vc) 76 :group 'vc)
77 77
78(defcustom vc-svn-header (or (cdr (assoc 'SVN vc-header-alist)) '("\$Id\$")) 78(defcustom vc-svn-header (or (cdr (assoc 'SVN vc-header-alist)) '("\$Id\$"))
79 "*Header keywords to be inserted by `vc-insert-headers'." 79 "*Header keywords to be inserted by `vc-insert-headers'."
80 :version "21.1" 80 :version "21.4"
81 :type '(repeat string) 81 :type '(repeat string)
82 :group 'vc) 82 :group 'vc)
83 83
@@ -86,27 +86,7 @@ A string or list of strings passed to the checkin program by
86This is only meaningful if you don't use the implicit checkout model 86This is only meaningful if you don't use the implicit checkout model
87\(i.e. if you have $SVNREAD set)." 87\(i.e. if you have $SVNREAD set)."
88 :type 'boolean 88 :type 'boolean
89 :version "21.1" 89 :version "21.4"
90 :group 'vc)
91
92(defcustom vc-svn-stay-local t
93 "*Non-nil means use local operations when possible for remote repositories.
94This avoids slow queries over the network and instead uses heuristics
95and past information to determine the current status of a file.
96
97The value can also be a regular expression or list of regular
98expressions to match against the host name of a repository; then VC
99only stays local for hosts that match it. Alternatively, the value
100can be a list of regular expressions where the first element is the
101symbol `except'; then VC always stays local except for hosts matched
102by these regular expressions."
103 :type '(choice (const :tag "Always stay local" t)
104 (const :tag "Don't stay local" nil)
105 (list :format "\nExamine hostname and %v" :tag "Examine hostname ..."
106 (set :format "%v" :inline t (const :format "%t" :tag "don't" except))
107 (regexp :format " stay local,\n%t: %v" :tag "if it matches")
108 (repeat :format "%v%i\n" :inline t (regexp :tag "or"))))
109 :version "21.1"
110 :group 'vc) 90 :group 'vc)
111 91
112;;; 92;;;
@@ -134,7 +114,7 @@ by these regular expressions."
134 114
135(defun vc-svn-state (file &optional localp) 115(defun vc-svn-state (file &optional localp)
136 "SVN-specific version of `vc-state'." 116 "SVN-specific version of `vc-state'."
137 (setq localp (or localp (vc-svn-stay-local-p file))) 117 (setq localp (or localp (vc-stay-local-p file)))
138 (with-temp-buffer 118 (with-temp-buffer
139 (cd (file-name-directory file)) 119 (cd (file-name-directory file))
140 (vc-svn-command t 0 file "status" (if localp "-v" "-u")) 120 (vc-svn-command t 0 file "status" (if localp "-v" "-u"))
@@ -147,7 +127,7 @@ by these regular expressions."
147 127
148(defun vc-svn-dir-state (dir &optional localp) 128(defun vc-svn-dir-state (dir &optional localp)
149 "Find the SVN state of all files in DIR." 129 "Find the SVN state of all files in DIR."
150 (setq localp (or localp (vc-svn-stay-local-p dir))) 130 (setq localp (or localp (vc-stay-local-p dir)))
151 (let ((default-directory dir)) 131 (let ((default-directory dir))
152 ;; Don't specify DIR in this command, the default-directory is 132 ;; Don't specify DIR in this command, the default-directory is
153 ;; enough. Otherwise it might fail with remote repositories. 133 ;; enough. Otherwise it might fail with remote repositories.
@@ -168,31 +148,6 @@ by these regular expressions."
168 ;; It looks like Subversion has no equivalent of CVSREAD. 148 ;; It looks like Subversion has no equivalent of CVSREAD.
169 'implicit) 149 'implicit)
170 150
171(defun vc-svn-mode-line-string (file)
172 "Return string for placement into the modeline for FILE.
173Compared to the default implementation, this function does two things:
174Handle the special case of a SVN file that is added but not yet
175committed and support display of sticky tags."
176 (let* ((state (vc-state file))
177 (rev (vc-workfile-version file))
178 (sticky-tag (vc-file-getprop file 'vc-svn-sticky-tag))
179 (sticky-tag-printable (and sticky-tag
180 (not (string= sticky-tag ""))
181 (concat "[" sticky-tag "]"))))
182 (cond ((string= rev "0")
183 ;; A file that is added but not yet committed.
184 "SVN @@")
185 ((or (eq state 'up-to-date)
186 (eq state 'needs-patch))
187 (concat "SVN-" rev sticky-tag-printable))
188 ((stringp state)
189 (concat "SVN:" state ":" rev sticky-tag-printable))
190 (t
191 ;; Not just for the 'edited state, but also a fallback
192 ;; for all other states. Think about different symbols
193 ;; for 'needs-patch and 'needs-merge.
194 (concat "SVN:" rev sticky-tag-printable)))))
195
196(defun vc-svn-dired-state-info (file) 151(defun vc-svn-dired-state-info (file)
197 "SVN-specific version of `vc-dired-state-info'." 152 "SVN-specific version of `vc-dired-state-info'."
198 (let ((svn-state (vc-state file))) 153 (let ((svn-state (vc-state file)))
@@ -378,7 +333,7 @@ The changes are between FIRST-VERSION and SECOND-VERSION."
378 (insert "Working file: " (file-relative-name file) "\n")) 333 (insert "Working file: " (file-relative-name file) "\n"))
379 (vc-svn-command 334 (vc-svn-command
380 t 335 t
381 (if (and (vc-svn-stay-local-p file) (fboundp 'start-process)) 'async 0) 336 (if (and (vc-stay-local-p file) (fboundp 'start-process)) 'async 0)
382 file "log"))) 337 file "log")))
383 338
384(defun vc-svn-diff (file &optional oldvers newvers) 339(defun vc-svn-diff (file &optional oldvers newvers)
@@ -396,7 +351,7 @@ The changes are between FIRST-VERSION and SECOND-VERSION."
396 ;; Even if it's empty, it's locally modified. 351 ;; Even if it's empty, it's locally modified.
397 1) 352 1)
398 (let* ((switches (vc-switches 'SVN 'diff)) 353 (let* ((switches (vc-switches 'SVN 'diff))
399 (async (and (vc-svn-stay-local-p file) 354 (async (and (vc-stay-local-p file)
400 (or oldvers newvers) ; Svn diffs those locally. 355 (or oldvers newvers) ; Svn diffs those locally.
401 (fboundp 'start-process)))) 356 (fboundp 'start-process))))
402 (apply 'vc-svn-command "*vc-diff*" 357 (apply 'vc-svn-command "*vc-diff*"
@@ -417,7 +372,7 @@ The changes are between FIRST-VERSION and SECOND-VERSION."
417 "Diff all files at and below DIR." 372 "Diff all files at and below DIR."
418 (with-current-buffer "*vc-diff*" 373 (with-current-buffer "*vc-diff*"
419 (setq default-directory dir) 374 (setq default-directory dir)
420 (if (vc-svn-stay-local-p dir) 375 (if (vc-stay-local-p dir)
421 ;; local diff: do it filewise, and only for files that are modified 376 ;; local diff: do it filewise, and only for files that are modified
422 (vc-file-tree-walk 377 (vc-file-tree-walk
423 dir 378 dir
@@ -492,7 +447,7 @@ If UPDATE is non-nil, then update (resynch) any affected buffers."
492;;; 447;;;
493 448
494;; Subversion makes backups for us, so don't bother. 449;; Subversion makes backups for us, so don't bother.
495;; (defalias 'vc-svn-make-version-backups-p 'vc-svn-stay-local-p 450;; (defalias 'vc-svn-make-version-backups-p 'vc-stay-local-p
496;; "Return non-nil if version backups should be made for FILE.") 451;; "Return non-nil if version backups should be made for FILE.")
497 452
498(defun vc-svn-check-headers () 453(defun vc-svn-check-headers ()
@@ -517,59 +472,18 @@ and that it passes `vc-svn-global-switches' to it before FLAGS."
517 (append vc-svn-global-switches 472 (append vc-svn-global-switches
518 flags)))) 473 flags))))
519 474
520(defun vc-svn-stay-local-p (file) 475(defun vc-svn-repository-hostname (dirname)
521 "Return non-nil if VC should stay local when handling FILE. 476 (with-temp-buffer
522See `vc-svn-stay-local'." 477 (let ((coding-system-for-read
523 (when vc-svn-stay-local 478 (or file-name-coding-system
524 (let* ((dirname (if (file-directory-p file) 479 default-file-name-coding-system)))
525 (directory-file-name file) 480 (vc-insert-file (expand-file-name ".svn/entries" dirname)))
526 (file-name-directory file))) 481 (goto-char (point-min))
527 (prop 482 (when (re-search-forward
528 (or (vc-file-getprop dirname 'vc-svn-stay-local-p) 483 (concat "name=\"svn:this_dir\"[\n\t ]*"
529 (vc-file-setprop 484 "\\([-a-z]+=\"[^\"]*\"[\n\t ]*\\)*?"
530 dirname 'vc-svn-stay-local-p 485 "url=\"\\([^\"]+\\)\"") nil t)
531 (let ((rootname (expand-file-name ".svn/entries" dirname))) 486 (match-string 2))))
532 (cond
533 ((not (file-readable-p rootname)) 'no)
534 ((stringp vc-svn-stay-local)
535 (with-temp-buffer
536 (let ((coding-system-for-read
537 (or file-name-coding-system
538 default-file-name-coding-system)))
539 (vc-insert-file rootname))
540 (goto-char (point-min))
541 (when (re-search-forward
542 (concat "name=\"svn:this_dir\"[\n\t ]*"
543 "url=\"\\([^\"]+\\)\"") nil t)
544 (let ((hostname (match-string 1)))
545 (if (not hostname)
546 'no
547 (let* ((stay-local t)
548 (rx
549 (cond
550 ;; vc-svn-stay-local: rx
551 ((stringp vc-svn-stay-local)
552 vc-svn-stay-local)
553 ;; vc-svn-stay-local: '( [except] rx ... )
554 ((consp vc-svn-stay-local)
555 (mapconcat
556 'identity
557 (if (not (eq (car vc-svn-stay-local)
558 'except))
559 vc-svn-stay-local
560 (setq stay-local nil)
561 (cdr vc-svn-stay-local))
562 "\\|")))))
563 (if (not rx)
564 'yes
565 (if (not (string-match rx hostname))
566 (setq stay-local (not stay-local)))
567 (if stay-local
568 'yes
569 'no))))))))
570 ;; vc-svn-stay-local is neither nil nor list nor string.
571 (t 'yes)))))))
572 (if (eq prop 'yes) t nil))))
573 487
574(defun vc-svn-parse-status (localp) 488(defun vc-svn-parse-status (localp)
575 "Parse output of \"svn status\" command in the current buffer. 489 "Parse output of \"svn status\" command in the current buffer.