diff options
| author | Chong Yidong | 2011-01-28 22:12:32 -0500 |
|---|---|---|
| committer | Chong Yidong | 2011-01-28 22:12:32 -0500 |
| commit | 659114fdba7d5ea14541cdc713c7f9745eb93c46 (patch) | |
| tree | 32cbb5f428dc239902df39d7869377b85e2338fb | |
| parent | bc68bd3998b317499fb5df713470f78fbdf3a78d (diff) | |
| download | emacs-659114fdba7d5ea14541cdc713c7f9745eb93c46.tar.gz emacs-659114fdba7d5ea14541cdc713c7f9745eb93c46.zip | |
Rudimentary support for vc-pull and vc-merge in Git and Mercurial.
* lisp/vc/vc.el (vc-pull): Make vc-update an alias for this, instead of
the other way around.
* lisp/vc/vc-git.el (vc-git-branches, vc-git-pull)
(vc-git-merge-branch): New functions.
(vc-git-history): New var.
* lisp/vc/vc-hg.el (vc-hg-history): New var.
(vc-hg-pull): Perform default pull if called via Lisp by vc-pull.
(vc-hg-merge-branch): New function.
| -rw-r--r-- | etc/NEWS | 14 | ||||
| -rw-r--r-- | lisp/ChangeLog | 13 | ||||
| -rw-r--r-- | lisp/vc/vc-dispatcher.el | 2 | ||||
| -rw-r--r-- | lisp/vc/vc-git.el | 51 | ||||
| -rw-r--r-- | lisp/vc/vc-hg.el | 47 | ||||
| -rw-r--r-- | lisp/vc/vc.el | 4 |
6 files changed, 111 insertions, 20 deletions
| @@ -589,20 +589,20 @@ on a D-Bus without simultaneously registering a property or a method. | |||
| 589 | ** VC and related modes | 589 | ** VC and related modes |
| 590 | 590 | ||
| 591 | *** Support for pulling on distributed version control systems. | 591 | *** Support for pulling on distributed version control systems. |
| 592 | The vc-update command now runs a "pull" operation, if it is supported. | 592 | The vc-pull command runs a "pull" operation, if it is supported. |
| 593 | This updates the current branch from upstream. A prefix argument | 593 | This updates the current branch from upstream. A prefix argument |
| 594 | means to prompt the user for command specifics, e.g. a pull location. | 594 | means to prompt the user for specifics, e.g. a pull location. |
| 595 | 595 | ||
| 596 | **** vc-pull is an alias for vc-update. | 596 | **** vc-update is now an alias for vc-update. |
| 597 | 597 | ||
| 598 | **** Currently supported by Bzr. | 598 | **** Currently supported by Bzr, Git, and Mercurial. |
| 599 | 599 | ||
| 600 | *** Support for merging on distributed version control systems. | 600 | *** Support for merging on distributed version control systems. |
| 601 | The vc-merge command now runs a "merge" operation, if it is supported. | 601 | The vc-merge command now runs a "merge" operation, if it is supported. |
| 602 | This merges another branch into the current one. A prefix argument | 602 | This merges another branch into the current one. This command prompts |
| 603 | means to prompt the user for command specifics, e.g. a merge location. | 603 | the user for specifics, e.g. a merge source. |
| 604 | 604 | ||
| 605 | **** Currently supported by Bzr. | 605 | **** Currently supported by Bzr, Git, and Mercurial. |
| 606 | 606 | ||
| 607 | ** Miscellaneous | 607 | ** Miscellaneous |
| 608 | 608 | ||
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c1477a6b8a5..41242360c60 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2011-01-29 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * vc/vc-hg.el (vc-hg-history): New var. | ||
| 4 | (vc-hg-pull): Perform default pull if called via Lisp by vc-pull. | ||
| 5 | (vc-hg-merge-branch): New function. | ||
| 6 | |||
| 7 | * vc/vc.el (vc-pull): Make vc-update an alias for this, instead of | ||
| 8 | the other way around. | ||
| 9 | |||
| 10 | * vc/vc-git.el (vc-git-branches, vc-git-pull) | ||
| 11 | (vc-git-merge-branch): New functions. | ||
| 12 | (vc-git-history): New var. | ||
| 13 | |||
| 1 | 2011-01-28 Chong Yidong <cyd@stupidchicken.com> | 14 | 2011-01-28 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 15 | ||
| 3 | * vc/vc-dispatcher.el (vc-do-async-command): New function. | 16 | * vc/vc-dispatcher.el (vc-do-async-command): New function. |
diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el index 19a276b635c..53b0d9ef8b3 100644 --- a/lisp/vc/vc-dispatcher.el +++ b/lisp/vc/vc-dispatcher.el | |||
| @@ -373,7 +373,7 @@ Display the buffer in some window, but don't select it." | |||
| 373 | (unless (eq (point) (point-min)) | 373 | (unless (eq (point) (point-min)) |
| 374 | (insert "\n")) | 374 | (insert "\n")) |
| 375 | (setq new-window-start (point)) | 375 | (setq new-window-start (point)) |
| 376 | (insert "Running \"" command " ") | 376 | (insert "Running \"" command) |
| 377 | (dolist (arg args) | 377 | (dolist (arg args) |
| 378 | (insert " " arg)) | 378 | (insert " " arg)) |
| 379 | (insert "\"...\n") | 379 | (insert "\"...\n") |
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index c3ffa1fcf46..592fc77e2e3 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el | |||
| @@ -122,6 +122,9 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches." | |||
| 122 | (defvar vc-git-commits-coding-system 'utf-8 | 122 | (defvar vc-git-commits-coding-system 'utf-8 |
| 123 | "Default coding system for git commits.") | 123 | "Default coding system for git commits.") |
| 124 | 124 | ||
| 125 | ;; History of Git commands. | ||
| 126 | (defvar vc-git-history nil) | ||
| 127 | |||
| 125 | ;;; BACKEND PROPERTIES | 128 | ;;; BACKEND PROPERTIES |
| 126 | 129 | ||
| 127 | (defun vc-git-revision-granularity () 'repository) | 130 | (defun vc-git-revision-granularity () 'repository) |
| @@ -526,6 +529,21 @@ or an empty string if none." | |||
| 526 | 'help-echo stash-help-echo | 529 | 'help-echo stash-help-echo |
| 527 | 'face 'font-lock-variable-name-face)))))) | 530 | 'face 'font-lock-variable-name-face)))))) |
| 528 | 531 | ||
| 532 | (defun vc-git-branches () | ||
| 533 | "Return the existing branches, as a list of strings. | ||
| 534 | The car of the list is the current branch." | ||
| 535 | (with-temp-buffer | ||
| 536 | (call-process "git" nil t nil "branch") | ||
| 537 | (goto-char (point-min)) | ||
| 538 | (let (current-branch branches) | ||
| 539 | (while (not (eobp)) | ||
| 540 | (when (looking-at "^\\([ *]\\) \\(.+\\)$") | ||
| 541 | (if (string-equal (match-string 1) "*") | ||
| 542 | (setq current-branch (match-string 2)) | ||
| 543 | (push (match-string 2) branches))) | ||
| 544 | (forward-line 1)) | ||
| 545 | (cons current-branch (nreverse branches))))) | ||
| 546 | |||
| 529 | ;;; STATE-CHANGING FUNCTIONS | 547 | ;;; STATE-CHANGING FUNCTIONS |
| 530 | 548 | ||
| 531 | (defun vc-git-create-repo () | 549 | (defun vc-git-create-repo () |
| @@ -587,6 +605,39 @@ or an empty string if none." | |||
| 587 | (vc-git-command nil 0 file "reset" "-q" "--") | 605 | (vc-git-command nil 0 file "reset" "-q" "--") |
| 588 | (vc-git-command nil nil file "checkout" "-q" "--"))) | 606 | (vc-git-command nil nil file "checkout" "-q" "--"))) |
| 589 | 607 | ||
| 608 | (defun vc-git-pull (prompt) | ||
| 609 | "Pull changes into the current Git branch. | ||
| 610 | Normally, this runs \"git pull\".If there is no default | ||
| 611 | location from which to pull or update, or if PROMPT is non-nil, | ||
| 612 | prompt for the Git command to run." | ||
| 613 | (let* ((root (vc-git-root default-directory)) | ||
| 614 | (buffer (format "*vc-git : %s*" (expand-file-name root))) | ||
| 615 | (command "pull") | ||
| 616 | (git-program "git") | ||
| 617 | args) | ||
| 618 | ;; If necessary, prompt for the exact command. | ||
| 619 | (when prompt | ||
| 620 | (setq args (split-string | ||
| 621 | (read-shell-command "Run Git (like this): " | ||
| 622 | "git pull" | ||
| 623 | 'vc-git-history) | ||
| 624 | " " t)) | ||
| 625 | (setq git-program (car args) | ||
| 626 | command (cadr args) | ||
| 627 | args (cddr args))) | ||
| 628 | (apply 'vc-do-async-command buffer root git-program command args))) | ||
| 629 | |||
| 630 | (defun vc-git-merge-branch () | ||
| 631 | "Merge changes into the current Git branch. | ||
| 632 | This prompts for a branch to merge from." | ||
| 633 | (let* ((root (vc-git-root default-directory)) | ||
| 634 | (buffer (format "*vc-git : %s*" (expand-file-name root))) | ||
| 635 | (branches (cdr (vc-git-branches))) | ||
| 636 | (merge-source | ||
| 637 | (completing-read "Merge from branch: " branches nil t))) | ||
| 638 | (apply 'vc-do-async-command buffer root "git" "merge" | ||
| 639 | (list merge-source)))) | ||
| 640 | |||
| 590 | ;;; HISTORY FUNCTIONS | 641 | ;;; HISTORY FUNCTIONS |
| 591 | 642 | ||
| 592 | (defun vc-git-print-log (files buffer &optional shortlog start-revision limit) | 643 | (defun vc-git-print-log (files buffer &optional shortlog start-revision limit) |
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index 890d97923bc..8acff1ee2ca 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el | |||
| @@ -141,6 +141,8 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches." | |||
| 141 | 141 | ||
| 142 | ;;; Properties of the backend | 142 | ;;; Properties of the backend |
| 143 | 143 | ||
| 144 | (defvar vc-hg-history nil) | ||
| 145 | |||
| 144 | (defun vc-hg-revision-granularity () 'repository) | 146 | (defun vc-hg-revision-granularity () 'repository) |
| 145 | (defun vc-hg-checkout-model (files) 'implicit) | 147 | (defun vc-hg-checkout-model (files) 'implicit) |
| 146 | 148 | ||
| @@ -607,16 +609,41 @@ REV is the revision to check out into WORKFILE." | |||
| 607 | (mapcar (lambda (arg) (list "-r" arg)) marked-list))) | 609 | (mapcar (lambda (arg) (list "-r" arg)) marked-list))) |
| 608 | (error "No log entries selected for push")))) | 610 | (error "No log entries selected for push")))) |
| 609 | 611 | ||
| 610 | (defun vc-hg-pull () | 612 | (defun vc-hg-pull (prompt) |
| 611 | (interactive) | 613 | (interactive "P") |
| 612 | (let ((marked-list (log-view-get-marked))) | 614 | (let (marked-list) |
| 613 | (if marked-list | 615 | (if (and (called-interactively-p 'interactive) |
| 614 | (apply #'vc-hg-command | 616 | (setq marked-list (log-view-get-marked))) |
| 615 | nil 0 nil | 617 | (apply #'vc-hg-command |
| 616 | "pull" | 618 | nil 0 nil |
| 617 | (apply 'nconc | 619 | "pull" |
| 618 | (mapcar (lambda (arg) (list "-r" arg)) marked-list))) | 620 | (apply 'nconc |
| 619 | (error "No log entries selected for pull")))) | 621 | (mapcar (lambda (arg) (list "-r" arg)) |
| 622 | marked-list))) | ||
| 623 | (let* ((root (vc-hg-root default-directory)) | ||
| 624 | (buffer (format "*vc-hg : %s*" (expand-file-name root))) | ||
| 625 | (command "pull") | ||
| 626 | (hg-program "hg") | ||
| 627 | ;; Todo: maybe check if we're up-to-date before updating | ||
| 628 | ;; the working copy to the latest state. | ||
| 629 | (args '("-u"))) | ||
| 630 | ;; If necessary, prompt for the exact command. | ||
| 631 | (when prompt | ||
| 632 | (setq args (split-string | ||
| 633 | (read-shell-command "Run Hg (like this): " "hg -u" | ||
| 634 | 'vc-hg-history) | ||
| 635 | " " t)) | ||
| 636 | (setq hg-program (car args) | ||
| 637 | command (cadr args) | ||
| 638 | args (cddr args))) | ||
| 639 | (apply 'vc-do-async-command buffer root hg-program | ||
| 640 | command args))))) | ||
| 641 | |||
| 642 | (defun vc-hg-merge-branch () | ||
| 643 | "Merge incoming changes into the current Mercurial working directory." | ||
| 644 | (let* ((root (vc-hg-root default-directory)) | ||
| 645 | (buffer (format "*vc-hg : %s*" (expand-file-name root)))) | ||
| 646 | (apply 'vc-do-async-command buffer root "hg" '("merge")))) | ||
| 620 | 647 | ||
| 621 | ;;; Internal functions | 648 | ;;; Internal functions |
| 622 | 649 | ||
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 7f11a4b3333..be0f568d304 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el | |||
| @@ -2297,7 +2297,7 @@ depending on the underlying version-control system." | |||
| 2297 | (define-obsolete-function-alias 'vc-revert-buffer 'vc-revert "23.1") | 2297 | (define-obsolete-function-alias 'vc-revert-buffer 'vc-revert "23.1") |
| 2298 | 2298 | ||
| 2299 | ;;;###autoload | 2299 | ;;;###autoload |
| 2300 | (defun vc-update (&optional arg) | 2300 | (defun vc-pull (&optional arg) |
| 2301 | "Update the current fileset or branch. | 2301 | "Update the current fileset or branch. |
| 2302 | On a distributed version control system, this runs a \"pull\" | 2302 | On a distributed version control system, this runs a \"pull\" |
| 2303 | operation to update the current branch, prompting for an argument | 2303 | operation to update the current branch, prompting for an argument |
| @@ -2337,7 +2337,7 @@ tip revision are merged into the working file." | |||
| 2337 | (error "VC update is unsupported for `%s'" backend))))) | 2337 | (error "VC update is unsupported for `%s'" backend))))) |
| 2338 | 2338 | ||
| 2339 | ;;;###autoload | 2339 | ;;;###autoload |
| 2340 | (defalias 'vc-pull 'vc-update) | 2340 | (defalias 'vc-update 'vc-pull) |
| 2341 | 2341 | ||
| 2342 | (defun vc-version-backup-file (file &optional rev) | 2342 | (defun vc-version-backup-file (file &optional rev) |
| 2343 | "Return name of backup file for revision REV of FILE. | 2343 | "Return name of backup file for revision REV of FILE. |