comparison lisp/vc-hooks.el @ 98086:4a399b9bc4b9

* vc-svn.el (vc-svn-root): * vc-sccs.el (vc-sccs-root): * vc-rcs.el (vc-rcs-root): * vc-cvs.el (vc-cvs-root): Delete. * vc-hooks.el (vc-find-root): Remove `invert' argument.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 07 Sep 2008 20:24:24 +0000
parents 795196147034
children 29b6eeebe3bf
comparison
equal deleted inserted replaced
98085:5b7423557e65 98086:4a399b9bc4b9
319 (point-max))) 319 (point-max)))
320 (not pos))))))) 320 (not pos)))))))
321 (set-buffer-modified-p nil) 321 (set-buffer-modified-p nil)
322 t)) 322 t))
323 323
324 (defun vc-find-root (file witness &optional invert) 324 (defun vc-find-root (file witness)
325 "Find the root of a checked out project. 325 "Find the root of a checked out project.
326 The function walks up the directory tree from FILE looking for WITNESS. 326 The function walks up the directory tree from FILE looking for WITNESS.
327 If WITNESS if not found, return nil, otherwise return the root. 327 If WITNESS if not found, return nil, otherwise return the root."
328 Optional arg INVERT non-nil reverses the sense of the check;
329 the root is the last directory for which WITNESS *is* found."
330 ;; Represent /home/luser/foo as ~/foo so that we don't try to look for 328 ;; Represent /home/luser/foo as ~/foo so that we don't try to look for
331 ;; witnesses in /home or in /. 329 ;; witnesses in /home or in /.
332 (setq file (abbreviate-file-name file)) 330 (setq file (abbreviate-file-name file))
333 (let ((root nil) 331 (let ((root nil)
334 (prev-file file) 332 (prev-file file)
347 (let ((prev-user user)) 345 (let ((prev-user user))
348 (setq user (nth 2 (file-attributes file))) 346 (setq user (nth 2 (file-attributes file)))
349 (and prev-user (not (equal user prev-user)))) 347 (and prev-user (not (equal user prev-user))))
350 (string-match vc-ignore-dir-regexp file))) 348 (string-match vc-ignore-dir-regexp file)))
351 (setq try (file-exists-p (expand-file-name witness file))) 349 (setq try (file-exists-p (expand-file-name witness file)))
352 (cond ((and invert (not try)) (setq root prev-file)) 350 (cond (try (setq root file))
353 ((and (not invert) try) (setq root file))
354 ((equal file (setq prev-file file 351 ((equal file (setq prev-file file
355 file (file-name-directory 352 file (file-name-directory
356 (directory-file-name file)))) 353 (directory-file-name file))))
357 (setq file nil)))) 354 (setq file nil))))
358 ;; Handle the case where ~/WITNESS exists and the original FILE is "~".
359 ;; (This occurs, for example, when placing dotfiles under RCS.)
360 (when (and (not root) invert prev-file)
361 (setq root prev-file))
362 root)) 355 root))
363 356
364 ;; Access functions to file properties 357 ;; Access functions to file properties
365 ;; (Properties should be _set_ using vc-file-setprop, but 358 ;; (Properties should be _set_ using vc-file-setprop, but
366 ;; _retrieved_ only through these functions, which decide 359 ;; _retrieved_ only through these functions, which decide