aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Steingold2017-11-03 12:00:35 -0400
committerAlan Third2018-06-12 21:15:13 +0100
commit6d4cbe80844a56e0b469fd6304ab7f24daa3d3af (patch)
treee199a14cd70040eeddf39e55db06ec4b8ae4c7ce
parent66a491fbec005b6a7ba255612ddb6efcf1a4bbcb (diff)
downloademacs-6d4cbe80844a56e0b469fd6304ab7f24daa3d3af.tar.gz
emacs-6d4cbe80844a56e0b469fd6304ab7f24daa3d3af.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 6650c5d764a..c6b08e942f3 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -860,7 +860,7 @@ It is based on `log-edit-mode', and has Git-specific extensions.")
860 (vc-git-command nil nil file "checkout" "-q" "--"))) 860 (vc-git-command nil nil file "checkout" "-q" "--")))
861 861
862(defvar vc-git-error-regexp-alist 862(defvar vc-git-error-regexp-alist
863 '(("^ \\(.+\\) |" 1 nil nil 0)) 863 '(("^ \\(.+\\)\\> *|" 1 nil nil 0))
864 "Value of `compilation-error-regexp-alist' in *vc-git* buffers.") 864 "Value of `compilation-error-regexp-alist' in *vc-git* buffers.")
865 865
866;; To be called via vc-pull from vc.el, which requires vc-dispatcher. 866;; To be called via vc-pull from vc.el, which requires vc-dispatcher.
@@ -885,17 +885,16 @@ If PROMPT is non-nil, prompt for the Git command to run."
885 (setq git-program (car args) 885 (setq git-program (car args)
886 command (cadr args) 886 command (cadr args)
887 args (cddr args))) 887 args (cddr args)))
888 (setq args (nconc args extra-args))
888 (require 'vc-dispatcher) 889 (require 'vc-dispatcher)
889 (apply 'vc-do-async-command buffer root git-program command args) 890 (apply 'vc-do-async-command buffer root git-program command args)
890 (with-current-buffer buffer 891 (with-current-buffer buffer
891 (vc-run-delayed 892 (vc-run-delayed
892 (vc-compilation-mode 'git) 893 (vc-compilation-mode 'git)
893 (setq-local compile-command 894 (setq-local compile-command
894 (concat git-program " " command " " extra-args " " 895 (concat git-program " " command " "
895 (if args (mapconcat 'identity args " ") ""))) 896 (mapconcat 'identity args " ")))
896 (setq-local compilation-directory root) 897 (setq-local compilation-directory root)
897 (setq-local compilation-error-regexp-alist
898 vc-git-error-regexp-alist)
899 ;; Either set `compilation-buffer-name-function' locally to nil 898 ;; Either set `compilation-buffer-name-function' locally to nil
900 ;; or use `compilation-arguments' to set `name-function'. 899 ;; or use `compilation-arguments' to set `name-function'.
901 ;; See `compilation-buffer-name'. 900 ;; See `compilation-buffer-name'.
@@ -909,13 +908,13 @@ If PROMPT is non-nil, prompt for the Git command to run."
909 "Pull changes into the current Git branch. 908 "Pull changes into the current Git branch.
910Normally, this runs \"git pull\". If PROMPT is non-nil, prompt 909Normally, this runs \"git pull\". If PROMPT is non-nil, prompt
911for the Git command to run." 910for the Git command to run."
912 (vc-git--pushpull "pull" prompt "--stat")) 911 (vc-git--pushpull "pull" prompt '("--stat")))
913 912
914(defun vc-git-push (prompt) 913(defun vc-git-push (prompt)
915 "Push changes from the current Git branch. 914 "Push changes from the current Git branch.
916Normally, this runs \"git push\". If PROMPT is non-nil, prompt 915Normally, this runs \"git push\". If PROMPT is non-nil, prompt
917for the Git command to run." 916for the Git command to run."
918 (vc-git--pushpull "push" prompt "")) 917 (vc-git--pushpull "push" prompt nil))
919 918
920(defun vc-git-merge-branch () 919(defun vc-git-merge-branch ()
921 "Merge changes into the current Git branch. 920 "Merge changes into the current Git branch.
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index 2deac2aae27..08b1be8f6d3 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.