Function: vc-merge

vc-merge is an autoloaded, interactive and byte-compiled function defined in vc.el.gz.

Signature

(vc-merge)

Documentation

Perform a version control merge operation.

You must be visiting a version controlled file, or in a vc-dir buffer. On a distributed version control system, this runs a "merge" operation to incorporate changes from another branch onto the current branch, prompting for an argument list.

On a non-distributed version control system, this merges changes between two revisions into the current fileset. This asks for two revisions to merge from in the minibuffer. If the first revision is a branch number, then merge all changes from that branch. If the first revision is empty, merge the most recent changes from the current branch.

Probably introduced at or before Emacs version 20.3.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/vc/vc.el.gz
;;;###autoload
(defun vc-merge ()
  "Perform a version control merge operation.
You must be visiting a version controlled file, or in a `vc-dir' buffer.
On a distributed version control system, this runs a \"merge\"
operation to incorporate changes from another branch onto the
current branch, prompting for an argument list.

On a non-distributed version control system, this merges changes
between two revisions into the current fileset.  This asks for
two revisions to merge from in the minibuffer.  If the first
revision is a branch number, then merge all changes from that
branch.  If the first revision is empty, merge the most recent
changes from the current branch."
  (interactive)
  (let* ((vc-fileset (vc-deduce-fileset t))
	 (backend (car vc-fileset))
	 (files (cadr vc-fileset)))
    (cond
     ;; If a branch-merge operation is defined, use it.
     ((vc-find-backend-function backend 'merge-branch)
      (vc-call-backend backend 'merge-branch))
     ;; Otherwise, do a per-file merge.
     ((vc-find-backend-function backend 'merge-file)
      (vc-buffer-sync)
      (dolist (file files)
	(let* ((state (vc-state file))
	       status)
	  (cond
	   ((stringp state)	;; Locking VCses only
	    (error "File %s is locked by %s" file state))
	   ((not (vc-editable-p file))
	    (vc-checkout file t)))
	  (setq status (vc-call-backend backend 'merge-file file))
	  (vc-maybe-resolve-conflicts file status "WORKFILE" "MERGE SOURCE"))))
     (t
      (error "Sorry, merging is not implemented for %s" backend)))))