mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
New vc-async-checkin user option
* lisp/vc/vc.el (vc-async-checkin): New option. (vc-checkin): Don't use with-vc-properties on or display messages around asynchronous checkins. * lisp/vc/vc-git.el (vc-git-checkin): * lisp/vc/vc-hg.el (vc-hg-checkin, vc-hg-checkin-patch): Perform an async checkin operation when vc-async-checkin is non-nil. * doc/emacs/vc1-xtra.texi (General VC Options): * etc/NEWS: Document the new option. * lisp/vc/vc-dispatcher.el (vc-wait-for-process-before-save): New function. (vc-set-async-update): If the current buffer visits a file, call vc-refresh-state. * lisp/vc/vc-hg.el (vc-wait-for-process-before-save): Autoload. (vc-hg--async-command, vc-hg--async-buffer, vc-hg--command-1): New utilities, partially factored out of vc-hg-command. (vc-hg-merge-branch): Use vc-hg--async-command, thereby newly respecting vc-hg-global-switches.
This commit is contained in:
parent
3739b86f5a
commit
8e02537d0b
6 changed files with 219 additions and 84 deletions
|
|
@ -1209,32 +1209,49 @@ It is based on `log-edit-mode', and has Git-specific extensions."
|
|||
(vc-git-command nil 0 nil "apply" "--cached" patch-file)
|
||||
(delete-file patch-file))))
|
||||
(when to-stash (vc-git--stash-staged-changes to-stash)))
|
||||
;; When operating on the whole tree, better pass "-a" than ".",
|
||||
;; since "." fails when we're committing a merge.
|
||||
(apply #'vc-git-command nil 0
|
||||
(if (and only (not vc-git-patch-string)) files)
|
||||
(nconc (if msg-file (list "commit" "-F"
|
||||
(file-local-name msg-file))
|
||||
(list "commit" "-m"))
|
||||
(let ((args
|
||||
(vc-git--log-edit-extract-headers comment)))
|
||||
(when msg-file
|
||||
(let ((coding-system-for-write
|
||||
(or pcsw vc-git-commits-coding-system)))
|
||||
(write-region (car args) nil msg-file))
|
||||
(setq args (cdr args)))
|
||||
args)
|
||||
(unless vc-git-patch-string
|
||||
(if only (list "--only" "--") '("-a")))))
|
||||
(if (and msg-file (file-exists-p msg-file)) (delete-file msg-file))
|
||||
(when to-stash
|
||||
(let ((cached (make-nearby-temp-file "git-cached")))
|
||||
(unwind-protect
|
||||
(progn (with-temp-file cached
|
||||
(vc-git-command t 0 nil "stash" "show" "-p"))
|
||||
(vc-git-command nil 0 nil "apply" "--cached" cached))
|
||||
(delete-file cached))
|
||||
(vc-git-command nil 0 nil "stash" "drop")))))
|
||||
(let ((files (and only (not vc-git-patch-string) files))
|
||||
(args (vc-git--log-edit-extract-headers comment))
|
||||
(buffer (format "*vc-git : %s*" (expand-file-name root)))
|
||||
(post
|
||||
(lambda ()
|
||||
(when (and msg-file (file-exists-p msg-file))
|
||||
(delete-file msg-file))
|
||||
(when to-stash
|
||||
(let ((cached (make-nearby-temp-file "git-cached")))
|
||||
(unwind-protect
|
||||
(progn
|
||||
(with-temp-file cached
|
||||
(vc-git-command t 0 nil "stash" "show" "-p"))
|
||||
(vc-git-command nil 0 "apply" "--cached" cached))
|
||||
(delete-file cached))
|
||||
(vc-git-command nil 0 nil "stash" "drop"))))))
|
||||
(when msg-file
|
||||
(let ((coding-system-for-write
|
||||
(or pcsw vc-git-commits-coding-system)))
|
||||
(write-region (car args) nil msg-file))
|
||||
(setq args (cdr args)))
|
||||
(setq args (nconc (if msg-file
|
||||
(list "commit" "-F"
|
||||
(file-local-name msg-file))
|
||||
(list "commit" "-m"))
|
||||
args
|
||||
;; When operating on the whole tree, better pass
|
||||
;; "-a" than ".", since "." fails when we're
|
||||
;; committing a merge.
|
||||
(and (not vc-git-patch-string)
|
||||
(if only (list "--only" "--") '("-a")))))
|
||||
(if vc-async-checkin
|
||||
(progn (vc-wait-for-process-before-save
|
||||
(apply #'vc-do-async-command buffer root
|
||||
vc-git-program (nconc args files))
|
||||
"Finishing checking in files...")
|
||||
(with-current-buffer buffer
|
||||
(vc-run-delayed
|
||||
(vc-compilation-mode 'git)
|
||||
(funcall post)))
|
||||
(vc-set-async-update buffer))
|
||||
(apply #'vc-git-command nil 0 files args)
|
||||
(funcall post)))))
|
||||
|
||||
(defun vc-git--stash-staged-changes (files)
|
||||
"Stash only the staged changes to FILES."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue