Function: vc-trunk-or-topic-p

vc-trunk-or-topic-p is a byte-compiled function defined in vc.el.gz.

Signature

(vc-trunk-or-topic-p &optional BRANCH BACKEND)

Documentation

Return whether BRANCH, or the current branch, is a trunk or a topic.

Returns trunk if BRANCH is definitely a trunk, topic if BRANCH is definitely a topic, or nil if no general determination can be made.

In VC, trunk branches are those where you've finished sharing the work on the branch with your collaborators just as soon as you've checked it in, and in the case of a decentralized VCS, pushed it. In addition, typically you never delete trunk branches. The specific VCS workflow you are using may only acknowledge a single trunk, and give other names to kinds of branches which VC would consider to be just further trunks.

Topic branches are those where checking in work, and pushing it in the case of a decentralized VCS, is not enough to complete the process of sharing the changes with your collaborators. In addition, it's required that you merge the topic branch into another branch. After this is done, typically you delete the topic branch. Topic branches are sometimes called "feature branches", though it is also common for that term to be reserved for only a certain kind of topic branch.

Determining whether BRANCH is a trunk or a topic proceeds in two stages:
1. If BRANCH is non-nil, compare that name against
   vc-trunk-branch-regexps and vc-topic-branch-regexps, which see.
   If BRANCH is nil, ask the backend for the name of the current branch.
   If the backend returns a name, compare it against
   vc-trunk-branch-regexps and vc-topic-branch-regexps.
2. If that doesn't settle it, either because the backend reports that
   the current branch has no name or because comparing the name against
   the two regexp defcustoms yields no decisive answer, call the backend's
   trunk-or-topic-p VC API function.

If trunk and/or topic branches in your project can be identified by name, include regexps matching those names in vc-trunk-branch-regexps and/or vc-topic-branch-regexps as appropriate. This is more reliable than letting Emacs ask the backend.

BACKEND is the VC backend.

Source Code

;; Defined in /usr/src/emacs/lisp/vc/vc.el.gz
(defun vc-trunk-or-topic-p (&optional branch backend)
  "Return whether BRANCH, or the current branch, is a trunk or a topic.
Returns `trunk' if BRANCH is definitely a trunk, `topic' if BRANCH is
definitely a topic, or nil if no general determination can be made.

In VC, trunk branches are those where you've finished sharing the work
on the branch with your collaborators just as soon as you've checked it
in, and in the case of a decentralized VCS, pushed it.  In addition,
typically you never delete trunk branches.  The specific VCS workflow
you are using may only acknowledge a single trunk, and give other names
to kinds of branches which VC would consider to be just further trunks.

Topic branches are those where checking in work, and pushing it in the
case of a decentralized VCS, is not enough to complete the process of
sharing the changes with your collaborators.  In addition, it's required
that you merge the topic branch into another branch.  After this is
done, typically you delete the topic branch.  Topic branches are
sometimes called \"feature branches\", though it is also common for that
term to be reserved for only a certain kind of topic branch.

Determining whether BRANCH is a trunk or a topic proceeds in two stages:
1. If BRANCH is non-nil, compare that name against
   `vc-trunk-branch-regexps' and `vc-topic-branch-regexps', which see.
   If BRANCH is nil, ask the backend for the name of the current branch.
   If the backend returns a name, compare it against
   `vc-trunk-branch-regexps' and `vc-topic-branch-regexps'.
2. If that doesn't settle it, either because the backend reports that
   the current branch has no name or because comparing the name against
   the two regexp defcustoms yields no decisive answer, call the backend's
   `trunk-or-topic-p' VC API function.

If trunk and/or topic branches in your project can be identified by
name, include regexps matching those names in `vc-trunk-branch-regexps'
and/or `vc-topic-branch-regexps' as appropriate.  This is more reliable
than letting Emacs ask the backend.

BACKEND is the VC backend."
  (let* ((backend (or backend (vc-deduce-backend)))
         (branch (or branch (vc-call-backend backend 'working-branch))))
    (or (and branch (vc--match-branch-name-regexps branch))
        ;; It's okay to pass nil BRANCH here, which is what happens in
        ;; case of a VCS without named branches or where the current
        ;; branch has no name.
        (vc-call-backend backend 'trunk-or-topic-p branch))))