This fixes Bug#3860.
* lisp/vc/vc.el (vc-resolve-conflicts): New user option.
* lisp/vc/vc-bzr.el (vc-bzr-resolve-conflicts): New user option.
(vc-bzr-find-file-hook): Use it.
* lisp/vc/vc-hg.el (vc-hg-resolve-conflicts): New user option.
(vc-hg-find-file-hook): Use it.
* lisp/vc/vc-svn.el (vc-svn-resolve-conflicts): New user option.
(vc-svn-find-file-hook): Use it.
* lisp/vc/vc-git.el (vc-git-resolve-conflicts): Support
'default' as an option. Adjust docstring and version.
(vc-git-find-file-hook): Respect vc-resolve-conflicts.
* etc/NEWS: Announce the new options.
(cherry picked from commit
acb96a5ca8ac3bef80ca2ff1496cacb3ab57c87a)
(repeat :tag "Argument List" :value ("") string))
:version "24.1")
+(defcustom vc-bzr-resolve-conflicts 'default
+ "Whether to mark conflicted file as resolved upon saving.
+If this is t and there are no more conflict markers in the file,
+VC will mark the conflicts in the saved file as resolved.
+A value of `default' means to use the value of `vc-resolve-conflicts'."
+ :type '(choice (const :tag "Don't resolve" nil)
+ (const :tag "Resolve" t)
+ (const :tag "Use vc-resolve-conflicts" default))
+ :version "31.1")
+
;; since v0.9, bzr supports removing the progress indicators
;; by setting environment variable BZR_PROGRESS_BAR to "none".
(defun vc-bzr-command (bzr-command buffer okstatus file-or-list &rest args)
;; but the one in `bzr pull' isn't, so it would be good to provide an
;; elisp function to remerge from the .BASE/OTHER/THIS files.
(smerge-start-session)
- (add-hook 'after-save-hook #'vc-bzr-resolve-when-done nil t)
+ (when (or (eq vc-bzr-resolve-conflicts t)
+ (and (eq vc-bzr-resolve-conflicts 'default)
+ vc-resolve-conflicts))
+ (add-hook 'after-save-hook #'vc-bzr-resolve-when-done nil t))
(vc-message-unresolved-conflicts buffer-file-name)))
(defun vc-bzr-clone (remote directory rev)
(repeat :tag "Argument List" :value ("") string))
:version "30.1")
-(defcustom vc-git-resolve-conflicts t
- "When non-nil, mark conflicted file as resolved upon saving.
+(defcustom vc-git-resolve-conflicts 'default
+ "Whether to mark conflicted file as resolved upon saving.
That is performed after all conflict markers in it have been removed.
+
+If this is t and there are no more conflict markers in the file,
+VC will mark the conflicts in the saved file as resolved.
+
If the value is `unstage-maybe', and no merge, rebase or similar
operation is in progress, then after the last conflict is resolved, also
-clear the staging area."
+clear the staging area.
+
+A value of `default' means to use the value of `vc-resolve-conflicts'."
:type '(choice (const :tag "Don't resolve" nil)
(const :tag "Resolve" t)
(const :tag "Resolve and maybe unstage all files"
- unstage-maybe))
- :version "25.1")
+ unstage-maybe)
+ (const :tag "Use vc-resolve-conflicts" default))
+ :version "31.1")
(defcustom vc-git-program "git"
"Name of the Git executable (excluding any arguments)."
(goto-char (point-min))
(re-search-forward "^<<<<<<< " nil 'noerror)))
(smerge-start-session)
- (when vc-git-resolve-conflicts
+ (unless (or (null vc-git-resolve-conflicts)
+ (and (eq vc-git-resolve-conflicts 'default)
+ (not vc-resolve-conflicts)))
(add-hook 'after-save-hook #'vc-git-resolve-when-done nil 'local))
(vc-message-unresolved-conflicts buffer-file-name)))
(const :tag "Ask" ask))
:version "28.1")
+(defcustom vc-hg-resolve-conflicts 'default
+ "Whether to mark conflicted file as resolved upon saving.
+If this is t and there are no more conflict markers in the file,
+VC will mark the conflicts in the saved file as resolved.
+A value of `default' means to use the value of `vc-resolve-conflicts'."
+ :type '(choice (const :tag "Don't resolve" nil)
+ (const :tag "Resolve" t)
+ (const :tag "Use vc-resolve-conflicts" default))
+ :version "31.1")
+
\f
;; Clear up the cache to force vc-call to check again and discover
;; new functions when we reload this file.
;; Hg may not recognize "conflict" as a state, but we can do better.
(vc-file-setprop buffer-file-name 'vc-state 'conflict)
(smerge-start-session)
- (add-hook 'after-save-hook #'vc-hg-resolve-when-done nil t)
+ (when (or (eq vc-hg-resolve-conflicts t)
+ (and (eq vc-hg-resolve-conflicts 'default)
+ vc-resolve-conflicts))
+ (add-hook 'after-save-hook #'vc-hg-resolve-when-done nil t))
(vc-message-unresolved-conflicts buffer-file-name)))
(defun vc-hg-clone (remote directory rev)
:version "24.1" ; no longer consult the obsolete vc-header-alist
:type '(repeat string))
+(defcustom vc-svn-resolve-conflicts 'default
+ "Whether to mark conflicted file as resolved upon saving.
+If this is t and there are no more conflict markers in the file,
+VC will mark the conflicts in the saved file as resolved.
+A value of `default' means to use the value of `vc-resolve-conflicts'."
+ :type '(choice (const :tag "Don't resolve" nil)
+ (const :tag "Resolve" t)
+ (const :tag "Use vc-resolve-conflicts" default))
+ :version "31.1")
+
;; We want to autoload it for use by the autoloaded version of
;; vc-svn-registered, but we want the value to be compiled at startup, not
;; at dump time.
;; There are conflict markers.
(progn
(smerge-start-session)
- (add-hook 'after-save-hook #'vc-svn-resolve-when-done nil t))
+ (when (or (eq vc-svn-resolve-conflicts t)
+ (and (eq vc-svn-resolve-conflicts 'default)
+ vc-resolve-conflicts))
+ (add-hook 'after-save-hook #'vc-svn-resolve-when-done nil t)))
;; There are no conflict markers. This is problematic: maybe it means
;; the conflict has been resolved and we should immediately call "svn
;; resolved", or it means that the file's type does not allow Svn to
:value-type ,vc-cloneable-backends-custom-type)
:version "31.1")
+(defcustom vc-resolve-conflicts t
+ "Whether to mark conflicted file as resolved upon saving.
+
+If this is non-nil and there are no more conflict markers in the file,
+VC will mark the conflicts in the saved file as resolved. This is
+only meaningful for VCS that handle conflicts by inserting conflict
+markers in a conflicted file.
+
+When saving a conflicted file, VC first tries to use the value
+of `vc-BACKEND-resolve-conflicts', for handling backend-specific
+settings. It defaults to this option if that option has the special
+value `default'."
+ :type 'boolean
+ :version "31.1")
+
\f
;; File property caching