Mercurial > emacs
comparison lisp/vc-git.el @ 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 | eabeaae7370e |
children | b9d2156e3f5d |
comparison
equal
deleted
inserted
replaced
82108:fb40f60f0ab3 | 82109:12d79fae7504 |
---|---|
38 | 38 |
39 ;;; Todo: | 39 ;;; Todo: |
40 ;; - check if more functions could use vc-git-command instead | 40 ;; - check if more functions could use vc-git-command instead |
41 ;; of start-process. | 41 ;; of start-process. |
42 ;; - changelog generation | 42 ;; - changelog generation |
43 ;; - working with revisions other than HEAD | |
44 | 43 |
45 ;; Implement the rest of the vc interface. See the comment at the | 44 ;; Implement the rest of the vc interface. See the comment at the |
46 ;; beginning of vc.el. The current status is: | 45 ;; beginning of vc.el. The current status is: |
47 ;; ("??" means: "figure out what to do about it") | 46 ;; ("??" means: "figure out what to do about it") |
48 ;; | 47 ;; |
71 ;; * checkin (files rev comment) OK | 70 ;; * checkin (files rev comment) OK |
72 ;; * find-version (file rev buffer) OK | 71 ;; * find-version (file rev buffer) OK |
73 ;; * checkout (file &optional editable rev) OK | 72 ;; * checkout (file &optional editable rev) OK |
74 ;; * revert (file &optional contents-done) OK | 73 ;; * revert (file &optional contents-done) OK |
75 ;; - rollback (files) ?? PROBABLY NOT NEEDED | 74 ;; - rollback (files) ?? PROBABLY NOT NEEDED |
76 ;; - merge (file rev1 rev2) NEEDED | 75 ;; - merge (file rev1 rev2) It would be possible to merge changes into |
77 ;; - merge-news (file) NEEDED | 76 ;; a single file, but when committing they |
77 ;; wouldn't be identified as a merge by git, | |
78 ;; so it's probably not a good idea. | |
79 ;; - merge-news (file) see `merge' | |
78 ;; - steal-lock (file &optional version) NOT NEEDED | 80 ;; - steal-lock (file &optional version) NOT NEEDED |
79 ;; HISTORY FUNCTIONS | 81 ;; HISTORY FUNCTIONS |
80 ;; * print-log (files &optional buffer) OK | 82 ;; * print-log (files &optional buffer) OK |
81 ;; - log-view-mode () OK | 83 ;; - log-view-mode () OK |
82 ;; - show-log-entry (version) NOT NEEDED, DEFAULT IS GOOD | 84 ;; - show-log-entry (version) NOT NEEDED, DEFAULT IS GOOD |
83 ;; - wash-log (file) ?? | 85 ;; - wash-log (file) ?? |
84 ;; - logentry-check () ?? | 86 ;; - logentry-check () ?? |
85 ;; - comment-history (file) ?? | 87 ;; - comment-history (file) ?? |
86 ;; - update-changelog (files) ?? | 88 ;; - update-changelog (files) ?? |
87 ;; * diff (file &optional rev1 rev2 buffer) PORT TO NEW VC INTERFACE | 89 ;; * diff (file &optional rev1 rev2 buffer) OK |
88 ;; - revision-completion-table (file) NEEDED? | 90 ;; - revision-completion-table (file) NEEDED? |
89 ;; - diff-tree (dir &optional rev1 rev2) OK | 91 ;; - diff-tree (dir &optional rev1 rev2) OK |
90 ;; - annotate-command (file buf &optional rev) OK | 92 ;; - annotate-command (file buf &optional rev) OK |
91 ;; - annotate-time () OK | 93 ;; - annotate-time () OK |
92 ;; - annotate-current-time () ?? NOT NEEDED | 94 ;; - annotate-current-time () ?? NOT NEEDED |
93 ;; - annotate-extract-revision-at-line () OK | 95 ;; - annotate-extract-revision-at-line () OK |
94 ;; SNAPSHOT SYSTEM | 96 ;; SNAPSHOT SYSTEM |
95 ;; - create-snapshot (dir name branchp) NEEDED | 97 ;; - create-snapshot (dir name branchp) OK |
96 ;; - assign-name (file name) NOT NEEDED | 98 ;; - assign-name (file name) NOT NEEDED |
97 ;; - retrieve-snapshot (dir name update) NEEDED | 99 ;; - retrieve-snapshot (dir name update) OK, needs to handle the `name' arg |
98 ;; MISCELLANEOUS | 100 ;; MISCELLANEOUS |
99 ;; - make-version-backups-p (file) ?? | 101 ;; - make-version-backups-p (file) ?? |
100 ;; - repository-hostname (dirname) ?? | 102 ;; - repository-hostname (dirname) ?? |
101 ;; - previous-version (file rev) OK | 103 ;; - previous-version (file rev) OK |
102 ;; - next-version (file rev) OK | 104 ;; - next-version (file rev) OK |
308 (1 'change-log-name) | 310 (1 'change-log-name) |
309 (2 'change-log-email)) | 311 (2 'change-log-email)) |
310 ("^Date: \\(.+\\)" (1 'change-log-date)) | 312 ("^Date: \\(.+\\)" (1 'change-log-date)) |
311 ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message)))))) | 313 ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message)))))) |
312 | 314 |
313 (defun vc-git-diff (file &optional rev1 rev2 buffer) | 315 (defun vc-git-diff (files &optional rev1 rev2 buffer) |
314 (let ((name (file-relative-name file)) | 316 (let ((buf (or buffer "*vc-diff*"))) |
315 (buf (or buffer "*vc-diff*"))) | |
316 (if (and rev1 rev2) | 317 (if (and rev1 rev2) |
317 (vc-git-command buf 0 name "diff-tree" "-p" rev1 rev2 "--") | 318 (vc-git-command buf 1 files "diff-tree" "--exit-code" "-p" rev1 rev2 "--") |
318 (vc-git-command buf 0 name "diff-index" "-p" (or rev1 "HEAD") "--")) | 319 (vc-git-command buf 1 files "diff-index" "--exit-code" "-p" (or rev1 "HEAD") "--")))) |
319 ;; git-diff-index doesn't set exit status like diff does | |
320 (if (vc-git-workfile-unchanged-p file) 0 1))) | |
321 | 320 |
322 (defun vc-git-diff-tree (dir &optional rev1 rev2) | 321 (defun vc-git-diff-tree (dir &optional rev1 rev2) |
323 (vc-git-diff dir rev1 rev2)) | 322 (vc-git-diff dir rev1 rev2)) |
324 | 323 |
325 (defun vc-git-annotate-command (file buf &optional rev) | 324 (defun vc-git-annotate-command (file buf &optional rev) |
335 (defun vc-git-annotate-extract-revision-at-line () | 334 (defun vc-git-annotate-extract-revision-at-line () |
336 (save-excursion | 335 (save-excursion |
337 (move-beginning-of-line 1) | 336 (move-beginning-of-line 1) |
338 (and (looking-at "[0-9a-f]+") | 337 (and (looking-at "[0-9a-f]+") |
339 (buffer-substring-no-properties (match-beginning 0) (match-end 0))))) | 338 (buffer-substring-no-properties (match-beginning 0) (match-end 0))))) |
339 | |
340 ;;; SNAPSHOT SYSTEM | |
341 | |
342 (defun vc-git-create-snapshot (dir name branchp) | |
343 (let ((default-directory dir)) | |
344 (and (vc-git-command nil 0 nil "update-index" "--refresh") | |
345 (if branchp | |
346 (vc-git-command nil 0 nil "checkout" "-b" name) | |
347 (vc-git-command nil 0 nil "tag" name))))) | |
348 | |
349 (defun vc-git-retrieve-snapshot (dir name update) | |
350 (let ((default-directory dir)) | |
351 (vc-git-command nil 0 nil "checkout" name) | |
352 ;; FIXME: update buffers if `update' is true | |
353 )) | |
354 | |
340 | 355 |
341 ;;; MISCELLANEOUS | 356 ;;; MISCELLANEOUS |
342 | 357 |
343 (defun vc-git-previous-version (file rev) | 358 (defun vc-git-previous-version (file rev) |
344 "Git-specific version of `vc-previous-version'." | 359 "Git-specific version of `vc-previous-version'." |
395 | 410 |
396 (defun vc-git-rename-file (old new) | 411 (defun vc-git-rename-file (old new) |
397 (vc-git-command nil 0 (list old new) "mv" "-f" "--")) | 412 (vc-git-command nil 0 (list old new) "mv" "-f" "--")) |
398 | 413 |
399 | 414 |
400 ;; Internal commands | 415 ;;; Internal commands |
401 | 416 |
402 (defun vc-git-root (file) | 417 (defun vc-git-root (file) |
403 (vc-find-root file ".git")) | 418 (vc-find-root file ".git")) |
404 | 419 |
405 (defun vc-git-command (buffer okstatus file-or-list &rest flags) | 420 (defun vc-git-command (buffer okstatus file-or-list &rest flags) |