changeset 93382:8e46096e0cb3

* vc.el (vc-status-menu-map, vc-status-mode-map): Bind vc-revert. (vc-status-refresh): Create a temporary buffer and call the `dir-status' backend function from that buffer. * vc-bzr.el (vc-bzr-dir-status): Don't create a buffer. (vc-bzr-after-dir-status): Don't kill the buffer. * vc-cvs.el (vc-cvs-dir-status): Don't create a buffer. (vc-cvs-after-dir-status): Don't kill the buffer. * vc-git.el (vc-git-dir-status): Don't create a buffer. (vc-git-after-dir-status-stage2): Don't kill the buffer. * vc-hg.el (vc-hg-dir-status): Don't create a buffer. (vc-hg-after-dir-status): Don't kill the buffer. * vc-svn.el (vc-svn-dir-status): Don't create a buffer. (vc-svn-after-dir-status): Don't kill the buffer.
author Dan Nicolaescu <dann@ics.uci.edu>
date Sat, 29 Mar 2008 05:34:52 +0000
parents e6a15031fc81
children 92ec903498d4
files lisp/ChangeLog lisp/vc-bzr.el lisp/vc-cvs.el lisp/vc-git.el lisp/vc-hg.el lisp/vc-svn.el lisp/vc.el
diffstat 7 files changed, 85 insertions(+), 83 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sat Mar 29 05:33:06 2008 +0000
+++ b/lisp/ChangeLog	Sat Mar 29 05:34:52 2008 +0000
@@ -3,6 +3,25 @@
 	* vc-hooks.el (vc-menu-map-filter): Be more careful when finding
 	the current backend.
 
+	* vc.el (vc-status-menu-map, vc-status-mode-map): Bind vc-revert.
+	(vc-status-refresh): Create a temporary buffer and call the
+	`dir-status' backend function from that buffer.
+
+	* vc-bzr.el (vc-bzr-dir-status): Don't create a buffer.
+	(vc-bzr-after-dir-status): Don't kill the buffer.
+
+	* vc-cvs.el (vc-cvs-dir-status): Don't create a buffer.
+	(vc-cvs-after-dir-status): Don't kill the buffer.
+
+	* vc-git.el (vc-git-dir-status): Don't create a buffer.
+	(vc-git-after-dir-status-stage2): Don't kill the buffer.
+
+	* vc-hg.el (vc-hg-dir-status): Don't create a buffer.
+	(vc-hg-after-dir-status): Don't kill the buffer.
+
+	* vc-svn.el (vc-svn-dir-status): Don't create a buffer.
+	(vc-svn-after-dir-status): Don't kill the buffer.
+
 2008-03-29  Glenn Morris  <rgm@gnu.org>
 
 	* calendar/calendar.el (diary-file, american-date-diary-pattern)
--- a/lisp/vc-bzr.el	Sat Mar 29 05:33:06 2008 +0000
+++ b/lisp/vc-bzr.el	Sat Mar 29 05:34:52 2008 +0000
@@ -677,23 +677,16 @@
 	(setq translated (assoc status-str translation))
 	(push (cons file (cdr translated)) result)
 	(forward-line))
-      ;; Remove the temporary buffer.
-      (kill-buffer (current-buffer))
       (funcall update-function result status-buffer)))
 
 ;; XXX Experimental function for the vc-dired replacement.
 ;; XXX This probably needs some further refinement and testing.
 (defun vc-bzr-dir-status (dir update-function status-buffer)
   "Return a list of conses (file . state) for DIR."
-  (with-current-buffer
-      (get-buffer-create
-       (expand-file-name " *VC-bzr* tmp status" dir))
-    (erase-buffer)
-    ;; XXX: Is this the right command to use?
-    (vc-bzr-command "status" (current-buffer) 'async dir "-v" "-S")
-    (vc-exec-after
-     `(vc-bzr-after-dir-status (quote ,update-function) ,status-buffer))
-    (current-buffer)))
+  ;; XXX: Is this the right command to use?
+  (vc-bzr-command "status" (current-buffer) 'async dir "-v" "-S")
+  (vc-exec-after
+   `(vc-bzr-after-dir-status (quote ,update-function) ,status-buffer)))
 
 ;;; Revision completion
 
--- a/lisp/vc-cvs.el	Sat Mar 29 05:33:06 2008 +0000
+++ b/lisp/vc-cvs.el	Sat Mar 29 05:34:52 2008 +0000
@@ -927,20 +927,14 @@
 	      (push (cons file status) result))))))
       (goto-char (point-max))
       (widen))
-      ;; Remove the temporary buffer.
-      (kill-buffer (current-buffer))
       (funcall update-function result status-buffer)))
 
 ;; XXX Experimental function for the vc-dired replacement.
 (defun vc-cvs-dir-status (dir update-function status-buffer)
   "Create a list of conses (file . state) for DIR."
-  (with-current-buffer
-      (get-buffer-create (expand-file-name " *VC-cvs* tmp status" dir))
-    (erase-buffer)
-    (vc-cvs-command (current-buffer) 'async dir "status")
-    (vc-exec-after
-     `(vc-cvs-after-dir-status (quote ,update-function) ,status-buffer))
-    (current-buffer)))
+  (vc-cvs-command (current-buffer) 'async dir "status")
+  (vc-exec-after
+   `(vc-cvs-after-dir-status (quote ,update-function) ,status-buffer)))
 
 (defun vc-cvs-get-entries (dir)
   "Insert the CVS/Entries file from below DIR into the current buffer.
--- a/lisp/vc-git.el	Sat Mar 29 05:33:06 2008 +0000
+++ b/lisp/vc-git.el	Sat Mar 29 05:34:52 2008 +0000
@@ -215,9 +215,7 @@
   (goto-char (point-min))
   (while (re-search-forward "\\([^\0]*?\\)\0" nil t 1)
     (push (cons (match-string 1) 'unregistered) vc-git-status-result))
-  (funcall update-function (nreverse vc-git-status-result) status-buffer)
-  ;; Remove the temporary buffer.
-  (kill-buffer (current-buffer)))
+  (funcall update-function (nreverse vc-git-status-result) status-buffer))
 
 (defun vc-git-after-dir-status-stage1 (update-function status-buffer)
   (goto-char (point-min))
@@ -248,21 +246,16 @@
   ;; Further things that would have to be fixed later:
   ;; - how to handle unregistered directories
   ;; - how to support vc-status on a subdir of the project tree
-  (with-current-buffer
-      (get-buffer-create
-       (expand-file-name " *VC-Git* tmp status" dir))
-    (set (make-local-variable 'vc-git-status-result) nil)
-    (cd dir)
-    (erase-buffer)
-    (if (vc-git--empty-db-p)
-        (progn
-          (vc-git-command (current-buffer) 'async nil "ls-files" "-z" "-c")
-          (vc-exec-after
-           `(vc-git-after-dir-status-stage1-empty-db (quote ,update-function) ,status-buffer)))
-      (vc-git-command (current-buffer) 'async nil "diff-index" "-z" "HEAD")
-      (vc-exec-after
-       `(vc-git-after-dir-status-stage1 (quote ,update-function) ,status-buffer)))
-    (current-buffer)))
+  (set (make-local-variable 'vc-git-status-result) nil)
+  (if (vc-git--empty-db-p)
+      (progn
+	(vc-git-command (current-buffer) 'async nil "ls-files" "-z" "-c")
+	(vc-exec-after
+	 `(vc-git-after-dir-status-stage1-empty-db 
+	   (quote ,update-function) ,status-buffer)))
+    (vc-git-command (current-buffer) 'async nil "diff-index" "-z" "HEAD")
+    (vc-exec-after
+     `(vc-git-after-dir-status-stage1 (quote ,update-function) ,status-buffer))))
 
 (defun vc-git-status-extra-headers (dir)
   (let ((str (with-output-to-string
--- a/lisp/vc-hg.el	Sat Mar 29 05:33:06 2008 +0000
+++ b/lisp/vc-hg.el	Sat Mar 29 05:34:52 2008 +0000
@@ -498,21 +498,15 @@
 	(when (and translated (not (eq (cdr translated) 'up-to-date)))
 	  (push (cons file (cdr translated)) result))
 	(forward-line))
-      ;; Remove the temporary buffer.
-      (kill-buffer (current-buffer))
       (funcall update-function result status-buffer)))
 
 ;; XXX Experimental function for the vc-dired replacement.
 (defun vc-hg-dir-status (dir update-function status-buffer)
   "Return a list of conses (file . state) for DIR."
-  (with-current-buffer
-      (get-buffer-create
-       (expand-file-name " *VC-hg* tmp status" dir))
-    (erase-buffer)
-    (vc-hg-command (current-buffer) 'async dir "status")
-    (vc-exec-after
-     `(vc-hg-after-dir-status (quote ,update-function) ,status-buffer))
-    (current-buffer)))
+  (erase-buffer)
+  (vc-hg-command (current-buffer) 'async dir "status")
+  (vc-exec-after
+   `(vc-hg-after-dir-status (quote ,update-function) ,status-buffer)))
 
 ;; XXX this adds another top level menu, instead figure out how to
 ;; replace the Log-View menu.
--- a/lisp/vc-svn.el	Sat Mar 29 05:33:06 2008 +0000
+++ b/lisp/vc-svn.el	Sat Mar 29 05:34:52 2008 +0000
@@ -175,19 +175,15 @@
            (filename (match-string 2)))
        (when state
          (setq result (cons (cons filename state) result)))))
-    (kill-buffer (current-buffer))
     (funcall callback result buffer)))
 
 (defun vc-svn-dir-status (dir callback buffer)
   "Run 'svn status' for DIR and update BUFFER via CALLBACK.
 CALLBACK is called as (CALLBACK RESULT BUFFER), where
 RESULT is a list of conses (FILE . STATE) for directory DIR."
-  (with-current-buffer (get-buffer-create
-                       (generate-new-buffer-name " *vc svn status*"))
-    (vc-svn-command (current-buffer) 'async nil "status")
-    (vc-exec-after
-     `(vc-svn-after-dir-status (quote ,callback) ,buffer))
-    (current-buffer)))
+  (vc-svn-command (current-buffer) 'async nil "status")
+  (vc-exec-after
+   `(vc-svn-after-dir-status (quote ,callback) ,buffer)))
 
 (defun vc-svn-working-revision (file)
   "SVN-specific version of `vc-working-revision'."
--- a/lisp/vc.el	Sat Mar 29 05:33:06 2008 +0000
+++ b/lisp/vc.el	Sat Mar 29 05:34:52 2008 +0000
@@ -171,19 +171,16 @@
 ;;
 ;;   Produce RESULT: a list of conses of the form (file . vc-state)
 ;;   for the files in DIR.  If a command needs to be run to compute
-;;   this list, it should be run asynchronously.  When RESULT is
-;;   computed, it should be passed back by doing:
-;;       (funcall UPDATE-FUNCTION RESULT STATUS-BUFFER)
-;;   Return the buffer used for the asynchronous call.  This buffer
-;;   is used to kill the status update process on demand.
-;;   This function is used by vc-status, a replacement for vc-dired.
+;;   this list, it should be run asynchronously using (current-buffer)
+;;   as the buffer for the command.  When RESULT is computed, it should
+;;   be passed back by doing: (funcall UPDATE-FUNCTION RESULT STATUS-BUFFER)
+;;   This function is used by `vc-status', a replacement for `vc-dired'.
 ;;   vc-status is still under development, and is NOT feature
 ;;   complete.  As such, the requirements for this function might
-;;   change.
-;;   This is a replacement for dir-state.
+;;   change.  This is a replacement for `dir-state'.
 ;;
 ;; - status-extra-headers (dir)
-;;   
+;;
 ;;   Return a string that will be added to the *vc-status* buffer header.
 ;;
 ;; * working-revision (file)
@@ -2739,7 +2736,7 @@
       '(menu-item "Hide up-to-date" vc-status-hide-up-to-date
 		  :help "Hide up-to-date items from display"))
     ;; VC commands.
-    (define-key map [separator-vc-commands] '("--"))
+    (define-key map [sepvccmd] '("--"))
     (define-key map [annotate]
       '(menu-item "Annotate" vc-annotate
 		  :help "Display the edit history of the current file using colors"))
@@ -2750,14 +2747,17 @@
       '(menu-item "Register" vc-status-register
 		  :help "Register file set into the version control system"))
     (define-key map [update]
-      '(menu-item "Update" vc-update
+      '(menu-item "Update to latest version" vc-update
 		  :help "Update the current fileset's files to their tip revisions"))
+    (define-key map [revert]
+      '(menu-item "Revert to base version" vc-revert
+		  :help "Revert working copies of the selected fileset to their repository contents."))
     (define-key map [log]
      '(menu-item "Show history" vc-print-log
      :help "List the change log of the current file set in a window"))
 
     ;; Movement.
-    (define-key map [separator-movement] '("--"))
+    (define-key map [sepmv] '("--"))
     (define-key map [next-line]
       '(menu-item "Next line" vc-status-next-line
 		  :help "Go to the next line" :keys "n"))
@@ -2765,7 +2765,7 @@
       '(menu-item "Previous line" vc-status-previous-line
 		  :help "Go to the previous line"))
     ;; Marking.
-    (define-key map [separator-marking] '("--"))
+    (define-key map [sepmrk] '("--"))
     (define-key map [unmark-all]
       '(menu-item "Unmark All" vc-status-unmark-all-files
 		  :help "Unmark all files that are in the same state as the current file\
@@ -2786,7 +2786,7 @@
       '(menu-item "Mark" vc-status-mark
 		  :help "Mark the current file or all files in the region"))
 
-    (define-key map [separator-open] '("--"))
+    (define-key map [sepopn] '("--"))
     (define-key map [open-other]
       '(menu-item "Open in other window" vc-status-find-file-other-window
 		  :help "Find the file on the current line, in another window"))
@@ -2814,12 +2814,13 @@
     (define-key map "p" 'vc-status-previous-line)
     (define-key map [backtab] 'vc-status-previous-line)
     ;; VC commands.
-    (define-key map "=" 'vc-diff)
+    (define-key map "=" 'vc-diff)   ;; C-x v =
     (define-key map "a" 'vc-status-register)
-    (define-key map "+" 'vc-update)
+    (define-key map "+" 'vc-update) ;; C-x v +
+    (define-key map "U" 'vc-revert) ;; u is taken by unmark.
     ;; Can't be "g" (as in vc map), so "A" for "Annotate".
     (define-key map "A" 'vc-annotate)
-    (define-key map "l" 'vc-print-log)
+    (define-key map "l" 'vc-print-log) ;; C-x v l
     ;; The remainder.
     (define-key map "f" 'vc-status-find-file)
     (define-key map "\C-m" 'vc-status-find-file)
@@ -2961,9 +2962,9 @@
   (interactive)
   (if vc-status-process-buffer
       (error "Another update process is in progress, cannot run two at a time")
-    ;; This is not very efficient; ewoc could use a new function here.
     ;; We clear the ewoc, but remember the marked files so that we can
     ;; mark them again after the refresh is done.
+    ;; This is not very efficient; ewoc could use a new function here.
     (setq vc-status-crt-marked
 	  (mapcar
 	   (lambda (elem)
@@ -2973,17 +2974,29 @@
 	    (lambda (crt) (vc-status-fileinfo->marked crt)))))
     (ewoc-filter vc-status (lambda (node) nil))
 
-    (let ((backend (vc-responsible-backend default-directory)))
+    (let ((backend (vc-responsible-backend default-directory))
+	  (status-buffer (current-buffer))
+	  (def-dir default-directory))
       (vc-set-mode-line-busy-indicator)
-      ;; Call the dir-status backend function. dir-status is supposed to
-      ;; be asynchronous.  It should compute the results and call the
-      ;; function passed as a an arg to update the vc-status buffer with
-      ;; the results.
-      (let ((buf (vc-call-backend
-		  backend 'dir-status default-directory
-		  #'vc-update-vc-status-buffer (current-buffer))))
-	(setq vc-status-process-buffer
-	      (if (buffer-live-p buf) buf nil))))))
+      ;; Call the `dir-status' backend function.
+      ;; `dir-status' is supposed to be asynchronous.
+      ;; It should compute the results, and then call the function
+      ;; passed as an argument in order to update the vc-status buffer
+      ;; with the results.
+
+      ;; Create a buffer that can be used by `dir-status' and call
+      ;; `dir-status' with this buffer as the current buffer.  Use
+      ;; `vc-status-process-buffer' to remember this buffer, so that
+      ;; it can be used later to kill the update process in case it
+      ;; takes too long.
+      (setq vc-status-process-buffer
+	    (get-buffer-create
+	     (generate-new-buffer-name (format " *VC-%s* status" backend))))
+      (with-current-buffer vc-status-process-buffer
+	(cd def-dir)
+	(erase-buffer)
+	(vc-call-backend backend 'dir-status def-dir
+			 #'vc-update-vc-status-buffer status-buffer)))))
 
 (defun vc-status-kill-dir-status-process ()
   "Kill the temporary buffer and associated process."