]> git.eshelyaron.com Git - emacs.git/commitdiff
Add new VC operation `revision-completion-table'.
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 26 Jun 2007 17:43:04 +0000 (17:43 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Tue, 26 Jun 2007 17:43:04 +0000 (17:43 +0000)
(vc-default-revision-completion-table): New function.
(vc-version-diff, vc-version-other-window): Use it to provide
completion of revision names if the backend provides it.

lisp/ChangeLog
lisp/vc.el

index c910fc5478ace2bd39b5e775d0ba2c7c5afdf84b..75cbc29d28a7cc7617d20ed17fac3499ed51f030 100644 (file)
@@ -1,5 +1,10 @@
 2007-06-26  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+       * vc.el: Add new VC operation `revision-completion-table'.
+       (vc-default-revision-completion-table): New function.
+       (vc-version-diff, vc-version-other-window): Use it to provide
+       completion of revision names if the backend provides it.
+
        * log-edit.el (log-edit-changelog-entries): Use with-current-buffer.
 
        * vc-svn.el (vc-svn-repository-hostname): Adjust to non-XML format
index 19e428d90a8c6b36132d91078324d8227fc049f8..6780a9c97d773854e6aee2eda1b24de05e5c2ed0 100644 (file)
 ;;   of either 0 (no differences found), or 1 (either non-empty diff
 ;;   or the diff is run asynchronously).
 ;;
+;; - revision-completion-table (file)
+;;
+;;   Return a completion table for existing revisions of FILE.
+;;   The default is to not use any completion table.
+;;
 ;; - diff-tree (dir &optional rev1 rev2)
 ;;
 ;;   Insert the diff for all files at and below DIR into the *vc-diff*
@@ -1748,6 +1753,8 @@ saving the buffer."
          (message "No changes to %s since latest version" file)
        (vc-version-diff file nil nil)))))
 
+(defun vc-default-revision-completion-table (backend file) nil)
+
 (defun vc-version-diff (file rev1 rev2)
   "List the differences between FILE's versions REV1 and REV2.
 If REV1 is empty or nil it means to use the current workfile version;
@@ -1755,12 +1762,13 @@ REV2 empty or nil means the current file contents.  FILE may also be
 a directory, in that case, generate diffs between the correponding
 versions of all registered files in or below it."
   (interactive
-   (let ((file (expand-file-name
-                (read-file-name (if buffer-file-name
-                                    "File or dir to diff (default visited file): "
-                                  "File or dir to diff: ")
-                                default-directory buffer-file-name t)))
-         (rev1-default nil) (rev2-default nil))
+   (let* ((file (expand-file-name
+                 (read-file-name (if buffer-file-name
+                                     "File or dir to diff (default visited file): "
+                                   "File or dir to diff: ")
+                                 default-directory buffer-file-name t)))
+          (rev1-default nil) (rev2-default nil)
+          (completion-table (vc-call revision-completion-table file)))
      ;; compute default versions based on the file state
      (cond
       ;; if it's a directory, don't supply any version default
@@ -1772,21 +1780,25 @@ versions of all registered files in or below it."
       ;; if the file is not locked, use last and previous version as default
       (t
        (setq rev1-default (vc-call previous-version file
-                                   (vc-workfile-version file)))
+                                  (vc-workfile-version file)))
        (if (string= rev1-default "") (setq rev1-default nil))
        (setq rev2-default (vc-workfile-version file))))
      ;; construct argument list
-     (list file
-           (read-string (if rev1-default
-                           (concat "Older version (default "
-                                   rev1-default "): ")
-                         "Older version: ")
-                       nil nil rev1-default)
-           (read-string (if rev2-default
-                           (concat "Newer version (default "
-                                   rev2-default "): ")
-                         "Newer version (default current source): ")
-                       nil nil rev2-default))))
+     (let* ((rev1-prompt (if rev1-default
+                            (concat "Older version (default "
+                                    rev1-default "): ")
+                          "Older version: "))
+           (rev2-prompt (concat "Newer version (default "
+                                (or rev2-default "current source") "): "))
+           (rev1 (if completion-table
+                     (completing-read rev1-prompt completion-table
+                                       nil nil nil nil rev1-default)
+                   (read-string rev1-prompt nil nil rev1-default)))
+           (rev2 (if completion-table
+                     (completing-read rev2-prompt completion-table
+                                       nil nil nil nil rev2-default)
+                   (read-string rev2-prompt nil nil rev2-default))))
+       (list file rev1 rev2))))
   (if (file-directory-p file)
       ;; recursive directory diff
       (progn
@@ -1941,7 +1953,16 @@ The meaning of REV1 and REV2 is the same as for `vc-version-diff'."
   "Visit version REV of the current file in another window.
 If the current file is named `F', the version is named `F.~REV~'.
 If `F.~REV~' already exists, use it instead of checking it out again."
-  (interactive "sVersion to visit (default is workfile version): ")
+  (interactive
+   (save-current-buffer
+     (vc-ensure-vc-buffer)
+     (let ((completion-table
+            (vc-call revision-completion-table buffer-file-name))
+           (prompt "Version to visit (default is workfile version): "))
+       (list
+        (if completion-table
+            (completing-read prompt completion-table)
+          (read-string prompt))))))
   (vc-ensure-vc-buffer)
   (let* ((file buffer-file-name)
         (version (if (string-equal rev "")