Function: vc--match-branch-name-regexps
vc--match-branch-name-regexps is a byte-compiled function defined in
vc.el.gz.
Signature
(vc--match-branch-name-regexps BRANCH)
Documentation
Match against vc-trunk-branch-regexps and vc-topic-branch-regexps.
See the docstrings for those two variables for how this matching works.
If BRANCH matches both sets of regexps we signal an error; this is to allow for future extension. If BRANCH matches neither set of regexps return nil to mean that the defcustoms don't decide the matter of which kind of branch this is.
Source Code
;; Defined in /usr/src/emacs/lisp/vc/vc.el.gz
(defun vc--match-branch-name-regexps (branch)
"Match against `vc-trunk-branch-regexps' and `vc-topic-branch-regexps'.
See the docstrings for those two variables for how this matching works.
If BRANCH matches both sets of regexps we signal an error; this is to
allow for future extension.
If BRANCH matches neither set of regexps return nil to mean that the
defcustoms don't decide the matter of which kind of branch this is."
(when (and (eq vc-trunk-branch-regexps t)
(eq vc-topic-branch-regexps t))
(user-error "\
`vc-trunk-branch-regexps' and `vc-topic-branch-regexps' cannot both be `t'"))
(cl-labels ((join-regexps (regexps)
(mapconcat (lambda (elt)
(format (if (equal (regexp-quote elt) elt)
"\\`%s\\'"
"\\(?:%s\\)")
elt))
regexps "\\|"))
(compile-regexps (regexps)
(if regexps
(let* ((negated (eq (car regexps) 'not))
(joined (join-regexps (if negated
(cdr regexps)
regexps))))
(if negated
(lambda (s) (not (string-match-p joined s)))
(lambda (s) (string-match-p joined s))))
#'ignore))
(match-trunk (if (eq vc-trunk-branch-regexps t)
(lambda (s) (not (match-topic s)))
(compile-regexps vc-trunk-branch-regexps)))
(match-topic (if (eq vc-topic-branch-regexps t)
(lambda (s) (not (match-trunk s)))
(compile-regexps vc-topic-branch-regexps))))
(let ((trunk (match-trunk branch))
(topic (match-topic branch)))
(cond ((and trunk topic)
(error "Branch name `%s' matches both \
`vc-trunk-branch-regexps' and `vc-topic-branch-regexps'"
branch))
(trunk 'trunk)
(topic 'topic)))))