From 5da9b3d2bdde0c9d23cdcd9d55883878900daa78 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sun, 29 Aug 2021 22:37:30 +0200 Subject: [PATCH] Move vc-branch-p and vc-branch-part from vc.el to vc-rcs.el and rename * lisp/vc/vc-rcs.el (vc-rcs-branch-p): Renamed from `vc-branch-p' (old name made into obsolete alias) and moved from vc.el. (vc-rcs-branch-part): Renamed from `vc-branch-part' (old name made into obsolete alias) and moved from vc.el. --- lisp/vc/vc-cvs.el | 10 ++++------ lisp/vc/vc-rcs.el | 48 +++++++++++++++++++++++++++++------------------ lisp/vc/vc.el | 14 -------------- 3 files changed, 34 insertions(+), 38 deletions(-) diff --git a/lisp/vc/vc-cvs.el b/lisp/vc/vc-cvs.el index c8f36fb76ec..ec6dc282dc8 100644 --- a/lisp/vc/vc-cvs.el +++ b/lisp/vc/vc-cvs.el @@ -24,9 +24,9 @@ ;;; Code: +(require 'vc-rcs) (eval-when-compile (require 'vc)) -(declare-function vc-branch-p "vc" (rev)) (declare-function vc-checkout "vc" (file &optional rev)) (declare-function vc-expand-dirs "vc" (file-or-dir-list backend)) (declare-function vc-read-revision "vc" @@ -451,17 +451,17 @@ REV is the revision to check out." ((string= first-revision "") (setq status (vc-cvs-merge-news file))) (t - (if (not (vc-branch-p first-revision)) + (if (not (vc-rcs-branch-p first-revision)) (setq second-revision (vc-read-revision "Second revision: " (list file) 'CVS nil - (concat (vc-branch-part first-revision) "."))) + (concat (vc-rcs-branch-part first-revision) "."))) ;; We want to merge an entire branch. Set revisions ;; accordingly, so that vc-cvs-merge understands us. (setq second-revision first-revision) ;; first-revision must be the starting point of the branch - (setq first-revision (vc-branch-part first-revision))) + (setq first-revision (vc-rcs-branch-part first-revision))) (setq status (vc-cvs-merge file first-revision second-revision)))) status)) @@ -542,14 +542,12 @@ Will fail unless you have administrative privileges on the repo." ;;; History functions ;;; -(declare-function vc-rcs-print-log-cleanup "vc-rcs" ()) ;; Follows vc-cvs-command, which uses vc-do-command from vc-dispatcher. (declare-function vc-exec-after "vc-dispatcher" (code)) (defun vc-cvs-print-log (files buffer &optional _shortlog _start-revision limit) "Print commit log associated with FILES into specified BUFFER. Remaining arguments are ignored." - (require 'vc-rcs) ;; It's just the catenation of the individual logs. (vc-cvs-command buffer diff --git a/lisp/vc/vc-rcs.el b/lisp/vc/vc-rcs.el index 6ffc1a8a2ff..0b0c71b1ff9 100644 --- a/lisp/vc/vc-rcs.el +++ b/lisp/vc/vc-rcs.el @@ -41,7 +41,6 @@ (require 'cl-lib) (require 'vc)) -(declare-function vc-branch-p "vc" (rev)) (declare-function vc-read-revision "vc" (prompt &optional files backend default initial-input)) (declare-function vc-buffer-context "vc-dispatcher" ()) @@ -173,6 +172,19 @@ For a description of possible values, see `vc-check-master-templates'." (defun vc-rcs-dir-extra-headers (&rest _ignore)) +;; functions that operate on RCS revision numbers. +(defun vc-rcs-branch-p (rev) + "Return t if REV is a branch revision." + (not (eq nil (string-match "\\`[0-9]+\\(\\.[0-9]+\\.[0-9]+\\)*\\'" rev)))) +(define-obsolete-function-alias 'vc-branch-p #'vc-rcs-branch-p "28.1") + +(defun vc-rcs-branch-part (rev) + "Return the branch part of a revision number REV." + (let ((index (string-match "\\.[0-9]+\\'" rev))) + (when index + (substring rev 0 index)))) +(define-obsolete-function-alias 'vc-branch-part #'vc-rcs-branch-part "28.1") + (defun vc-rcs-working-revision (file) "RCS-specific version of `vc-working-revision'." (or (and vc-consult-headers @@ -198,7 +210,7 @@ When VERSION is given, perform check for that version." ;; If we are not on the trunk, we need to examine the ;; whole current branch. (vc-insert-file (vc-master-name file) "^desc") - (vc-rcs-find-most-recent-rev (vc-branch-part version)))))) + (vc-rcs-find-most-recent-rev (vc-rcs-branch-part version)))))) (defun vc-rcs-workfile-unchanged-p (file) "Has FILE remained unchanged since last checkout?" @@ -326,7 +338,7 @@ whether to remove it." (setq rev default-branch) (setq switches (cons "-f" switches))) (if (and (not rev) old-version) - (setq rev (vc-branch-part old-version))) + (setq rev (vc-rcs-branch-part old-version))) (apply #'vc-do-command "*vc*" 0 "ci" (vc-master-name file) ;; if available, use the secure check-in option (and (vc-rcs-release-p "5.6.4") "-j") @@ -349,11 +361,11 @@ whether to remove it." ;; branch accordingly (cond ((and old-version new-version - (not (string= (vc-branch-part old-version) - (vc-branch-part new-version)))) + (not (string= (vc-rcs-branch-part old-version) + (vc-rcs-branch-part new-version)))) (vc-rcs-set-default-branch file (if (vc-rcs-trunk-p new-version) nil - (vc-branch-part new-version))) + (vc-rcs-branch-part new-version))) ;; If this is an old (pre-1992!) RCS release, we might have ;; to remove a remaining lock. (if (not (vc-rcs-release-p "5.6.2")) @@ -414,7 +426,7 @@ attempt the checkout for all registered files beneath it." ;; REV is t ... (if (not (vc-rcs-trunk-p workrev)) ;; ... go to head of current branch - (vc-branch-part workrev) + (vc-rcs-branch-part workrev) ;; ... go to head of trunk (vc-rcs-set-default-branch file nil) @@ -431,7 +443,7 @@ attempt the checkout for all registered files beneath it." file (if (vc-rcs-latest-on-branch-p file new-version) (if (vc-rcs-trunk-p new-version) nil - (vc-branch-part new-version)) + (vc-rcs-branch-part new-version)) new-version))))) (message "Checking out %s...done" file)))))) @@ -456,17 +468,17 @@ revert all registered files beneath it." ((string= first-revision "") (error "A starting RCS revision is required")) (t - (if (not (vc-branch-p first-revision)) + (if (not (vc-rcs-branch-p first-revision)) (setq second-revision (vc-read-revision "Second RCS revision: " (list file) 'RCS nil - (concat (vc-branch-part first-revision) "."))) + (concat (vc-rcs-branch-part first-revision) "."))) ;; We want to merge an entire branch. Set revisions ;; accordingly, so that vc-rcs-merge understands us. (setq second-revision first-revision) ;; first-revision must be the starting point of the branch - (setq first-revision (vc-branch-part first-revision))))) + (setq first-revision (vc-rcs-branch-part first-revision))))) (vc-rcs-merge file first-revision second-revision))) (defun vc-rcs-merge (file first-version &optional second-version) @@ -637,11 +649,11 @@ Optional arg REVISION is a revision to annotate from." ;; Find which branches (if any) must be included in the edits. (let ((par revision) bpt kids) - (while (setq bpt (vc-branch-part par) - par (vc-branch-part bpt)) + (while (setq bpt (vc-rcs-branch-part par) + par (vc-rcs-branch-part bpt)) (setq kids (cdr (assq 'branches (cdr (assoc par revisions))))) ;; A branchpoint may have multiple children. Find the right one. - (while (not (string= bpt (vc-branch-part (car kids)))) + (while (not (string= bpt (vc-rcs-branch-part (car kids)))) (setq kids (cdr kids))) (push (cons par (car kids)) nbls))) ;; Start with the full text. @@ -818,7 +830,7 @@ systime, or nil if there is none. Also, reposition point." or nil if there is no previous revision. This default implementation works for MAJOR.MINOR-style revision numbers as used by RCS and CVS." - (let ((branch (vc-branch-part rev)) + (let ((branch (vc-rcs-branch-part rev)) (minor-num (string-to-number (vc-rcs-minor-part rev)))) (when branch (if (> minor-num 1) @@ -830,7 +842,7 @@ used by RCS and CVS." nil ;; we are at the beginning of a branch -- ;; return revision of starting point - (vc-branch-part branch)))))) + (vc-rcs-branch-part branch)))))) (defun vc-rcs-next-revision (file rev) "Return the revision number immediately following REV for FILE, @@ -838,7 +850,7 @@ or nil if there is no next revision. This default implementation works for MAJOR.MINOR-style revision numbers as used by RCS and CVS." (when (not (string= rev (vc-working-revision file))) - (let ((branch (vc-branch-part rev)) + (let ((branch (vc-rcs-branch-part rev)) (minor-num (string-to-number (vc-rcs-minor-part rev)))) (concat branch "." (number-to-string (1+ minor-num)))))) @@ -965,7 +977,7 @@ to its master version." (setq latest-rev rev) (setq value (match-string 1))))) (or value - (vc-branch-part branch)))) + (vc-rcs-branch-part branch)))) (defun vc-rcs-fetch-master-state (file &optional working-revision) "Compute the master file's idea of the state of FILE. diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index b75862e8a52..38204ef91c8 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -3072,20 +3072,6 @@ log entries should be gathered." (vc-call-backend (vc-responsible-backend default-directory) 'update-changelog args)) -;; functions that operate on RCS revision numbers. This code should -;; also be moved into the backends. It stays for now, however, since -;; it is used in code below. -(defun vc-branch-p (rev) - "Return t if REV is a branch revision." - (not (eq nil (string-match "\\`[0-9]+\\(\\.[0-9]+\\.[0-9]+\\)*\\'" rev)))) - -;;;###autoload -(defun vc-branch-part (rev) - "Return the branch part of a revision number REV." - (let ((index (string-match "\\.[0-9]+\\'" rev))) - (when index - (substring rev 0 index)))) - (defun vc-default-responsible-p (_backend _file) "Indicate whether BACKEND is responsible for FILE. The default is to return nil always." -- 2.39.2