aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Steingold2017-11-03 12:00:35 -0400
committerSam Steingold2017-11-03 12:09:27 -0400
commit5ea5b2536ef580fe4b17b6dbd62df90d51e73e5f (patch)
tree4a7c53640b0dc4e6602e21d20c2c0d24ad5b9402
parent16748a5f6bd57ec0967ecb5e14ffe8af5f43d888 (diff)
downloademacs-5ea5b2536ef580fe4b17b6dbd62df90d51e73e5f.tar.gz
emacs-5ea5b2536ef580fe4b17b6dbd62df90d51e73e5f.zip
Finish the Bug#11728 work: hg & git
* lisp/vc/vc-git.el (vc-git--pushpull): Make `extra-args' a list. Do not set `compilation-error-regexp-alist', this is done in `vc-compilation-mode'. (vc-git-error-regexp-alist): Tweak the regexp. * lisp/vc/vc-hg.el (vc-hg-error-regexp-alist): Make non-trivial. (vc-hg--pushpull): Accept `post-processing' argument. Call them after the `command'. (vc-hg-pull): Pass the `post-processing' commands that show which are to be modified by the `update', and then run `update'.
-rw-r--r--lisp/vc/vc-git.el13
-rw-r--r--lisp/vc/vc-hg.el40
2 files changed, 30 insertions, 23 deletions
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 5e4632f4d6d..f95e67f4f56 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -857,7 +857,7 @@ It is based on `log-edit-mode', and has Git-specific extensions.")
857 (vc-git-command nil nil file "checkout" "-q" "--"))) 857 (vc-git-command nil nil file "checkout" "-q" "--")))
858 858
859(defvar vc-git-error-regexp-alist 859(defvar vc-git-error-regexp-alist
860 '(("^ \\(.+\\) |" 1 nil nil 0)) 860 '(("^ \\(.+\\)\\> *|" 1 nil nil 0))
861 "Value of `compilation-error-regexp-alist' in *vc-git* buffers.") 861 "Value of `compilation-error-regexp-alist' in *vc-git* buffers.")
862 862
863;; To be called via vc-pull from vc.el, which requires vc-dispatcher. 863;; To be called via vc-pull from vc.el, which requires vc-dispatcher.
@@ -882,17 +882,16 @@ If PROMPT is non-nil, prompt for the Git command to run."
882 (setq git-program (car args) 882 (setq git-program (car args)
883 command (cadr args) 883 command (cadr args)
884 args (cddr args))) 884 args (cddr args)))
885 (setq args (nconc args extra-args))
885 (require 'vc-dispatcher) 886 (require 'vc-dispatcher)
886 (apply 'vc-do-async-command buffer root git-program command args) 887 (apply 'vc-do-async-command buffer root git-program command args)
887 (with-current-buffer buffer 888 (with-current-buffer buffer
888 (vc-run-delayed 889 (vc-run-delayed
889 (vc-compilation-mode 'git) 890 (vc-compilation-mode 'git)
890 (setq-local compile-command 891 (setq-local compile-command
891 (concat git-program " " command " " extra-args " " 892 (concat git-program " " command " "
892 (if args (mapconcat 'identity args " ") ""))) 893 (mapconcat 'identity args " ")))
893 (setq-local compilation-directory root) 894 (setq-local compilation-directory root)
894 (setq-local compilation-error-regexp-alist
895 vc-git-error-regexp-alist)
896 ;; Either set `compilation-buffer-name-function' locally to nil 895 ;; Either set `compilation-buffer-name-function' locally to nil
897 ;; or use `compilation-arguments' to set `name-function'. 896 ;; or use `compilation-arguments' to set `name-function'.
898 ;; See `compilation-buffer-name'. 897 ;; See `compilation-buffer-name'.
@@ -906,13 +905,13 @@ If PROMPT is non-nil, prompt for the Git command to run."
906 "Pull changes into the current Git branch. 905 "Pull changes into the current Git branch.
907Normally, this runs \"git pull\". If PROMPT is non-nil, prompt 906Normally, this runs \"git pull\". If PROMPT is non-nil, prompt
908for the Git command to run." 907for the Git command to run."
909 (vc-git--pushpull "pull" prompt "--stat")) 908 (vc-git--pushpull "pull" prompt '("--stat")))
910 909
911(defun vc-git-push (prompt) 910(defun vc-git-push (prompt)
912 "Push changes from the current Git branch. 911 "Push changes from the current Git branch.
913Normally, this runs \"git push\". If PROMPT is non-nil, prompt 912Normally, this runs \"git push\". If PROMPT is non-nil, prompt
914for the Git command to run." 913for the Git command to run."
915 (vc-git--pushpull "push" prompt "")) 914 (vc-git--pushpull "push" prompt nil))
916 915
917(defun vc-git-merge-branch () 916(defun vc-git-merge-branch ()
918 "Merge changes into the current Git branch. 917 "Merge changes into the current Git branch.
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index 99c8869ae06..9e597a209a7 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -1296,12 +1296,8 @@ REV is the revision to check out into WORKFILE."
1296 (vc-hg-command buffer 1 nil "outgoing" "-n" (unless (string= remote-location "") 1296 (vc-hg-command buffer 1 nil "outgoing" "-n" (unless (string= remote-location "")
1297 remote-location))) 1297 remote-location)))
1298 1298
1299(defvar vc-hg-error-regexp-alist nil 1299(defvar vc-hg-error-regexp-alist
1300 ;; 'hg pull' does not list modified files, so, for now, the only 1300 '(("^M \\(.+\\)" 1 nil nil 0))
1301 ;; benefit of `vc-compilation-mode' is that one can get rid of
1302 ;; *vc-hg* buffer with 'q' or 'z'.
1303 ;; TODO: call 'hg incoming' before pull/merge to get the list of
1304 ;; modified files
1305 "Value of `compilation-error-regexp-alist' in *vc-hg* buffers.") 1301 "Value of `compilation-error-regexp-alist' in *vc-hg* buffers.")
1306 1302
1307(autoload 'vc-do-async-command "vc-dispatcher") 1303(autoload 'vc-do-async-command "vc-dispatcher")
@@ -1309,9 +1305,10 @@ REV is the revision to check out into WORKFILE."
1309(defvar compilation-directory) 1305(defvar compilation-directory)
1310(defvar compilation-arguments) ; defined in compile.el 1306(defvar compilation-arguments) ; defined in compile.el
1311 1307
1312(defun vc-hg--pushpull (command prompt &optional obsolete) 1308(defun vc-hg--pushpull (command prompt post-processing &optional obsolete)
1313 "Run COMMAND (a string; either push or pull) on the current Hg branch. 1309 "Run COMMAND (a string; either push or pull) on the current Hg branch.
1314If PROMPT is non-nil, prompt for the Hg command to run. 1310If PROMPT is non-nil, prompt for the Hg command to run.
1311POST-PROCESSING is a list of commands to execute after the command.
1315If OBSOLETE is non-nil, behave like the old versions of the Hg push/pull 1312If OBSOLETE is non-nil, behave like the old versions of the Hg push/pull
1316commands, which only operated on marked files." 1313commands, which only operated on marked files."
1317 (let (marked-list) 1314 (let (marked-list)
@@ -1327,18 +1324,14 @@ commands, which only operated on marked files."
1327 (let* ((root (vc-hg-root default-directory)) 1324 (let* ((root (vc-hg-root default-directory))
1328 (buffer (format "*vc-hg : %s*" (expand-file-name root))) 1325 (buffer (format "*vc-hg : %s*" (expand-file-name root)))
1329 (hg-program vc-hg-program) 1326 (hg-program vc-hg-program)
1330 ;; Fixme: before updating the working copy to the latest 1327 args)
1331 ;; state, should check if it's visiting an old revision.
1332 (args (if (equal command "pull") '("-u"))))
1333 ;; If necessary, prompt for the exact command. 1328 ;; If necessary, prompt for the exact command.
1334 ;; TODO if pushing, prompt if no default push location - cf bzr. 1329 ;; TODO if pushing, prompt if no default push location - cf bzr.
1335 (when prompt 1330 (when prompt
1336 (setq args (split-string 1331 (setq args (split-string
1337 (read-shell-command 1332 (read-shell-command
1338 (format "Hg %s command: " command) 1333 (format "Hg %s command: " command)
1339 (format "%s %s%s" hg-program command 1334 (format "%s %s" hg-program command)
1340 (if (not args) ""
1341 (concat " " (mapconcat 'identity args " "))))
1342 'vc-hg-history) 1335 'vc-hg-history)
1343 " " t)) 1336 " " t))
1344 (setq hg-program (car args) 1337 (setq hg-program (car args)
@@ -1347,10 +1340,17 @@ commands, which only operated on marked files."
1347 (apply 'vc-do-async-command buffer root hg-program command args) 1340 (apply 'vc-do-async-command buffer root hg-program command args)
1348 (with-current-buffer buffer 1341 (with-current-buffer buffer
1349 (vc-run-delayed 1342 (vc-run-delayed
1343 (dolist (cmd post-processing)
1344 (apply 'vc-do-command buffer nil hg-program nil cmd))
1350 (vc-compilation-mode 'hg) 1345 (vc-compilation-mode 'hg)
1351 (setq-local compile-command 1346 (setq-local compile-command
1352 (concat hg-program " " command " " 1347 (concat hg-program " " command " "
1353 (if args (mapconcat 'identity args " ") ""))) 1348 (mapconcat 'identity args " ")
1349 (mapconcat (lambda (args)
1350 (concat " && " hg-program " "
1351 (mapconcat 'identity
1352 args " ")))
1353 post-processing "")))
1354 (setq-local compilation-directory root) 1354 (setq-local compilation-directory root)
1355 ;; Either set `compilation-buffer-name-function' locally to nil 1355 ;; Either set `compilation-buffer-name-function' locally to nil
1356 ;; or use `compilation-arguments' to set `name-function'. 1356 ;; or use `compilation-arguments' to set `name-function'.
@@ -1371,7 +1371,15 @@ specific Mercurial pull command. The default is \"hg pull -u\",
1371which fetches changesets from the default remote repository and 1371which fetches changesets from the default remote repository and
1372then attempts to update the working directory." 1372then attempts to update the working directory."
1373 (interactive "P") 1373 (interactive "P")
1374 (vc-hg--pushpull "pull" prompt (called-interactively-p 'interactive))) 1374 (vc-hg--pushpull "pull" prompt
1375 ;; Fixme: before updating the working copy to the latest
1376 ;; state, should check if it's visiting an old revision.
1377 ;; post-processing: list modified files and update
1378 ;; NB: this will not work with "pull = --rebase"
1379 ;; or "pull = --update" in hgrc.
1380 '(("--pager" "no" "status" "--rev" "." "--rev" "tip")
1381 ("update"))
1382 (called-interactively-p 'interactive)))
1375 1383
1376(defun vc-hg-push (prompt) 1384(defun vc-hg-push (prompt)
1377 "Push changes from the current Mercurial branch. 1385 "Push changes from the current Mercurial branch.
@@ -1381,7 +1389,7 @@ for the Hg command to run.
1381If called interactively with a set of marked Log View buffers, 1389If called interactively with a set of marked Log View buffers,
1382call \"hg push -r REVS\" to push the specified revisions REVS." 1390call \"hg push -r REVS\" to push the specified revisions REVS."
1383 (interactive "P") 1391 (interactive "P")
1384 (vc-hg--pushpull "push" prompt (called-interactively-p 'interactive))) 1392 (vc-hg--pushpull "push" prompt nil (called-interactively-p 'interactive)))
1385 1393
1386(defun vc-hg-merge-branch () 1394(defun vc-hg-merge-branch ()
1387 "Merge incoming changes into the current working directory. 1395 "Merge incoming changes into the current working directory.