comparison lisp/vc-svn.el @ 51732:f43bd5204ab4

(vc-svn-use-edit): Make it into a const. (vc-svn-update): Fix the arguments to `svn'. (vc-svn-diff-tree): Just use `vc-svn-diff'. (vc-svn-create-snapshot, vc-svn-retrieve-snapshot): Simple implementations, assuming `name' is a URL.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 04 Jul 2003 22:21:45 +0000
parents c09edac18f97
children 9b5f3940a1ef
comparison
equal deleted inserted replaced
51731:6b3b6b76e307 51732:f43bd5204ab4
79 "*Header keywords to be inserted by `vc-insert-headers'." 79 "*Header keywords to be inserted by `vc-insert-headers'."
80 :version "21.4" 80 :version "21.4"
81 :type '(repeat string) 81 :type '(repeat string)
82 :group 'vc) 82 :group 'vc)
83 83
84 (defcustom vc-svn-use-edit nil 84 (defconst vc-svn-use-edit nil
85 ;; Subversion does not provide this feature (yet).
85 "*Non-nil means to use `svn edit' to \"check out\" a file. 86 "*Non-nil means to use `svn edit' to \"check out\" a file.
86 This is only meaningful if you don't use the implicit checkout model 87 This is only meaningful if you don't use the implicit checkout model
87 \(i.e. if you have $SVNREAD set)." 88 \(i.e. if you have $SVNREAD set)."
88 :type 'boolean 89 ;; :type 'boolean
89 :version "21.4" 90 ;; :version "21.4"
90 :group 'vc) 91 ;; :group 'vc
92 )
91 93
92 ;;; 94 ;;;
93 ;;; State-querying functions 95 ;;; State-querying functions
94 ;;; 96 ;;;
95 97
149 (defun vc-svn-checkout-model (file) 151 (defun vc-svn-checkout-model (file)
150 "SVN-specific version of `vc-checkout-model'." 152 "SVN-specific version of `vc-checkout-model'."
151 ;; It looks like Subversion has no equivalent of CVSREAD. 153 ;; It looks like Subversion has no equivalent of CVSREAD.
152 'implicit) 154 'implicit)
153 155
156 ;; vc-svn-mode-line-string doesn't exist because the default implementation
157 ;; works just fine.
158
154 (defun vc-svn-dired-state-info (file) 159 (defun vc-svn-dired-state-info (file)
155 "SVN-specific version of `vc-dired-state-info'." 160 "SVN-specific version of `vc-dired-state-info'."
156 (let ((svn-state (vc-state file))) 161 (let ((svn-state (vc-state file)))
157 (cond ((eq svn-state 'edited) 162 (cond ((eq svn-state 'edited)
158 (if (equal (vc-workfile-version file) "0") 163 (if (equal (vc-workfile-version file) "0")
169 "Register FILE into the SVN version-control system. 174 "Register FILE into the SVN version-control system.
170 COMMENT can be used to provide an initial description of FILE. 175 COMMENT can be used to provide an initial description of FILE.
171 176
172 `vc-register-switches' and `vc-svn-register-switches' are passed to 177 `vc-register-switches' and `vc-svn-register-switches' are passed to
173 the SVN command (in that order)." 178 the SVN command (in that order)."
174 (apply 'vc-svn-command nil 0 file 179 (apply 'vc-svn-command nil 0 file "add" (vc-switches 'SVN 'register)))
175 "add"
176 ;; (and comment (string-match "[^\t\n ]" comment)
177 ;; (concat "-m" comment))
178 (vc-switches 'SVN 'register)))
179 180
180 (defun vc-svn-responsible-p (file) 181 (defun vc-svn-responsible-p (file)
181 "Return non-nil if SVN thinks it is responsible for FILE." 182 "Return non-nil if SVN thinks it is responsible for FILE."
182 (file-directory-p (expand-file-name ".svn" 183 (file-directory-p (expand-file-name ".svn"
183 (if (file-directory-p file) 184 (if (file-directory-p file)
238 (set-file-modes file (logior (file-modes file) 128)) 239 (set-file-modes file (logior (file-modes file) 128))
239 (if (equal file buffer-file-name) (toggle-read-only -1)))) 240 (if (equal file buffer-file-name) (toggle-read-only -1))))
240 ;; Check out a particular version (or recreate the file). 241 ;; Check out a particular version (or recreate the file).
241 (vc-file-setprop file 'vc-workfile-version nil) 242 (vc-file-setprop file 'vc-workfile-version nil)
242 (apply 'vc-svn-command nil 0 file 243 (apply 'vc-svn-command nil 0 file
243 "-w"
244 "update" 244 "update"
245 ;; default for verbose checkout: clear the sticky tag so 245 ;; default for verbose checkout: clear the sticky tag so
246 ;; that the actual update will get the head of the trunk 246 ;; that the actual update will get the head of the trunk
247 (if (or (not rev) (string= rev "")) 247 (cond
248 "-A" 248 ((null rev) "-rBASE")
249 (concat "-r" rev)) 249 ((or (eq rev t) (equal rev "")) nil)
250 (t (concat "-r" rev)))
250 switches))) 251 switches)))
251 252
252 (defun vc-svn-delete-file (file) 253 (defun vc-svn-delete-file (file)
253 (vc-svn-command nil 0 file "remove")) 254 (vc-svn-command nil 0 file "remove"))
254 255
374 ;; status w.r.t whether the diff was empty or not. 375 ;; status w.r.t whether the diff was empty or not.
375 (buffer-size (get-buffer "*vc-diff*")))))) 376 (buffer-size (get-buffer "*vc-diff*"))))))
376 377
377 (defun vc-svn-diff-tree (dir &optional rev1 rev2) 378 (defun vc-svn-diff-tree (dir &optional rev1 rev2)
378 "Diff all files at and below DIR." 379 "Diff all files at and below DIR."
379 (with-current-buffer "*vc-diff*" 380 (vc-svn-diff (file-name-as-directory dir) rev1 rev2))
380 (setq default-directory dir)
381 (if (vc-stay-local-p dir)
382 ;; local diff: do it filewise, and only for files that are modified
383 (vc-file-tree-walk
384 dir
385 (lambda (f)
386 (vc-exec-after
387 `(let ((coding-system-for-read (vc-coding-system-for-diff ',f)))
388 ;; possible optimization: fetch the state of all files
389 ;; in the tree via vc-svn-dir-state-heuristic
390 (unless (vc-up-to-date-p ',f)
391 (message "Looking at %s" ',f)
392 (vc-diff-internal ',f ',rev1 ',rev2))))))
393 ;; svn diff: use a single call for the entire tree
394 (let ((coding-system-for-read (or coding-system-for-read 'undecided))
395 (switches (vc-switches 'SVN 'diff)))
396 (apply 'vc-svn-command "*vc-diff*" 1 nil "diff"
397 (append
398 (when rev1
399 (list "-r" (if rev2 (concat rev1 ":" rev2) rev1)))
400 (when switches
401 (list "-x" (mapconcat 'identity switches " ")))))))))
402 381
403 ;;; 382 ;;;
404 ;;; Snapshot system 383 ;;; Snapshot system
405 ;;; 384 ;;;
406 385
407 (defun vc-svn-create-snapshot (dir name branchp) 386 (defun vc-svn-create-snapshot (dir name branchp)
408 "Assign to DIR's current version a given NAME. 387 "Assign to DIR's current version a given NAME.
409 If BRANCHP is non-nil, the name is created as a branch (and the current 388 If BRANCHP is non-nil, the name is created as a branch (and the current
410 workspace is immediately moved to that new branch)." 389 workspace is immediately moved to that new branch).
411 (vc-svn-command nil 0 dir "tag" "-c" (if branchp "-b") name) 390 NAME is assumed to be a URL."
412 (when branchp (vc-svn-command nil 0 dir "update" "-r" name))) 391 (vc-svn-command nil 0 dir "copy" name)
392 (when branchp (vc-svn-retrieve-snapshot dir name nil)))
413 393
414 (defun vc-svn-retrieve-snapshot (dir name update) 394 (defun vc-svn-retrieve-snapshot (dir name update)
415 "Retrieve a snapshot at and below DIR. 395 "Retrieve a snapshot at and below DIR.
416 NAME is the name of the snapshot; if it is empty, do a `svn update'. 396 NAME is the name of the snapshot; if it is empty, do a `svn update'.
417 If UPDATE is non-nil, then update (resynch) any affected buffers." 397 If UPDATE is non-nil, then update (resynch) any affected buffers.
418 (with-current-buffer (get-buffer-create "*vc*") 398 NAME is assumed to be a URL."
419 (let ((default-directory dir) 399 (vc-svn-command nil 0 dir "switch" name)
420 (sticky-tag)) 400 ;; FIXME: parse the output and obey `update'.
421 (erase-buffer) 401 )
422 (if (or (not name) (string= name ""))
423 (vc-svn-command t 0 nil "update")
424 (vc-svn-command t 0 nil "update" "-r" name)
425 (setq sticky-tag name))
426 (when update
427 (goto-char (point-min))
428 (while (not (eobp))
429 (if (looking-at "\\([CMUP]\\) \\(.*\\)")
430 (let* ((file (expand-file-name (match-string 2) dir))
431 (state (match-string 1))
432 (buffer (find-buffer-visiting file)))
433 (when buffer
434 (cond
435 ((or (string= state "U")
436 (string= state "P"))
437 (vc-file-setprop file 'vc-state 'up-to-date)
438 (vc-file-setprop file 'vc-workfile-version nil)
439 (vc-file-setprop file 'vc-checkout-time
440 (nth 5 (file-attributes file))))
441 ((or (string= state "M")
442 (string= state "C"))
443 (vc-file-setprop file 'vc-state 'edited)
444 (vc-file-setprop file 'vc-workfile-version nil)
445 (vc-file-setprop file 'vc-checkout-time 0)))
446 (vc-file-setprop file 'vc-svn-sticky-tag sticky-tag)
447 (vc-resynch-buffer file t t))))
448 (forward-line 1))))))
449
450 402
451 ;;; 403 ;;;
452 ;;; Miscellaneous 404 ;;; Miscellaneous
453 ;;; 405 ;;;
454 406