comparison lisp/vc-svn.el @ 81968:1b5dfd1b9ca0

Put the lower half (the back-end) of NewVC in place. This commit makes only the minimum changes needed to get the old vc.el logic working with the new back ends.
author Eric S. Raymond <esr@snark.thyrsus.com>
date Wed, 18 Jul 2007 16:32:40 +0000
parents 0a2fb180b0a5
children 4c7de50bc365
comparison
equal deleted inserted replaced
81967:6bf2af5a341e 81968:1b5dfd1b9ca0
94 (getenv "SVN_ASP_DOT_NET_HACK")) 94 (getenv "SVN_ASP_DOT_NET_HACK"))
95 "_svn") 95 "_svn")
96 (t ".svn")) 96 (t ".svn"))
97 "The name of the \".svn\" subdirectory or its equivalent.") 97 "The name of the \".svn\" subdirectory or its equivalent.")
98 98
99 ;;; Properties of the backend
100
101 (defun vc-svn-revision-granularity ()
102 'repository)
99 ;;; 103 ;;;
100 ;;; State-querying functions 104 ;;; State-querying functions
101 ;;; 105 ;;;
102 106
103 ;;; vc-svn-admin-directory is generally not defined when the 107 ;;; vc-svn-admin-directory is generally not defined when the
204 208
205 ;;; 209 ;;;
206 ;;; State-changing functions 210 ;;; State-changing functions
207 ;;; 211 ;;;
208 212
209 (defun vc-svn-register (file &optional rev comment) 213 (defun vc-svn-create-repo ()
210 "Register FILE into the SVN version-control system. 214 "Create a new SVN repository."
211 COMMENT can be used to provide an initial description of FILE. 215 (vc-do-command nil 0 "svnadmin" '("create" "SVN"))
216 (vc-do-command nil 0 "svn" '(".")
217 "checkout" (concat "file://" default-directory "SVN")))
218
219 (defun vc-svn-register (files &optional rev comment)
220 "Register FILES into the SVN version-control system.
221 The COMMENT argument is ignored This does an add but not a commit.
212 222
213 `vc-register-switches' and `vc-svn-register-switches' are passed to 223 `vc-register-switches' and `vc-svn-register-switches' are passed to
214 the SVN command (in that order)." 224 the SVN command (in that order)."
215 (apply 'vc-svn-command nil 0 file "add" (vc-switches 'SVN 'register))) 225 (apply 'vc-svn-command nil 0 files "add" (vc-switches 'SVN 'register)))
216 226
217 (defun vc-svn-responsible-p (file) 227 (defun vc-svn-responsible-p (file)
218 "Return non-nil if SVN thinks it is responsible for FILE." 228 "Return non-nil if SVN thinks it is responsible for FILE."
219 (file-directory-p (expand-file-name vc-svn-admin-directory 229 (file-directory-p (expand-file-name vc-svn-admin-directory
220 (if (file-directory-p file) 230 (if (file-directory-p file)
223 233
224 (defalias 'vc-svn-could-register 'vc-svn-responsible-p 234 (defalias 'vc-svn-could-register 'vc-svn-responsible-p
225 "Return non-nil if FILE could be registered in SVN. 235 "Return non-nil if FILE could be registered in SVN.
226 This is only possible if SVN is responsible for FILE's directory.") 236 This is only possible if SVN is responsible for FILE's directory.")
227 237
228 (defun vc-svn-checkin (file rev comment) 238 (defun vc-svn-checkin (files rev comment)
229 "SVN-specific version of `vc-backend-checkin'." 239 "SVN-specific version of `vc-backend-checkin'."
240 (if rev (error "Committing to a specific revision is unsupported in SVN."))
230 (let ((status (apply 241 (let ((status (apply
231 'vc-svn-command nil 1 file "ci" 242 'vc-svn-command nil 1 files "ci"
232 (nconc (list "-m" comment) (vc-switches 'SVN 'checkin))))) 243 (nconc (list "-m" comment) (vc-switches 'SVN 'checkin)))))
233 (set-buffer "*vc*") 244 (set-buffer "*vc*")
234 (goto-char (point-min)) 245 (goto-char (point-min))
235 (unless (equal status 0) 246 (unless (equal status 0)
236 ;; Check checkin problem. 247 ;; Check checkin problem.
237 (cond 248 (cond
238 ((search-forward "Transaction is out of date" nil t) 249 ((search-forward "Transaction is out of date" nil t)
239 (vc-file-setprop file 'vc-state 'needs-merge) 250 (mapc (lambda (file) (vc-file-setprop file 'vc-state 'needs-merge))
251 files)
240 (error (substitute-command-keys 252 (error (substitute-command-keys
241 (concat "Up-to-date check failed: " 253 (concat "Up-to-date check failed: "
242 "type \\[vc-next-action] to merge in changes")))) 254 "type \\[vc-next-action] to merge in changes"))))
243 (t 255 (t
244 (pop-to-buffer (current-buffer)) 256 (pop-to-buffer (current-buffer))
250 ;; file 'vc-workfile-version 262 ;; file 'vc-workfile-version
251 ;; (vc-parse-buffer "^\\(new\\|initial\\) revision: \\([0-9.]+\\)" 2)) 263 ;; (vc-parse-buffer "^\\(new\\|initial\\) revision: \\([0-9.]+\\)" 2))
252 )) 264 ))
253 265
254 (defun vc-svn-find-version (file rev buffer) 266 (defun vc-svn-find-version (file rev buffer)
267 "SVN-specific retrieval of a specified version into a buffer."
255 (apply 'vc-svn-command 268 (apply 'vc-svn-command
256 buffer 0 file 269 buffer 0 file
257 "cat" 270 "cat"
258 (and rev (not (string= rev "")) 271 (and rev (not (string= rev ""))
259 (concat "-r" rev)) 272 (concat "-r" rev))
360 373
361 ;;; 374 ;;;
362 ;;; History functions 375 ;;; History functions
363 ;;; 376 ;;;
364 377
365 (defun vc-svn-print-log (file &optional buffer) 378 (defun vc-svn-print-log (files &optional buffer)
366 "Get change log associated with FILE." 379 "Get change log(s) associated with FILES."
367 (save-current-buffer 380 (save-current-buffer
368 (vc-setup-buffer buffer) 381 (vc-setup-buffer buffer)
369 (let ((inhibit-read-only t)) 382 (let ((inhibit-read-only t))
370 (goto-char (point-min)) 383 (goto-char (point-min))
371 ;; Add a line to tell log-view-mode what file this is. 384 ;; Add a line to tell log-view-mode what file this is.
372 (insert "Working file: " (file-relative-name file) "\n")) 385 (insert "Working file(s): " (vc-delistify (mapcar 'file-relative-name files)) "\n"))
373 (vc-svn-command 386 (vc-svn-command
374 buffer 387 buffer
375 (if (and (vc-stay-local-p file) (fboundp 'start-process)) 'async 0) 388 (if (and (= (length files) 1) (vc-stay-local-p (car files)) (fboundp 'start-process)) 'async 0)
376 file "log" 389 files "log"
377 ;; By default Subversion only shows the log upto the working version, 390 ;; By default Subversion only shows the log upto the working version,
378 ;; whereas we also want the log of the subsequent commits. At least 391 ;; whereas we also want the log of the subsequent commits. At least
379 ;; that's what the vc-cvs.el code does. 392 ;; that's what the vc-cvs.el code does.
380 "-rHEAD:0"))) 393 "-rHEAD:0"))))
381 394
382 (defun vc-svn-diff (file &optional oldvers newvers buffer) 395 (defun vc-svn-wash-log ()
383 "Get a difference report using SVN between two versions of FILE." 396 "Remove all non-comment information from log output."
384 (unless buffer (setq buffer "*vc-diff*")) 397 ;; FIXME: not implemented for SVN
385 (if (and oldvers (equal oldvers (vc-workfile-version file))) 398 nil)
386 ;; Use nil rather than the current revision because svn handles it 399
387 ;; better (i.e. locally). 400 (defun vc-svn-diff (files &optional oldvers newvers buffer)
388 (setq oldvers nil)) 401 "Get a difference report using SVN between two versions of fileset FILES."
389 (if (string= (vc-workfile-version file) "0") 402 (let* ((switches
390 ;; This file is added but not yet committed; there is no master file.
391 (if (or oldvers newvers)
392 (error "No revisions of %s exist" file)
393 ;; We regard this as "changed".
394 ;; Diff it against /dev/null.
395 ;; Note: this is NOT a "svn diff".
396 (apply 'vc-do-command buffer
397 1 "diff" file
398 (append (vc-switches nil 'diff) '("/dev/null")))
399 ;; Even if it's empty, it's locally modified.
400 1)
401 (let* ((switches
402 (if vc-svn-diff-switches 403 (if vc-svn-diff-switches
403 (vc-switches 'SVN 'diff) 404 (vc-switches 'SVN 'diff)
404 (list "-x" (mapconcat 'identity (vc-switches nil 'diff) " ")))) 405 (list "-x" (mapconcat 'identity (vc-switches nil 'diff) " "))))
405 (async (and (not vc-disable-async-diff) 406 (async (and (not vc-disable-async-diff)
406 (vc-stay-local-p file) 407 (vc-stay-local-p files)
407 (or oldvers newvers) ; Svn diffs those locally. 408 (or oldvers newvers) ; Svn diffs those locally.
408 (fboundp 'start-process)))) 409 (fboundp 'start-process))))
409 (apply 'vc-svn-command buffer 410 (apply 'vc-svn-command buffer
410 (if async 'async 0) 411 (if async 'async 0)
411 file "diff" 412 files "diff"
412 (append 413 (append
413 switches 414 switches
414 (when oldvers 415 (when oldvers
415 (list "-r" (if newvers (concat oldvers ":" newvers) 416 (list "-r" (if newvers (concat oldvers ":" newvers)
416 oldvers))))) 417 oldvers)))))
417 (if async 1 ; async diff => pessimistic assumption 418 (if async 1 ; async diff => pessimistic assumption
418 ;; For some reason `svn diff' does not return a useful 419 ;; For some reason `svn diff' does not return a useful
419 ;; status w.r.t whether the diff was empty or not. 420 ;; status w.r.t whether the diff was empty or not.
420 (buffer-size (get-buffer buffer)))))) 421 (buffer-size (get-buffer buffer)))))
421 422
422 (defun vc-svn-diff-tree (dir &optional rev1 rev2) 423 (defun vc-svn-diff-tree (dir &optional rev1 rev2)
423 "Diff all files at and below DIR." 424 "Diff all files at and below DIR."
424 (vc-svn-diff (file-name-as-directory dir) rev1 rev2)) 425 (vc-svn-diff (file-name-as-directory dir) rev1 rev2))
425 426
467 (defcustom vc-svn-program "svn" 468 (defcustom vc-svn-program "svn"
468 "Name of the svn executable." 469 "Name of the svn executable."
469 :type 'string 470 :type 'string
470 :group 'vc) 471 :group 'vc)
471 472
472 (defun vc-svn-command (buffer okstatus file &rest flags) 473 (defun vc-svn-command (buffer okstatus file-or-list &rest flags)
473 "A wrapper around `vc-do-command' for use in vc-svn.el. 474 "A wrapper around `vc-do-command' for use in vc-svn.el.
474 The difference to vc-do-command is that this function always invokes `svn', 475 The difference to vc-do-command is that this function always invokes `svn',
475 and that it passes `vc-svn-global-switches' to it before FLAGS." 476 and that it passes `vc-svn-global-switches' to it before FLAGS."
476 (apply 'vc-do-command buffer okstatus vc-svn-program file 477 (apply 'vc-do-command buffer okstatus vc-svn-program file-or-list
477 (if (stringp vc-svn-global-switches) 478 (if (stringp vc-svn-global-switches)
478 (cons vc-svn-global-switches flags) 479 (cons vc-svn-global-switches flags)
479 (append vc-svn-global-switches 480 (append vc-svn-global-switches
480 flags)))) 481 flags))))
481 482