diff options
| author | Dan Nicolaescu | 2008-05-01 06:35:09 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2008-05-01 06:35:09 +0000 |
| commit | 7db924c06ab538e3424c4f6fb2e263a0402c4bc5 (patch) | |
| tree | 69de618dc004003c715a2b6b4f84860ac7dc6339 | |
| parent | 97c66ed8cd26da701c68eeae5d1c20481453cbc0 (diff) | |
| download | emacs-7db924c06ab538e3424c4f6fb2e263a0402c4bc5.tar.gz emacs-7db924c06ab538e3424c4f6fb2e263a0402c4bc5.zip | |
(vc-hg-extra-fileinfo): New defstruct.
(vc-hg-status-printer): New function.
(vc-hg-after-dir-status): Deal with copied and renamed files.
(vc-hg-dir-status): Add flag to show copied files.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/vc-hg.el | 62 |
2 files changed, 59 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4675f3ff710..fdbe4ace0de 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -2,6 +2,11 @@ | |||
| 2 | 2 | ||
| 3 | * vc.el (vc-dir-mode-map): Don't bind "r". | 3 | * vc.el (vc-dir-mode-map): Don't bind "r". |
| 4 | 4 | ||
| 5 | * vc-hg.el (vc-hg-extra-fileinfo): New defstruct. | ||
| 6 | (vc-hg-status-printer): New function. | ||
| 7 | (vc-hg-after-dir-status): Deal with copied and renamed files. | ||
| 8 | (vc-hg-dir-status): Add flag to show copied files. | ||
| 9 | |||
| 5 | 2008-05-01 John Paul Wallington <jpw@pobox.com> | 10 | 2008-05-01 John Paul Wallington <jpw@pobox.com> |
| 6 | 11 | ||
| 7 | * ibuffer.el (ibuffer-last-sorting-mode): New variable. | 12 | * ibuffer.el (ibuffer-last-sorting-mode): New variable. |
diff --git a/lisp/vc-hg.el b/lisp/vc-hg.el index d6cd13d3bd0..013bdcbed63 100644 --- a/lisp/vc-hg.el +++ b/lisp/vc-hg.el | |||
| @@ -473,7 +473,27 @@ REV is the revision to check out into WORKFILE." | |||
| 473 | 473 | ||
| 474 | (define-derived-mode vc-hg-incoming-mode vc-hg-log-view-mode "Hg-Incoming") | 474 | (define-derived-mode vc-hg-incoming-mode vc-hg-log-view-mode "Hg-Incoming") |
| 475 | 475 | ||
| 476 | ;; XXX Experimental function for the vc-dired replacement. | 476 | (defstruct (vc-hg-extra-fileinfo |
| 477 | (:copier nil) | ||
| 478 | (:constructor vc-hg-create-extra-fileinfo (rename-state extra-name)) | ||
| 479 | (:conc-name vc-hg-extra-fileinfo->)) | ||
| 480 | rename-state ;; rename or copy state | ||
| 481 | extra-name) ;; original name for copies and rename targets, new name for | ||
| 482 | |||
| 483 | (defun vc-hg-status-printer (info) | ||
| 484 | "Pretty-printer for the vc-dir-fileinfo structure." | ||
| 485 | (let ((extra (vc-dir-fileinfo->extra info))) | ||
| 486 | (vc-default-status-printer 'Hg info) | ||
| 487 | (when extra | ||
| 488 | (insert (propertize | ||
| 489 | (format " (%s %s)" | ||
| 490 | (case (vc-hg-extra-fileinfo->rename-state extra) | ||
| 491 | ('copied "copied from") | ||
| 492 | ('renamed-from "renamed from") | ||
| 493 | ('renamed-to "renamed to")) | ||
| 494 | (vc-hg-extra-fileinfo->extra-name extra)) | ||
| 495 | 'face 'font-lock-comment-face))))) | ||
| 496 | |||
| 477 | (defun vc-hg-after-dir-status (update-function) | 497 | (defun vc-hg-after-dir-status (update-function) |
| 478 | (let ((status-char nil) | 498 | (let ((status-char nil) |
| 479 | (file nil) | 499 | (file nil) |
| @@ -484,24 +504,50 @@ REV is the revision to check out into WORKFILE." | |||
| 484 | (?M . edited) | 504 | (?M . edited) |
| 485 | (?I . ignored) | 505 | (?I . ignored) |
| 486 | (?! . missing) | 506 | (?! . missing) |
| 507 | (? . copy-rename-line) | ||
| 487 | (?? . unregistered))) | 508 | (?? . unregistered))) |
| 488 | (translated nil) | 509 | (translated nil) |
| 489 | (result nil)) | 510 | (result nil) |
| 511 | (last-added nil) | ||
| 512 | (last-line-copy nil)) | ||
| 490 | (goto-char (point-min)) | 513 | (goto-char (point-min)) |
| 491 | (while (not (eobp)) | 514 | (while (not (eobp)) |
| 492 | (setq status-char (char-after)) | 515 | (setq translated (cdr (assoc (char-after) translation))) |
| 493 | (setq file | 516 | (setq file |
| 494 | (buffer-substring-no-properties (+ (point) 2) | 517 | (buffer-substring-no-properties (+ (point) 2) |
| 495 | (line-end-position))) | 518 | (line-end-position))) |
| 496 | (setq translated (assoc status-char translation)) | 519 | (cond ((not translated) |
| 497 | (when (and translated (not (eq (cdr translated) 'up-to-date))) | 520 | (setq last-line-copy nil)) |
| 498 | (push (list file (cdr translated)) result)) | 521 | ((eq translated 'up-to-date) |
| 522 | (setq last-line-copy nil)) | ||
| 523 | ((eq translated 'copy-rename-line) | ||
| 524 | ;; For copied files the output looks like this: | ||
| 525 | ;; A COPIED_FILE_NAME | ||
| 526 | ;; ORIGINAL_FILE_NAME | ||
| 527 | (setf (nth 2 last-added) | ||
| 528 | (vc-hg-create-extra-fileinfo 'copied file)) | ||
| 529 | (setq last-line-copy t)) | ||
| 530 | ((and last-line-copy (eq translated 'removed)) | ||
| 531 | ;; For renamed files the output looks like this: | ||
| 532 | ;; A NEW_FILE_NAME | ||
| 533 | ;; ORIGINAL_FILE_NAME | ||
| 534 | ;; R ORIGINAL_FILE_NAME | ||
| 535 | ;; We need to adjust the previous entry to not think it is a copy. | ||
| 536 | (setf (vc-hg-extra-fileinfo->rename-state (nth 2 last-added)) | ||
| 537 | 'renamed-from) | ||
| 538 | (push (list file translated | ||
| 539 | (vc-hg-create-extra-fileinfo | ||
| 540 | 'renamed-to (nth 0 last-added))) result) | ||
| 541 | (setq last-line-copy nil)) | ||
| 542 | (t | ||
| 543 | (setq last-added (list file translated nil)) | ||
| 544 | (push last-added result) | ||
| 545 | (setq last-line-copy nil))) | ||
| 499 | (forward-line)) | 546 | (forward-line)) |
| 500 | (funcall update-function result))) | 547 | (funcall update-function result))) |
| 501 | 548 | ||
| 502 | ;; XXX Experimental function for the vc-dired replacement. | ||
| 503 | (defun vc-hg-dir-status (dir update-function) | 549 | (defun vc-hg-dir-status (dir update-function) |
| 504 | (vc-hg-command (current-buffer) 'async dir "status") | 550 | (vc-hg-command (current-buffer) 'async dir "status" "-C") |
| 505 | (vc-exec-after | 551 | (vc-exec-after |
| 506 | `(vc-hg-after-dir-status (quote ,update-function)))) | 552 | `(vc-hg-after-dir-status (quote ,update-function)))) |
| 507 | 553 | ||