all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
blob 98138016b2a299fd52fc3fbacd889820ab170f93 3280 bytes (raw)
name: lisp/vc/vc-filewise.el 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
 
;;; vc-filewise.el --- common functions for file-oriented back ends.

;; Copyright (C) 1992-1996, 1998-2014 Free Software Foundation, Inc.

;; Author:     FSF (see vc.el for full credits)
;; Maintainer: Andre Spiegel <spiegel@gnu.org>
;; Package: vc

;; This file is part of GNU Emacs.

;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;; Common functions for file-oriented back ends - SCCS, RCS, SRC, CVS
;; 
;; The main purpose of this file is so none od this code jas to like
;; in the always-resident vc-hooks.  A secondary purpose is to remove
;; code specific to this class of back ends from vc.el.

;;; Code:

(eval-when-compile (require 'vc))

;;;###autoload
(defun vc-master-name (file)
  "Return the master name of FILE.
If the file is not registered, or the master name is not known, return nil."
  (or (vc-file-getprop file 'vc-master-name)
      ;; force computation of the property by calling
      ;; vc-BACKEND-registered explicitly
      (let ((backend (vc-backend file)))
	(if (and backend
		 (vc-call-backend backend 'registered file))
	    (vc-file-getprop file 'vc-master-name)))))

(defun vc-rename-master (oldmaster newfile templates)
  "Rename OLDMASTER to be the master file for NEWFILE based on TEMPLATES."
  (let* ((dir (file-name-directory (expand-file-name oldmaster)))
	 (newdir (or (file-name-directory newfile) ""))
	 (newbase (file-name-nondirectory newfile))
	 (masters
	  ;; List of potential master files for `newfile'
	  (mapcar
	   (lambda (s) (vc-possible-master s newdir newbase))
	   templates)))
    (when (or (file-symlink-p oldmaster)
	      (file-symlink-p (file-name-directory oldmaster)))
      (error "This is unsafe in the presence of symbolic links"))
    (rename-file
     oldmaster
     (catch 'found
       ;; If possible, keep the master file in the same directory.
       (dolist (f masters)
	 (when (and f (string= (file-name-directory (expand-file-name f)) dir))
	   (throw 'found f)))
       ;; If not, just use the first possible place.
       (dolist (f masters)
	 (and f (or (not (setq dir (file-name-directory f)))
		    (file-directory-p dir))
	      (throw 'found f)))
       (error "New file lacks a version control directory")))))

(defun vc-filewise-registered (backend file)
  "Check if FILE is registered in BACKEND using vc-BACKEND-master-templates."
  (let ((sym (vc-make-backend-sym backend 'master-templates)))
    (unless (get backend 'vc-templates-grabbed)
      (put backend 'vc-templates-grabbed t))
    (let ((result (vc-check-master-templates file (symbol-value sym))))
      (if (stringp result)
	  (vc-file-setprop file 'vc-master-name result)
	nil))))				; Not registered

(provide 'vc-filewise)

debug log:

solving 9813801 ...
found 9813801 in https://yhetil.org/emacs/20141124130355.GA5432@thyrsus.com/
found bc8a8de in https://git.savannah.gnu.org/cgit/emacs.git
preparing index
index prepared:
100644 bc8a8dec416009c61ba21d53e0be7bb6a571bbeb	lisp/vc/vc-filewise.el

applying [1/1] https://yhetil.org/emacs/20141124130355.GA5432@thyrsus.com/
diff --git a/lisp/vc/vc-filewise.el b/lisp/vc/vc-filewise.el
index bc8a8de..9813801 100644

Checking patch lisp/vc/vc-filewise.el...
Applied patch lisp/vc/vc-filewise.el cleanly.

index at:
100644 98138016b2a299fd52fc3fbacd889820ab170f93	lisp/vc/vc-filewise.el

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.