changeset 82109:12d79fae7504

* vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface. (vc-git-create-snapshot, vc-git-retrieve-snapshot): New functions.
author Dan Nicolaescu <dann@ics.uci.edu>
date Wed, 25 Jul 2007 15:03:05 +0000
parents fb40f60f0ab3
children b9d2156e3f5d
files lisp/ChangeLog lisp/vc-git.el
diffstat 2 files changed, 34 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Wed Jul 25 14:39:45 2007 +0000
+++ b/lisp/ChangeLog	Wed Jul 25 15:03:05 2007 +0000
@@ -1,3 +1,8 @@
+2007-07-25  Alexandre Julliard  <julliard@winehq.org>
+
+	* vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
+	(vc-git-create-snapshot, vc-git-retrieve-snapshot): New functions.
+
 2007-07-25  Vinicius Jose Latorre  <viniciusjl@ig.com.br>
 
 	* ps-print.el (ps-multibyte-buffer): Docstring fix.
--- a/lisp/vc-git.el	Wed Jul 25 14:39:45 2007 +0000
+++ b/lisp/vc-git.el	Wed Jul 25 15:03:05 2007 +0000
@@ -40,7 +40,6 @@
 ;;  - check if more functions could use vc-git-command instead
 ;;     of start-process.
 ;;  - changelog generation
-;;  - working with revisions other than HEAD
 
 ;; Implement the rest of the vc interface. See the comment at the
 ;; beginning of vc.el. The current status is:
@@ -73,8 +72,11 @@
 ;; * checkout (file &optional editable rev)	   OK
 ;; * revert (file &optional contents-done)	   OK
 ;; - rollback (files)				   ?? PROBABLY NOT NEEDED
-;; - merge (file rev1 rev2)			   NEEDED
-;; - merge-news (file)				   NEEDED
+;; - merge (file rev1 rev2)			   It would be possible to merge changes into 
+;;                                                 a single file, but when committing they 
+;;                                                 wouldn't be identified as a merge by git, 
+;;                                                 so it's probably not a good idea.
+;; - merge-news (file)				   see `merge'
 ;; - steal-lock (file &optional version)	   NOT NEEDED
 ;; HISTORY FUNCTIONS
 ;; * print-log (files &optional buffer)		   OK
@@ -84,7 +86,7 @@
 ;; - logentry-check ()				   ??
 ;; - comment-history (file)			   ??
 ;; - update-changelog (files)			   ??
-;; * diff (file &optional rev1 rev2 buffer)	   PORT TO NEW VC INTERFACE
+;; * diff (file &optional rev1 rev2 buffer)	   OK
 ;; - revision-completion-table (file)		   NEEDED?
 ;; - diff-tree (dir &optional rev1 rev2)	   OK
 ;; - annotate-command (file buf &optional rev)	   OK
@@ -92,9 +94,9 @@
 ;; - annotate-current-time ()			   ?? NOT NEEDED
 ;; - annotate-extract-revision-at-line ()	   OK
 ;; SNAPSHOT SYSTEM
-;; - create-snapshot (dir name branchp)		   NEEDED
+;; - create-snapshot (dir name branchp)		   OK
 ;; - assign-name (file name)			   NOT NEEDED
-;; - retrieve-snapshot (dir name update)	   NEEDED
+;; - retrieve-snapshot (dir name update)	   OK, needs to handle the `name' arg
 ;; MISCELLANEOUS
 ;; - make-version-backups-p (file)		   ??
 ;; - repository-hostname (dirname)		   ??
@@ -310,14 +312,11 @@
 	   ("^Date:   \\(.+\\)" (1 'change-log-date))
 	   ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message))))))
 
-(defun vc-git-diff (file &optional rev1 rev2 buffer)
-  (let ((name (file-relative-name file))
-        (buf (or buffer "*vc-diff*")))
+(defun vc-git-diff (files &optional rev1 rev2 buffer)
+  (let ((buf (or buffer "*vc-diff*")))
     (if (and rev1 rev2)
-        (vc-git-command buf 0 name "diff-tree" "-p" rev1 rev2 "--")
-      (vc-git-command buf 0 name "diff-index" "-p" (or rev1 "HEAD") "--"))
-    ;; git-diff-index doesn't set exit status like diff does
-    (if (vc-git-workfile-unchanged-p file) 0 1)))
+        (vc-git-command buf 1 files "diff-tree" "--exit-code" "-p" rev1 rev2 "--")
+      (vc-git-command buf 1 files "diff-index" "--exit-code" "-p" (or rev1 "HEAD") "--"))))
 
 (defun vc-git-diff-tree (dir &optional rev1 rev2)
   (vc-git-diff dir rev1 rev2))
@@ -338,6 +337,22 @@
    (and (looking-at "[0-9a-f]+")
         (buffer-substring-no-properties (match-beginning 0) (match-end 0)))))
 
+;;; SNAPSHOT SYSTEM
+
+(defun vc-git-create-snapshot (dir name branchp)
+  (let ((default-directory dir))
+    (and (vc-git-command nil 0 nil "update-index" "--refresh")
+         (if branchp
+             (vc-git-command nil 0 nil "checkout" "-b" name)
+           (vc-git-command nil 0 nil "tag" name)))))
+
+(defun vc-git-retrieve-snapshot (dir name update)
+  (let ((default-directory dir))
+    (vc-git-command nil 0 nil "checkout" name)
+    ;; FIXME: update buffers if `update' is true
+    ))
+
+
 ;;; MISCELLANEOUS
 
 (defun vc-git-previous-version (file rev)
@@ -397,7 +412,7 @@
   (vc-git-command nil 0 (list old new) "mv" "-f" "--"))
 
 
-;; Internal commands
+;;; Internal commands
 
 (defun vc-git-root (file)
   (vc-find-root file ".git"))