emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/vc.el,v


From: Stefan Monnier
Subject: [Emacs-diffs] Changes to emacs/lisp/vc.el,v
Date: Fri, 09 May 2008 16:01:51 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Stefan Monnier <monnier>        08/05/09 16:01:51

Index: vc.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/vc.el,v
retrieving revision 1.645
retrieving revision 1.646
diff -u -b -r1.645 -r1.646
--- vc.el       9 May 2008 07:03:15 -0000       1.645
+++ vc.el       9 May 2008 16:01:50 -0000       1.646
@@ -1011,22 +1011,15 @@
 
 (defun vc-deduce-fileset ()
   "Deduce a set of files and a backend to which to apply an operation and
-the common state of the fileset.  Return (BACKEND . (STATE . FILESET))."
+the common state of the fileset.  Return (BACKEND . FILESET)."
   (let* ((fileset (vc-dispatcher-selection-set))
-        (fileset-only-files (vc-expand-dirs fileset))
-        (firstfile (car fileset-only-files))
-        (firstbackend (vc-backend firstfile))
-        (firstmodel (vc-checkout-model firstbackend (list firstfile)))
-        (firststate (vc-state firstfile)))
-       (dolist (file (cdr fileset-only-files))
-         (unless (eq (vc-backend file) firstbackend)
-           (error "All members of a fileset must be under the same 
version-control system."))
-         (unless (vc-compatible-state (vc-state file) firststate)
-           (error "%s:%s clashes with %s:%s"
-                  file (vc-state file) firstfile firststate))
-         (unless (eq (vc-checkout-model firstbackend (list file)) firstmodel)
-           (error "Fileset has mixed checkout models")))
-       (cons firstbackend (cons firststate fileset))))
+         ;; FIXME: Store the backend in a buffer-local variable.
+         (backend (if (derived-mode-p 'vc-dir-mode)
+                      (vc-responsible-backend default-directory)
+                    (assert (and (= 1 (length fileset))
+                                 (not (file-directory-p (car fileset)))))
+                    (vc-backend (car fileset)))))
+       (cons backend fileset)))
 
 (defun vc-ensure-vc-buffer ()
   "Make sure that the current buffer visits a version-controlled file."
@@ -1098,10 +1091,21 @@
   (interactive "P")
   (let* ((vc-fileset (vc-deduce-fileset))
          (backend (car vc-fileset))
-        (state (cadr vc-fileset))
-        (files (cddr vc-fileset))
+        (files (cdr vc-fileset))
+         (fileset-only-files (vc-expand-dirs files))
+         (state (vc-state (car fileset-only-files)))
+         ;; The backend should check that the checkout-model is consistent
+         ;; among all the `files'.
         (model (vc-checkout-model backend files))
         revision)
+
+    ;; Check that all files are in a consistent state, since we use that
+    ;; state to decide which operation to perform.
+    (dolist (file (cdr fileset-only-files))
+      (unless (vc-compatible-state (vc-state file) state)
+        (error "%s:%s clashes with %s:%s"
+               file (vc-state file) (car fileset-only-files) state)))
+
     ;; Do the right thing
     (cond
      ((eq state 'missing)
@@ -1493,7 +1497,7 @@
   "Report diffs between two revisions of a fileset.
 Diff output goes to the *vc-diff* buffer.  The function
 returns t if the buffer had changes, nil otherwise."
-  (let* ((files (cddr vc-fileset))
+  (let* ((files (cdr vc-fileset))
         (messages (cons (format "Finding changes in %s..."
                                  (vc-delistify files))
                          (format "No changes between %s and %s"
@@ -1559,7 +1563,7 @@
   "Report diffs between revisions of the fileset in the repository history."
   (interactive
    (let* ((vc-fileset (vc-deduce-fileset))
-         (files (cddr vc-fileset))
+         (files (cdr vc-fileset))
          (first (car files))
          (completion-table
           (vc-call revision-completion-table files))
@@ -2001,12 +2005,13 @@
   "Show the VC status for DIR."
   (interactive "DVC status for directory: ")
   (pop-to-buffer (vc-dir-prepare-status-buffer dir))
-  (if (and (eq major-mode 'vc-dir-mode) (boundp 'client-object))
+  (if (and (derived-mode-p 'vc-dir-mode) (boundp 'client-object))
       (vc-dir-refresh)
     ;; Otherwise, initialize a new view using the dispatcher layer
     (progn
       ;; Build a capability object and hand it to the dispatcher initializer
       (vc-dir-mode (vc-make-backend-object dir))
+      ;; FIXME: Make a derived-mode instead.
       ;; Add VC-specific keybindings
       (let ((map (current-local-map)))
        (define-key map "=" 'vc-diff) ;; C-x v =
@@ -2119,7 +2124,7 @@
   (interactive)
   (let* ((vc-fileset (vc-deduce-fileset))
         (backend (car vc-fileset))
-        (files (cddr vc-fileset))
+        (files (cdr vc-fileset))
         (working-revision (or working-revision (vc-working-revision (car 
files)))))
     ;; Don't switch to the output buffer before running the command,
     ;; so that any buffer-local settings in the vc-controlled
@@ -2149,7 +2154,7 @@
 to the working revision (except for keyword expansion)."
   (interactive)
   (let* ((vc-fileset (vc-deduce-fileset))
-        (files (cddr vc-fileset)))
+        (files (cdr vc-fileset)))
     ;; If any of the files is visited by the current buffer, make
     ;; sure buffer is saved.  If the user says `no', abort since
     ;; we cannot show the changes and ask for confirmation to
@@ -2181,7 +2186,7 @@
   (interactive)
   (let* ((vc-fileset (vc-deduce-fileset))
         (backend (car vc-fileset))
-        (files (cddr vc-fileset))
+        (files (cdr vc-fileset))
         (granularity (vc-call-backend backend 'revision-granularity)))
     (unless (vc-find-backend-function backend 'rollback)
       (error "Rollback is not supported in %s" backend))
@@ -2236,7 +2241,7 @@
   (interactive)
   (let* ((vc-fileset (vc-deduce-fileset))
         (backend (car vc-fileset))
-        (files (cddr vc-fileset)))
+        (files (cdr vc-fileset)))
     (dolist (file files)
       (when (let ((buf (get-file-buffer file)))
              (and buf (buffer-modified-p buf)))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]